mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-09 12:17:13 +00:00
Compare commits
11
Commits
v0.9.6-RC2
...
coretext
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a80147bafd | ||
|
|
f170e4812d | ||
|
|
070728aea9 | ||
|
|
5e3ae58d42 | ||
|
|
b4e4bdb924 | ||
|
|
0f097e0ff4 | ||
|
|
e38845f993 | ||
|
|
f4f4dd8025 | ||
|
|
c942259c90 | ||
|
|
a4fb0920f6 | ||
|
|
4d47b5abf5 |
@@ -25,6 +25,7 @@
|
||||
@import "CPAnimation.j"
|
||||
@import "CPApplication.j"
|
||||
@import "CPArrayController.j"
|
||||
@import "CPAttributedString+Additions.j"
|
||||
@import "CPBezierPath.j"
|
||||
@import "CPBox.j"
|
||||
@import "CPBrowser.j"
|
||||
@@ -83,6 +84,7 @@
|
||||
@import "CPSound.j"
|
||||
@import "CPSplitView.j"
|
||||
@import "CPStepper.j"
|
||||
@import "CPString+Additions.j"
|
||||
@import "CPTableColumn.j"
|
||||
@import "CPTableView.j"
|
||||
@import "CPTabView.j"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* CPAttributedString+Additions.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Randy Luecke
|
||||
* Copyright 2011, RCLConcepts, LLC.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
AppKit adds two methods to the CPAttributedString class to support drawing string directly in an CPView.
|
||||
|
||||
AppKit also adds similar methods to CPString.
|
||||
*/
|
||||
@implementation CPAttributedString (AppKitAdditions)
|
||||
/*!
|
||||
Draws a string in the current graphics context.
|
||||
This method and draws the reciver on a single "infinately long" line.
|
||||
|
||||
@param aPoint - The starting point to draw the string
|
||||
*/
|
||||
- (void)drawAtPoint:(CGPoint)aPoint
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
line = CTLineCreateWithAttributedString([self copy]);
|
||||
|
||||
CGContextSetTextPosition(context, aPoint.x, aPoint.y);
|
||||
CTLineDraw(line, context);
|
||||
}
|
||||
|
||||
/*!
|
||||
Draws a string in the current graphics context.
|
||||
|
||||
@param aRect - The rect for which the string should be drawn into
|
||||
*/
|
||||
- (void)drawInRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
frameSetter = CTFramesetterCreateWithAttributedString([self copy]),
|
||||
path = CGPathCreateMutable();
|
||||
|
||||
CGPathAddRect(path, nil, aRect);
|
||||
|
||||
var frame = CTFramesetterCreateFrame(frameSetter, CPMakeRange(0, [self length]), path, nil);
|
||||
|
||||
CTFrameDraw(frame, context);
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* CPString+Additions.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Randy Luecke
|
||||
* Copyright 2011, RCLConcepts, LLC.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
AppKit adds two methods to the CPString class to support drawing string directly in an CPView.
|
||||
|
||||
AppKit also adds similar methods to CPAttributedString.
|
||||
The two drawing methods draw a string object with a single set of attributes that apply to the entire string.
|
||||
To draw a string with multiple attributes, such as multiple text fonts, you must use an attributed string.
|
||||
*/
|
||||
@implementation CPString (AppKitAdditions)
|
||||
|
||||
/*!
|
||||
Draws a string in the current graphics context.
|
||||
This method applies the attributes to the entier string
|
||||
and displays it on a single "infinately long" line.
|
||||
|
||||
@param aPoint - The starting point to draw the string
|
||||
@param attributes - the dictionary of attributes to apply to the string
|
||||
*/
|
||||
- (void)drawAtPoint:(CGPoint)aPoint withAttributes:(CPDictionary)attributes
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
run = _CTRunCreate([self copy], attributes);
|
||||
|
||||
CGContextSetTextPosition(context, aPoint.x, aPoint.y);
|
||||
CTRunDraw(run, context, nil);
|
||||
}
|
||||
|
||||
/*!
|
||||
Draws a string in the current graphics context.
|
||||
This method applies the attributes to the entier string
|
||||
and displays it within the given rect.
|
||||
|
||||
@param aRect - The rect for which the string should be drawn into
|
||||
@param attributes - the dictionary of attributes to apply to the string
|
||||
*/
|
||||
- (void)drawInRect:(CGRect)aRect withAttributes:(CPDictionary)attributes
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
string = [[CPAttributedString alloc] initWithString:self attributes:attributes];
|
||||
frameSetter = CTFramesetterCreateWithAttributedString(string),
|
||||
path = CGPathCreateMutable();
|
||||
|
||||
CGPathAddRect(path, nil, aRect);
|
||||
|
||||
var frame = CTFramesetterCreateFrame(frameSetter, CPMakeRange(0, [string length]), path, nil);
|
||||
|
||||
CTFrameDraw(frame, context);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* CGContextText.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
kCGTextFill = 0;
|
||||
kCGTextStroke = 1;
|
||||
kCGTextFillStroke = 2;
|
||||
kCGTextInvisible = 3;
|
||||
|
||||
function CGContextGetTextMatrix(/* CGContext */ aContext)
|
||||
{
|
||||
return aContext._textMatrix;
|
||||
}
|
||||
|
||||
function CGContextSetTextMatrix(/* CGContext */ aContext, /* CGAffineTransform */ aTransform)
|
||||
{
|
||||
aContext._textMatrix = aTransform;
|
||||
}
|
||||
|
||||
function CGContextGetTextPosition(/* CGContext */ aContext)
|
||||
{
|
||||
return aContext._textPosition || _CGPointMakeZero();
|
||||
}
|
||||
|
||||
function CGContextSetTextPosition(/* CGContext */ aContext, /* float */ x, /* float */ y)
|
||||
{
|
||||
aContext._textPosition = CGPointMake(x, y);
|
||||
}
|
||||
|
||||
function CGContextGetFont(/* CGContext */ aContext)
|
||||
{
|
||||
return aContext._CPFont;
|
||||
}
|
||||
|
||||
function CGContextSelectFont(/* CGContext */ aContext, /* CPFont */ aFont)
|
||||
{
|
||||
aContext.font = [aFont cssString];
|
||||
aContext._CPFont = aFont;
|
||||
}
|
||||
|
||||
function CGContextSetTextDrawingMode(/* CGContext */ aContext, /* CGTextDrawingMode */ aMode)
|
||||
{
|
||||
aContext._textDrawingMode = aMode;
|
||||
}
|
||||
|
||||
function CGContextShowText(/* CGContext */ aContext, /* CPString */ aString)
|
||||
{
|
||||
CGContextShowTextAtPoint(aContext, aContext._textPosition.x, aContext._textPosition.y, aString);
|
||||
}
|
||||
|
||||
function CGContextShowTextAtPoint(/* CGContext */ aContext, /* float */ x, /* float */ y, /* CPString */ aString)
|
||||
{
|
||||
aContext.textBaseline = @"middle";
|
||||
aContext.textAlign = @"left";
|
||||
|
||||
var mode = aContext._textDrawingMode;
|
||||
if (!mode && mode !== 0)
|
||||
mode = kCGTextFill;
|
||||
|
||||
var width = aContext.measureText(aString).width;
|
||||
|
||||
if (mode === kCGTextFill || mode === kCGTextFillStroke)
|
||||
aContext.fillText(aString, x, y);
|
||||
if (mode === kCGTextStroke || mode === kCGTextFillStroke)
|
||||
aContext.strokeText(aString, x, y);
|
||||
|
||||
aContext._textPosition = CGPointMake(x + width, y);
|
||||
}
|
||||
|
||||
// FIXME: these are hacks that override the default behavior.
|
||||
|
||||
function CGContextSetFillColor(/* CGContext */ aContext, /* CPColor */ aColor)
|
||||
{
|
||||
aContext.fillStyle = [aColor cssString];
|
||||
aContext._CPColor = aColor;
|
||||
}
|
||||
|
||||
function CGContextGetFillColor(/* CGContext */ aContext)
|
||||
{
|
||||
return aContext._CPColor;
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* CTFrame.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CTLine.j"
|
||||
|
||||
|
||||
kCTFrameProgressionTopToBottom = 0;
|
||||
kCTFrameProgressionRightToLeft = 1;
|
||||
|
||||
kCTFrameProgressionAttributeName = @"kCTFrameProgressionAttributeName";
|
||||
|
||||
function _CTFrameCreate(aPath, attributes, lines, attributedString)
|
||||
{
|
||||
return {
|
||||
path: aPath,
|
||||
attributes: attributes,
|
||||
lines: lines,
|
||||
string: attributedString
|
||||
};
|
||||
}
|
||||
|
||||
_CTFrameCreate.displayName = @"_CTFrameCreate";
|
||||
|
||||
/*!
|
||||
Returns the range of the frame based on the original string
|
||||
FIX ME: This implementation is wrong
|
||||
*/
|
||||
function CTFrameGetStringRange(/* CTFrame */ aFrame)
|
||||
{
|
||||
return CPMakeRange();
|
||||
}
|
||||
|
||||
CTFrameGetStringRange.displayName = @"CTFrameGetStringRange";
|
||||
|
||||
/*!
|
||||
Returns a range object with the visisble characters
|
||||
FIX ME: THis implementation is wrong
|
||||
*/
|
||||
function CTFrameGetVisibleStringRange(/* CTFrame */ aFrame)
|
||||
{
|
||||
return CPMakeRange();
|
||||
}
|
||||
|
||||
CTFrameGetVisibleStringRange.displayName = @"CTFrameGetVisibleStringRange";
|
||||
|
||||
/*!
|
||||
Returns the path for the frame.
|
||||
*/
|
||||
function CTFrameGetPath(/* CTFrame */ aFrame)
|
||||
{
|
||||
return aFrame.path;
|
||||
}
|
||||
|
||||
CTFrameGetPath.displayName = @"CTFrameGetPath";
|
||||
|
||||
/*!
|
||||
Returns a dictionary of attributes for the frame.
|
||||
*/
|
||||
function CTFrameGetFrameAttributes(/* CTFrame */ aFrame)
|
||||
{
|
||||
return aFrame.frameAttributes;
|
||||
}
|
||||
|
||||
CTFrameGetFrameAttributes.displayName = @"CTFrameGetFrameAttributes";
|
||||
|
||||
/*!
|
||||
Returns the array containing CTLines that make up the frame
|
||||
*/
|
||||
function CTFrameGetLines(/* CTFrame */ aFrame)
|
||||
{
|
||||
return aFrame.lines;
|
||||
}
|
||||
|
||||
CTFrameGetLines.displayName = @"CTFrameGetLines";
|
||||
|
||||
/*!
|
||||
Returns an array of CGPoints for the origin of each CTLine in the frame
|
||||
*/
|
||||
function CTFrameGetLineOrigins(/* CTFrame */ aFrame, /* CPRange */ aRange)
|
||||
{
|
||||
var results = [],
|
||||
lines = aRange ? CTFrameGetLinesForRange(aFrame, aRange) : aFrame.lines;
|
||||
|
||||
for (var i = -1, count = lines.length; ++i < count;)
|
||||
results.push(lines[i].origin);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
CTFrameGetLineOrigins.displayName = @"CTFrameGetLineOrigins";
|
||||
|
||||
/*!
|
||||
Returns an array of CTLines for a given range.
|
||||
Divergent from Cocoa and expensive.
|
||||
*/
|
||||
function CTFrameGetLinesForRange(/* CTFrame */ aFrame, /* CPRange */ lhs)
|
||||
{
|
||||
var lines = aFrame.lines, results = [];
|
||||
for (var i = -1, count = lines.length; ++i < count;)
|
||||
{
|
||||
var line = lines[i],
|
||||
rhs = CTLineGetStringRange(line);
|
||||
|
||||
if ((CPMaxRange(lhs) < rhs.location || CPMaxRange(rhs) < lhs.location) && result.length)
|
||||
break;
|
||||
|
||||
if (lhs.location >= rhs.location && rhs.location <= CPMaxRange(lhs) && CPMaxRange(rhs) > lhs.location)
|
||||
results.push(line);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
CTFrameGetLinesForRange.displayName = @"CTFrameGetLinesForRange";
|
||||
|
||||
/*!
|
||||
Returns a CPRange
|
||||
This is divergent from Cocoa. It's a convenience method used in CPTextView.
|
||||
*/
|
||||
function CTFrameGetRangeForPoint(/* CTFrame */ aFrame, /* CGPoint */ aPoint)
|
||||
{
|
||||
var lines = aFrame.lines, y = aPoint.y;
|
||||
for (var i = -1, count = lines.length; ++i < count;)
|
||||
{
|
||||
var line = lines[i],
|
||||
bounds = CTLineGetImageBounds(line),
|
||||
lineY = line._startPosition.y;
|
||||
|
||||
if (y >= lineY && y < bounds.size.height + lineY)
|
||||
{
|
||||
// FIXME: we seem to be doing stuff like this with some frequency;
|
||||
// Maybe it should be normalized at an earlier point.
|
||||
var index = CTLineGetStringIndexForPosition(line, aPoint),
|
||||
range = CTLineGetStringRange(line);
|
||||
|
||||
range.location += index;
|
||||
range.length = 0;
|
||||
return range;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CTFrameGetRangeForPoint.displayName = @"CTFrameGetRangeForPoint";
|
||||
|
||||
/*!
|
||||
Draws the frame to the graphics context.
|
||||
*/
|
||||
function CTFrameDraw(/* CTFrame */ aFrame, /* CGContext */ aContext)
|
||||
{
|
||||
var origin = aFrame.path.start,
|
||||
lines = aFrame.lines;
|
||||
|
||||
CGContextSetTextPosition(aContext, origin.x, origin.y);
|
||||
|
||||
for (var i = -1, count = lines.length; ++i < count;)
|
||||
{
|
||||
var line = lines[i],
|
||||
alignment = [line.string attribute:@"alignment" atIndex:0 effectiveRange:CPMakeRange(0, 0)],
|
||||
position = CGContextGetTextPosition(aContext);
|
||||
|
||||
if (alignment === CPRightTextAlignment)
|
||||
line.origin = CGPointMake((aFrame.path.elements[1].x - origin.x * 2) - CTLineGetTypographicBounds(line).width, position.y);
|
||||
else if (alignment === CPCenterTextAlignment)
|
||||
line.origin = CGPointMake(((aFrame.path.elements[1].x - origin.x) / 2) - CTLineGetTypographicBounds(line).width / 2, position.y);
|
||||
else
|
||||
line.origin = CGPointMake(origin.x, position.y);
|
||||
|
||||
CGContextSetTextPosition(aContext, line.origin.x, line.origin.y);
|
||||
CTLineDraw(line, aContext);
|
||||
}
|
||||
}
|
||||
|
||||
CTFrameDraw.displayName = @"CTFrameDraw";
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* CTFramesetter.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CTFrame.j"
|
||||
@import "CTTypesetter.j"
|
||||
|
||||
|
||||
/*!
|
||||
Creates a typesetter with a given CPAttributedString
|
||||
*/
|
||||
function CTFramesetterCreateWithAttributedString(/* CPAttributedString */ aString)
|
||||
{
|
||||
return {
|
||||
string: aString,
|
||||
typesetter: CTTypesetterCreateWithAttributedString(aString)
|
||||
};
|
||||
}
|
||||
|
||||
CTFramesetterCreateWithAttributedString.displayName = @"CTFramesetterCreateWithAttributedString";
|
||||
|
||||
/*!
|
||||
Creates a CTFrame with a given typesetter, range, path, and attributes
|
||||
*/
|
||||
function CTFramesetterCreateFrame(/* CTFramesetter */ aFramesetter, /* CPRange */ aRange, /* CGPath */ aPath, /* CPDictionary */ frameAttributes)
|
||||
{
|
||||
if (aFramesetter._cachedFrame && [aFramesetter._cachedAttributes isEqual:frameAttributes])
|
||||
return aFramesetter._cachedFrame;
|
||||
|
||||
var attributedString = aRange ? [aFramesetter.string attributedSubstringFromRange:aRange] : aFramesetter.string,
|
||||
nonattributedString = [attributedString string],
|
||||
splitLines = nonattributedString.split(/\n|\r/g),
|
||||
lines = [];
|
||||
|
||||
var index = 0;
|
||||
for (var i = -1, count = splitLines.length; ++i < count;)
|
||||
{
|
||||
var length = splitLines[i].length;
|
||||
if (i !== count - 1)
|
||||
++length;
|
||||
|
||||
var range = CPMakeRange(index, length),
|
||||
line = CTLineCreateWithAttributedString([attributedString attributedSubstringFromRange:range]);
|
||||
|
||||
line.range = range; // FIXME: a couple hacks to make managing lines in CPTextView easier
|
||||
line.prevLine = lastLine;
|
||||
|
||||
if (lastLine)
|
||||
lastLine.nextLine = line;
|
||||
|
||||
lines.push(line);
|
||||
index += length;
|
||||
|
||||
var lastLine = line;
|
||||
}
|
||||
|
||||
return aFramesetter._cachedFrame = _CTFrameCreate(aPath, frameAttributes, lines);
|
||||
}
|
||||
|
||||
CTFramesetterCreateFrame.displayName = @"CTFramesetterCreateFrame";
|
||||
|
||||
/*!
|
||||
Returns a CTTypesetter
|
||||
*/
|
||||
function CTFramesetterGetTypesetter(/* CTFramesetter */ aFramesetter)
|
||||
{
|
||||
return aFramesetter.typesetter;
|
||||
}
|
||||
|
||||
CTFramesetterGetTypesetter.displayName = @"CTFramesetterGetTypesetter";
|
||||
|
||||
/*!
|
||||
Returns a CGSize object with the suggested size for a given frame.
|
||||
*/
|
||||
function CTFramesetterSuggestFrameSizeWithConstraints(/* CTFramesetter */ aFramesetter, /* CPRange */ aRange, /* CPDictionary */ frameAttributes, /* CGSize */ constraints, /* {CPRange} */ fitRange)
|
||||
{
|
||||
var frame = CTFramesetterCreateFrame(aFramesetter, aRange, null, frameAttributes),
|
||||
lines = CTFrameGetLines(frame),
|
||||
width = 0.0,
|
||||
height = 0.0;
|
||||
|
||||
for (var i = -1, count = lines.length; ++i < count;)
|
||||
{
|
||||
var bounds = CTLineGetTypographicBounds(lines[i]);
|
||||
// var bounds = CTLineGetImageBounds(lines[i], [[CPGraphicsContext currentContext] graphicsPort]).size;
|
||||
width = MAX(width, bounds.width);
|
||||
height += bounds.lineHeight;
|
||||
// height += bounds.height;
|
||||
}
|
||||
|
||||
return CGSizeMake(width, height);
|
||||
}
|
||||
|
||||
CTFramesetterSuggestFrameSizeWithConstraints.displayName = @"CTFramesetterSuggestFrameSizeWithConstraints";
|
||||
|
||||
/*!
|
||||
Returns the CPAttributedString for a given framesetter
|
||||
*/
|
||||
function CTFramesetterGetAttributedString(/* CTFramesetter */ aFramesetter)
|
||||
{
|
||||
return aFramesetter.string;
|
||||
}
|
||||
|
||||
CTFramesetterGetAttributedString.displayName = @"CTFramesetterGetAttributedString";
|
||||
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* CTLine.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CTRun.j"
|
||||
|
||||
|
||||
kCTLineTruncationStart = 0;
|
||||
kCTLineTruncationEnd = 1;
|
||||
kCTLineTruncationMiddle = 2;
|
||||
|
||||
/*!
|
||||
Creates a new line with a supplied CPAttributedString
|
||||
*/
|
||||
function CTLineCreateWithAttributedString(/* CPAttributedString */ aString)
|
||||
{
|
||||
var line = {
|
||||
string: aString,
|
||||
runs: []
|
||||
};
|
||||
|
||||
_CTLineCreateRuns(line);
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
CTLineCreateWithAttributedString.displayName = @"CTLineCreateWithAttributedString";
|
||||
|
||||
/*!
|
||||
Creates a new line truncated to a given width.
|
||||
@param aLine - The input line
|
||||
@param width - The constraining width
|
||||
@param truncationToken - The characters to represent the truncation. This is usually an elipsis. If not token is given the string will just clip
|
||||
|
||||
FIX ME: Not implemented correctly
|
||||
*/
|
||||
function CTLineCreateTruncatedLine(/* CTLine */ aLine, /* float */ width, /* CTLineTruncationType */ truncationType, /* CTLine */ truncationToken)
|
||||
{
|
||||
return aLine;
|
||||
}
|
||||
|
||||
CTLineCreateTruncatedLine.displayName = @"CTLineCreateTruncatedLine";
|
||||
|
||||
/*!
|
||||
Returns a CTLine with justified text.
|
||||
FIX ME: This is not implemented correctly
|
||||
*/
|
||||
function CTLineCreateJustifiedLine(/* CTline */ aLine, /* float */ justificationFactor, /* float */ width)
|
||||
{
|
||||
return aLine;
|
||||
}
|
||||
|
||||
CTLineCreateJustifiedLine.displayName = @"CTLineCreateJustifiedLine";
|
||||
|
||||
/*!
|
||||
Returns the number of glyphs in a given line.
|
||||
*/
|
||||
function CTLineGetGlyphCount(/* CTLine */ aLine)
|
||||
{
|
||||
return [aLine.string length];
|
||||
}
|
||||
|
||||
CTLineGetGlyphCount.displayName = @"CTLineGetGlyphCount";
|
||||
|
||||
/*!
|
||||
Returns the array of CTRuns that make up the line.
|
||||
*/
|
||||
function CTLineGetGlyphRuns(/* CTLine */ aLine)
|
||||
{
|
||||
return aLine.runs;
|
||||
}
|
||||
|
||||
CTLineGetGlyphRuns.displayName = @"CTLineGetGlyphRuns";
|
||||
|
||||
/*!
|
||||
Returns the range for which the CTLine makes up the original string
|
||||
*/
|
||||
function CTLineGetStringRange(/* CTLine */ aLine)
|
||||
{
|
||||
return CPCopyRange(aLine.range) || CPMakeRange(0, [aLine.string length])
|
||||
}
|
||||
|
||||
CTLineGetStringRange.displayName = @"CTLineGetStringRange";
|
||||
|
||||
/*!
|
||||
No op
|
||||
*/
|
||||
function CTLineGetPenOffsetForFlush(/* CTLine */ aLine, /* float */ flushFactor, /* float */ flushWidth)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CTLineGetPenOffsetForFlush.displayName = @"CTLineGetPenOffsetForFlush";
|
||||
/*!
|
||||
Draws the CTLine to the graphics context.
|
||||
*/
|
||||
function CTLineDraw(/* CTLine */ aLine, /* CGContext */ aContext)
|
||||
{
|
||||
var startPosition = aLine._startPosition = CGContextGetTextPosition(aContext),
|
||||
height = CTLineGetImageBounds(aLine, aContext).size.height;
|
||||
|
||||
// FIXME: This is WRONG. This NEEDS to be in CGContext.
|
||||
CGContextSetTextPosition(aContext, startPosition.x, startPosition.y + height * 0.5);
|
||||
|
||||
var runs = aLine.runs;
|
||||
for (var i = -1, count = runs.length; ++i < count;)
|
||||
CTRunDraw(runs[i], aContext);
|
||||
|
||||
CGContextSetTextPosition(aContext, startPosition.x, startPosition.y + height);
|
||||
}
|
||||
|
||||
CTLineDraw.displayName = @"CTLineDraw";
|
||||
|
||||
/*!
|
||||
Calcaulates the image bounds for a line.
|
||||
*/
|
||||
function CTLineGetImageBounds(/* CTLine */ aLine, /* CGContext */ aContext)
|
||||
{
|
||||
if (aLine._imageBounds)
|
||||
return aLine._imageBounds;
|
||||
|
||||
var runs = aLine.runs,
|
||||
width = 0.0,
|
||||
height = 0.0;
|
||||
|
||||
for (var i = -1, count = runs.length; ++i < count;)
|
||||
{
|
||||
var runSize = CTRunGetImageBounds(runs[i], aContext).size;
|
||||
width += runSize.width;
|
||||
height = MAX(height, runSize.height);
|
||||
}
|
||||
|
||||
return aLine._imageBounds = CGRectMake(0.0, 0.0, width, height);
|
||||
}
|
||||
|
||||
CTLineGetImageBounds.displayName = @"CTLineGetImageBounds";
|
||||
|
||||
/*!
|
||||
Returns a JSObject: {width: float, ascent: float, descent: float, lineHeight: float}
|
||||
This method is more expensive than CTLineGetImageBounds.
|
||||
*/
|
||||
function CTLineGetTypographicBounds(/* CTLine */ aLine)
|
||||
{
|
||||
if (aLine._typographicBounds)
|
||||
return aLine._typographicBounds;
|
||||
|
||||
var runs = aLine.runs,
|
||||
width = 0.0,
|
||||
ascent = 0.0,
|
||||
descent = 0.0,
|
||||
lineHeight = 0.0;
|
||||
|
||||
for (var i = -1, count = runs.length; ++i < count;)
|
||||
{
|
||||
var runObject = CTRunGetTypographicBounds(runs[i]);
|
||||
width += runObject.width;
|
||||
ascent = MAX(ascent, runObject.ascent);
|
||||
descent = MAX(descent, runObject.descent);
|
||||
lineHeight = MAX(lineHeight, runObject.lineHeight);
|
||||
}
|
||||
|
||||
return aLine._typographicBounds = {
|
||||
width: width,
|
||||
ascent: ascent,
|
||||
descent: descent,
|
||||
lineHeight: lineHeight
|
||||
};
|
||||
}
|
||||
|
||||
CTLineGetTypographicBounds.displayName = @"CTLineGetTypographicBounds";
|
||||
|
||||
/*!
|
||||
Returns the index of the line based on the original string
|
||||
*/
|
||||
function CTLineGetStringIndexForPosition(/* CTLine */ aLine, /* CGPoint */ aPoint)
|
||||
{
|
||||
var runs = aLine.runs, x = aPoint.x, index = 0;
|
||||
for (var i = -1, count = runs.length; ++i < count;)
|
||||
{
|
||||
var run = runs[i],
|
||||
origins = run.glyphOrigins;
|
||||
|
||||
for (var j = -1, jcount = origins.length; ++j < jcount;)
|
||||
{
|
||||
var origin = origins[j], next;
|
||||
if (j < jcount - 1)
|
||||
next = origins[j + 1];
|
||||
else if (i < count - 1)
|
||||
next = runs[i + 1].glyphOrigins[0];
|
||||
else
|
||||
return index++;
|
||||
|
||||
if (x <= (next.x - origin.x) / 2 + origin.x)
|
||||
return index;
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CTLineGetStringIndexForPosition.displayName = @"CTLineGetStringIndexForPosition";
|
||||
|
||||
/*!
|
||||
Returns the offset corresponding to a string index,
|
||||
this works well for for movement between adjacent lines or for drawing a custom caret.
|
||||
*/
|
||||
function CTLineGetOffsetForStringIndex(/* CTLine */ aLine, /* int */ anIndex, /* float */ secondaryOffset)
|
||||
{
|
||||
var runs = aLine.runs;
|
||||
for (var i = -1, count = runs.length; ++i < count;)
|
||||
{
|
||||
var run = runs[i], runRange = run.range;
|
||||
if (CPLocationInRange(anIndex, runRange))
|
||||
return run.glyphOrigins[anIndex - runRange.location];
|
||||
}
|
||||
}
|
||||
|
||||
CTLineGetOffsetForStringIndex.displayName = @"CTLineGetOffsetForStringIndex";
|
||||
|
||||
function _CTLineCreateRuns(aLine)
|
||||
{
|
||||
var string = aLine.string,
|
||||
runs = aLine.runs,
|
||||
rangeEntries = string._rangeEntries;
|
||||
|
||||
for (var i = -1, count = rangeEntries.length; ++i < count;)
|
||||
{
|
||||
var rangeEntry = rangeEntries[i],
|
||||
range = rangeEntry.range,
|
||||
rangeString = [[string string] substringWithRange:range],
|
||||
attributes = rangeEntry.attributes;
|
||||
|
||||
var run = _CTRunCreate(rangeString, attributes);
|
||||
run.range = range;
|
||||
|
||||
runs.push(run);
|
||||
}
|
||||
}
|
||||
|
||||
_CTLineCreateRuns.displayName = @"_CTLineCreateRuns";
|
||||
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* CTRun.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
kCTRunStatusNoStatus = 0;
|
||||
kCTRunStatusRightToLeft = 1 << 0;
|
||||
kCTRunStatusNonMonotonic = 1 << 1;
|
||||
kCTRunStatusNonIdentityMatrix = 1 << 2;
|
||||
|
||||
/*!
|
||||
A CTRun represents a span of characters with common attribtues.
|
||||
*/
|
||||
|
||||
function _CTRunCreate(glyphs, attributes)
|
||||
{
|
||||
return {
|
||||
glyphs: glyphs,
|
||||
attributes: attributes,
|
||||
status: kCTRunStatusNoStatus
|
||||
};
|
||||
}
|
||||
|
||||
_CTRunCreate.displayName = @"_CTRunCreate";
|
||||
|
||||
/*!
|
||||
Returns the number of glyphs in the run.
|
||||
*/
|
||||
function CTRunGetGlyphCount(/* CTRun */ aRun)
|
||||
{
|
||||
return aRun.glyphs.length;
|
||||
}
|
||||
|
||||
CTRunGetGlyphCount.displayName = @"CTRunGetGlyphCount";
|
||||
|
||||
/*!
|
||||
Returns a CPDictionary of attributes for the CTRun
|
||||
*/
|
||||
function CTRunGetAttributes(/* CTRun */ aRun)
|
||||
{
|
||||
return aRun.attributes;
|
||||
}
|
||||
|
||||
CTRunGetAttributes.displayName = @"CTRunGetAttributes";
|
||||
|
||||
/*!
|
||||
Returns a CTRunStatus
|
||||
CTRuns have status that can be used to speed up certain operations.
|
||||
|
||||
Possible values:
|
||||
|
||||
@code
|
||||
kCTRunStatusNoStatus
|
||||
kCTRunStatusRightToLeft
|
||||
kCTRunStatusNonMonotonic
|
||||
kCTRunStatusNonIdentityMatrix
|
||||
@endcode
|
||||
*/
|
||||
function CTRunGetStatus(/* CTRun */ aRun)
|
||||
{
|
||||
return aRun.status || kCTRunStatusNoStatus;
|
||||
}
|
||||
|
||||
CTRunGetStatus.displayName = @"CTRunGetStatus";
|
||||
|
||||
/*!
|
||||
Returns an array of CGGlyphs
|
||||
FIX ME: Not implemented correctly
|
||||
*/
|
||||
function CTRunGetGlyphs(/* CTRun */ aRun, /* CPRange */ aRange)
|
||||
{
|
||||
if (!aRun.glyphs)
|
||||
aRun.glyphs = [];
|
||||
|
||||
return aRun.glyphs;
|
||||
}
|
||||
|
||||
CTRunGetGlyphs.displayName = @"CTRunGetGlyphs";
|
||||
|
||||
/*!
|
||||
Returns an array of CGPoints
|
||||
FIX ME: Not implemented correctly
|
||||
*/
|
||||
function CTRunGetPositions(/* CTRun */ aRun, /* CPRange */ aRange)
|
||||
{
|
||||
if (!aRun.positions)
|
||||
aRun.positions = [];
|
||||
|
||||
return aRun.positions;
|
||||
}
|
||||
|
||||
CTRunGetPositions.displayName = @"CTRunGetPositions";
|
||||
|
||||
/*!
|
||||
Returns an array of CGSizes
|
||||
FIX ME: Not implemented correctly
|
||||
*/
|
||||
function CTRunGetAdvances(/* CTRun */ aRun, /* CPRange */ aRange)
|
||||
{
|
||||
if (!aRun.advances)
|
||||
aRun.advances = [];
|
||||
|
||||
return aRun.advances;
|
||||
}
|
||||
|
||||
CTRunGetAdvances.displayName = @"CTRunGetAdvances";
|
||||
|
||||
/*!
|
||||
Returns an array of indexes.
|
||||
FIX ME: Not implemented correctly
|
||||
*/
|
||||
function CTRunGetStringIndices(/* CTRun */ aRun, /* CPRange */ aRange)
|
||||
{
|
||||
if (!aRun.stringIndices)
|
||||
aRun.stringIndices = [];
|
||||
|
||||
return aRun.stringIndices;
|
||||
}
|
||||
|
||||
CTRunGetStringIndices.displayName = @"CTRunGetStringIndices";
|
||||
|
||||
/*!
|
||||
Returns a CPRange containing the location of the run in the parent string
|
||||
*/
|
||||
function CTRunGetStringRange(/* CTRun */ aRun)
|
||||
{
|
||||
return aRun.range;
|
||||
}
|
||||
|
||||
CTRunGetStringRange.displayName = @"CTRunGetStringRange";
|
||||
|
||||
/*!
|
||||
Returns a JSObject: {width: float, ascender: float, descender: float, lineHeight: float}
|
||||
More expensive
|
||||
*/
|
||||
function CTRunGetTypographicBounds(/* CTRun */ aRun, /* CPRange */ aRange)
|
||||
{
|
||||
if (aRun._typographicBounds)
|
||||
return aRun._typographicBounds;
|
||||
|
||||
var attributes = aRun.attributes,
|
||||
font = [attributes valueForKey:@"font"],
|
||||
string = _CTRunStringForRange(aRun, aRange);
|
||||
|
||||
return aRun._typographicBounds = {
|
||||
width: [string sizeWithFont:font].width, // FIXME: account for tabs
|
||||
ascender: [font ascender],
|
||||
descender: [font descender],
|
||||
lineHeight: [font defaultLineHeightForFont]
|
||||
};
|
||||
}
|
||||
|
||||
CTRunGetTypographicBounds.displayName = @"CTRunGetTypographicBounds";
|
||||
|
||||
/*!
|
||||
Returns a CGRect
|
||||
Cheap
|
||||
*/
|
||||
function CTRunGetImageBounds(/* CTRun */ aRun, /* CGContext */ aContext, /* CPRange */ aRange)
|
||||
{
|
||||
if (aRun._imageBounds)
|
||||
return aRun._imageBounds;
|
||||
|
||||
_CTRunPrepareDraw(aRun, aContext);
|
||||
|
||||
var string = _CTRunStringForRange(aRun, aRange),
|
||||
width = aContext.measureText(string).width,
|
||||
height = [CGContextGetFont(aContext) defaultLineHeightForFont];
|
||||
|
||||
_CTRunUnprepareDraw(aRun, aContext);
|
||||
|
||||
return aRun._imageBounds = CGRectMake(0.0, 0.0, width, height);
|
||||
}
|
||||
|
||||
CTRunGetImageBounds.displayName = @"CTRunGetImageBounds";
|
||||
|
||||
// CGAffineTransform
|
||||
function CTRunGetTextMatrix(/* CTRun */ aRun)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CTRunGetTextMatrix.displayName = @"CTRunGetTextMatrix";
|
||||
|
||||
/*!
|
||||
Draws the run to the context
|
||||
*/
|
||||
function CTRunDraw(/* CTRun */ aRun, /* CGContext */ aContext, /* CPRange */ aRange)
|
||||
{
|
||||
_CTRunPrepareDraw(aRun, aContext);
|
||||
|
||||
var string = aRange ? [aRun.glyphs substringWithRange:aRange] : aRun.glyphs;
|
||||
_CTRunDrawShadow(aRun, aContext, string);
|
||||
|
||||
var origins = aRun.glyphOrigins = [];
|
||||
for (var i = -1, count = string.length; ++i < count;)
|
||||
{
|
||||
var glyph = string[i];
|
||||
origins[i] = CGContextGetTextPosition(aContext);
|
||||
|
||||
CGContextShowText(aContext, glyph);
|
||||
}
|
||||
|
||||
_CTRunUnprepareDraw(aRun, aContext);
|
||||
}
|
||||
|
||||
CTRunDraw.displayName = @"CTRunDraw";
|
||||
|
||||
function _CTRunDrawShadow(aRun, aContext, aString)
|
||||
{
|
||||
var attributes = aRun.attributes,
|
||||
textShadowColor = [attributes valueForKey:@"text-shadow-color"],
|
||||
textShadowOffset = [attributes valueForKey:@"text-shadow-offset"];
|
||||
|
||||
if (textShadowColor && textShadowOffset)
|
||||
{
|
||||
var color = CGContextGetFillColor(aContext),
|
||||
position = CGContextGetTextPosition(aContext);
|
||||
|
||||
CGContextSetFillColor(aContext, textShadowColor);
|
||||
CGContextShowTextAtPoint(aContext, position.x + textShadowOffset.width, position.y + textShadowOffset.height, aString);
|
||||
|
||||
CGContextSetFillColor(aContext, color);
|
||||
CGContextSetTextPosition(aContext, position.x, position.y);
|
||||
}
|
||||
}
|
||||
|
||||
_CTRunDrawShadow.displayName = @"_CTRunDrawShadow";
|
||||
|
||||
function _CTRunPrepareDraw(aRun, aContext)
|
||||
{
|
||||
var attributes = aRun.attributes,
|
||||
font = [attributes valueForKey:@"font"],
|
||||
color = [attributes valueForKey:@"color"];
|
||||
|
||||
if (font)
|
||||
{
|
||||
CGContextSelectFont(aContext, font);
|
||||
aRun._cachedFont = CGContextGetFont(aContext);
|
||||
}
|
||||
|
||||
if (color)
|
||||
{
|
||||
CGContextSetFillColor(aContext, color);
|
||||
aRun._cachedColor = CGContextGetFillColor(aContext);
|
||||
}
|
||||
}
|
||||
|
||||
_CTRunPrepareDraw.displayName = @"_CTRunPrepareDraw";
|
||||
|
||||
function _CTRunUnprepareDraw(aRun, aContext)
|
||||
{
|
||||
if (aRun._cachedFont)
|
||||
{
|
||||
CGContextSelectFont(aContext, aRun._cachedFont);
|
||||
aRun._cachedFont = nil;
|
||||
}
|
||||
|
||||
if (aRun._cachedColor)
|
||||
{
|
||||
CGContextSetFillColor(aContext, aRun._cachedColor);
|
||||
aRun._cachedColor = nil;
|
||||
}
|
||||
}
|
||||
|
||||
_CTRunUnprepareDraw.displayName = @"_CTRunUnprepareDraw";
|
||||
|
||||
function _CTRunStringForRange(aRun, aRange)
|
||||
{
|
||||
return (!aRange || aRange.length === 0) ? aRun.glyphs : [aRun.glyphs substringWithRange:aRange];
|
||||
}
|
||||
|
||||
_CTRunStringForRange.displayName = @"_CTRunStringForRange";
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* CTTypesetter.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CTLine.j"
|
||||
|
||||
|
||||
kCTTypesetterOptionDisableBidiProcessing = @"kCTTypesetterOptionDisableBidiProcessing";
|
||||
kCTTypesetterOptionForcedEmbeddingLevel = @"kCTTypesetterOptionForcedEmbeddingLevel";
|
||||
|
||||
// Returns a CTTypesetter
|
||||
function CTTypesetterCreateWithAttributedString(/* CPAttributedString */ aString)
|
||||
{
|
||||
return CTTypesetterCreateWithAttributedStringAndOptions(aString, nil);
|
||||
}
|
||||
|
||||
// Returns a CTTypesetter
|
||||
function CTTypesetterCreateWithAttributedStringAndOptions(/* CPAttributedString */ aString, /* CPDictionary */ aDictionary)
|
||||
{
|
||||
return {
|
||||
string: aString,
|
||||
options: aDictionary
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a CTLine
|
||||
function CTTypesetterCreateLine(/* CTTypesetter */ aTypesetter, /* CPRange */ aRange)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Returns an index
|
||||
function CTTypesetterSuggestLineBreak(/* CTTypesetter */ aTypesetter, /* int */ startIndex, /* float */ width)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Returns an index
|
||||
function CTTypesetterSuggestClusterBreak(/* CTTypesetter */ aTypesetter, /* int */ startIndex, /* float */ width)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* CoreText.j
|
||||
* CoreText
|
||||
*
|
||||
* Created by Nicholas Small.
|
||||
* Copyright 2011, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CTFramesetter.j"
|
||||
@import "CTFrame.j"
|
||||
@import "CTTypesetter.j"
|
||||
@import "CTLine.j"
|
||||
@import "CTRun.j"
|
||||
|
||||
@import "CGContextText.j"
|
||||
@@ -27,6 +27,10 @@
|
||||
@import "CPRange.j"
|
||||
@import "CPString.j"
|
||||
|
||||
|
||||
CPFontAttributeName = "font";
|
||||
CPForegroundColorAttributeName = "color";
|
||||
|
||||
/*!
|
||||
@class CPAttributedString
|
||||
@ingroup foundation
|
||||
@@ -42,6 +46,11 @@
|
||||
implements functionality from both NSAttributedString and
|
||||
NSMutableAttributedString. However, to ease converting of existing
|
||||
Objective-C code a CPMutableAttributedString alias to this class exists.
|
||||
|
||||
Below are a list of commonly used attributes:
|
||||
CPFontAttributeName - Font object
|
||||
CPForegroundColorAttributeName - CPColor object
|
||||
|
||||
*/
|
||||
@implementation CPAttributedString : CPObject
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
@import "CPArray.j"
|
||||
@import "CPAttributedString.j"
|
||||
@import "CPBundle.j"
|
||||
@import "CPCharacterSet.j"
|
||||
@import "CPCoder.j"
|
||||
|
||||
Reference in New Issue
Block a user