Core Text String Attributes Reference
| Framework | ApplicationServices/CoreText |
| Declared in | CTStringAttributes.h |
Overview
This reference document describes the attributes to which Core Text responds when the attributes are placed in a CFAttributedString object.
Constants
String Attribute Name Constants
These constants represent string attribute names.
const CFStringRef kCTCharacterShapeAttributeName; const CFStringRef kCTFontAttributeName; const CFStringRef kCTKernAttributeName; const CFStringRef kCTLigatureAttributeName; const CFStringRef kCTForegroundColorAttributeName; const CFStringRef kCTForegroundColorFromContextAttributeName; const CFStringRef kCTParagraphStyleAttributeName; const CFStringRef kCTStrokeWidthAttributeName; const CFStringRef kCTStrokeColorAttributeName; const CFStringRef kCTSuperscriptAttributeName; const CFStringRef kCTUnderlineColorAttributeName; const CFStringRef kCTUnderlineStyleAttributeName; const CFStringRef kCTVerticalFormsAttributeName; const CFStringRef kCTGlyphInfoAttributeName; const CFStringRef kCTRunDelegateAttributeName
Constants
kCTCharacterShapeAttributeNameControls glyph selection. Value must be a
CFNumberRefobject. Default is value is0(disabled). A non-zero value is interpreted as Apple Type ServiceskCharacterShapeTypeselector+ 1(see<ATS/SFNTLayoutTypes.h>for selectors). For example, an attribute value of1corresponds tokTraditionalCharactersSelector.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTFontAttributeNameThe font of the text to which this attribute applies. The value associated with this attribute must be a CTFont object. Default is Helvetica 12.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTKernAttributeNameThe amount to kern the next character. The value associated with this attribute must be a CFNumber float. Default is standard kerning. The kerning attribute indicates how many points the following character should be shifted from its default offset as defined by the current character's font in points: a positive kern indicates a shift farther away from and a negative kern indicates a shift closer to the current character. If this attribute is not present, standard kerning is used. If this attribute is set to
0.0, no kerning is done at all.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTLigatureAttributeNameThe type of ligatures to use. The value associated with this attribute must be a CFNumber object. Default is an integer value of
1. The ligature attribute determines what kinds of ligatures should be used when displaying the string. A value of0indicates that only ligatures essential for proper rendering of text should be used. A value of1indicates that standard ligatures should be used, and2indicates that all available ligatures should be used. Which ligatures are standard depends on the script and possibly the font. Arabic text, for example, requires ligatures for many character sequences but has a rich set of additional ligatures that combine characters. English text has no essential ligatures, and typically has only two standard ligatures, those for "fi" and "fl"—all others are considered more advanced or fancy.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTForegroundColorAttributeNameThe foreground color of the text to which this attribute applies. The value associated with this attribute must be a CGColor object. Default value is black.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTForegroundColorFromContextAttributeNameSets a foreground color using the context's fill color. Value must be a
CFBooleanRefobject. Default isfalse. The reason this exists is because anNSAttributedStringobject defaults to a black color if no color attribute is set. This forces Core Text to set the color in the context. This attribute allows developers to sidestep this, making Core Text set nothing but font information in theCGContext. If set, this attribute also determines the color used bykCTUnderlineStyleAttributeName, in which case it overrides the foreground color.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTParagraphStyleAttributeNameThe paragraph style of the text to which this attribute applies. A paragraph style object is used to specify things like line alignment, tab rulers, writing direction, and so on. Value must be a CTParagraphStyle object. Default is an empty CTParagraphStyle object. See CTParagraphStyle Reference for more information.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTStrokeWidthAttributeNameThe stroke width. Value must be a
CFNumberRefobject. Default value is0.0, or no stroke. This attribute, interpreted as a percentage of font point size, controls the text drawing mode: positive values effect drawing with stroke only; negative values are for stroke and fill. A typical value for outlined text is3.0.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTStrokeColorAttributeNameThe stroke color. Value must be a
CGColorRefobject. Default is the foreground color.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTSuperscriptAttributeNameControls vertical text positioning. Value must be a
CFNumberRefobject. Default is integer value0. If supported by the specified font, a value of1enables superscripting and a value of-1enables subscripting.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlineColorAttributeNameThe underline color. Value must be a
CGColorRefobject. Default is the foreground color.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlineStyleAttributeNameThe style of underlining, to be applied at render time, for the text to which this attribute applies. Value must be a CFNumber object. Default is
kCTUnderlineStyleNone. Set a value of something other thankCTUnderlineStyleNoneto draw an underline. In addition, the constants listed in “CTUnderlineStyleModifiers” can be used to modify the look of the underline. The underline color is determined by the text's foreground color.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTVerticalFormsAttributeNameThe orientation of the glyphs in the text to which this attribute applies. Value must be a CFBoolean object. Default is
False. A value ofFalseindicates that horizontal glyph forms are to be used;Trueindicates that vertical glyph forms are to be used.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTGlyphInfoAttributeNameThe glyph info object to apply to the text associated with this attribute. Value must be a CTGlyphInfo object. The glyph specified by this CTGlyphInfo object is assigned to the entire attribute range, provided that its contents match the specified base string and that the specified glyph is available in the font specified by
kCTFontAttributeName. See CTGlyphInfo Reference for more information.Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTRunDelegateAttributeNameThe run-delegate object to apply to an attribute range of the string. The value must be a CTRunDelegate object. The run delegate controls such typographic traits as glyph ascent, descent, and width. The values returned by the embedded run delegate apply to each glyph resulting from the text in that range. Because an embedded object is only a display-time modification, you should avoid applying this attribute to a range of text with complex behavior, such as text having a change of writing direction or having combining marks. It is thus recommended you apply this attribute to a range containing the single character U+FFFC. See CTRunDelegate Reference for more information.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.
CTUnderlineStyle
Underline style specifiers.
enum{
kCTUnderlineStyleNone = 0x00,
kCTUnderlineStyleSingle = 0x01,
kCTUnderlineStyleThick = 0x02,
kCTUnderlineStyleDouble = 0x09
};
typedef int32_t CTUnderlineStyle;
Constants
kCTUnderlineStyleNoneDo not draw an underline.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlineStyleSingleDraw an underline consisting of a single line.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlineStyleThickDraw an underline consisting of a thick line.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlineStyleDoubleDraw an underline consisting of a double line.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.
Discussion
These underline type specifiers can be applied to the value set with the kCTUnderlineStyleAttributeName attribute to control the underline style Core Text uses when rendering the text to which the attribute applies.
CTUnderlineStyleModifiers
Underline style modifiers.
enum{
kCTUnderlinePatternSolid = 0x0000,
kCTUnderlinePatternDot = 0x0100,
kCTUnderlinePatternDash = 0x0200,
kCTUnderlinePatternDashDot = 0x0300,
kCTUnderlinePatternDashDotDot = 0x0400
};
typedef int32_t CTUnderlineStyleModifiers;
Constants
kCTUnderlinePatternSolidDraw a solid underline.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlinePatternDotDraw an underline using a pattern of dots.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlinePatternDashDraw an underline using a pattern of dashes.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlinePatternDashDotDraw an underline using a pattern of alternating dashes and dots.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.kCTUnderlinePatternDashDotDotDraw an underline using a pattern of a dash followed by two dots.
Available in iOS 3.2 and later.
Declared in
CTStringAttributes.h.
Discussion
Set these bits with the underline style (see “CTUnderlineStyle”) that you set with the kCTUnderlineStyleAttributeName attribute to modify how the underline will be drawn.
© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-02-25)