TextShape
subclass of Shape
A text shape object.
Text
Layout
Type
attributedString
returns NSAttributedString; settable
Gets / Sets the shape's text using an NSAttributedString representation.
Example: if the frontmost selected shape is a text shape, change its font to 32pt Arial
var shape = [[[app activeDocument] selectedShapes] lastObject]
if(shape && [shape type] == "textShape")
{
var font = [NSFont fontWithName:"Arial" size:32]
var dict = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]
var str = [[NSAttributedString alloc] initWithString:[shape string] attributes:dict]
shape.attributedString = str
[str release]
}
sizeToFit
Resizes the text shape's bounding box to fit its text.
Example: update the bounds of the selected text shapes to fit their text
var shapes = [[app activeDocument] selectedShapes]
for(var i = 0; i < [shapes count]; i++)
{
var shape = shapes[i]
if([shape type] == "textShape")
[shape sizeToFit]
}
string
returns String
Gets a string representation of the shape's text. Use the attributedString property to modify the shape's text or text style.
Example: if the frontmost selected shape is a text shape, show an alert with its text string
var shape = [[[app activeDocument] selectedShapes] lastObject]
if(shape && [shape type] == "textShape")
[app showAlert:[shape string]]
textBoxBounds
returns CGRect; settable
Gets / Sets the text layout bounds of the shape. The text is wrapped inside this bounds.
Example: if the frontmost selected shape is a text shape, set its text bounds to 200 x 400 px
var doc = [app activeDocument]
var shape = [[doc selectedShapes] lastObject]
if(shape && [shape type] == "textShape")
{
var textBounds = [shape textBoxBounds]
textBounds.size.width = 200
textBounds.size.height = 400
shape.textBoxBounds = textBounds
}
type
returns String
Gets the type of this shape - "textShape"
Next: Path
