| Derived from | CFType |
| Framework | ApplicationServices/CoreText |
| Declared in | CTFont.h |
The CTFont opaque type represents a Core Text font object. Font objects represent fonts to an application, providing access to characteristics of the font, such as point size, transform matrix, and other attributes. Fonts provide assistance in laying out glyphs relative to one another and are used to establish the current font when drawing in a graphics context.
CTFontCreateWithName
CTFontCreateWithFontDescriptor
CTFontCreateUIFontForLanguage
CTFontCreateCopyWithAttributes
CTFontCreateCopyWithSymbolicTraits
CTFontCreateCopyWithFamily
CTFontCreateForString
CTFontCopyFontDescriptor
CTFontCopyAttribute
CTFontGetSize
CTFontGetMatrix
CTFontGetSymbolicTraits
CTFontCopyTraits
CTFontCopyPostScriptName
CTFontCopyFamilyName
CTFontCopyFullName
CTFontCopyDisplayName
CTFontCopyName
CTFontCopyLocalizedName
CTFontCopyCharacterSet
CTFontGetStringEncoding
CTFontCopySupportedLanguages
CTFontGetGlyphsForCharacters
CTFontGetAscent
CTFontGetDescent
CTFontGetLeading
CTFontGetUnitsPerEm
CTFontGetGlyphCount
CTFontGetBoundingBox
CTFontGetUnderlinePosition
CTFontGetUnderlineThickness
CTFontGetSlantAngle
CTFontGetCapHeight
CTFontGetXHeight
CTFontCreatePathForGlyph
CTFontGetGlyphWithName
CTFontGetBoundingRectsForGlyphs
CTFontGetAdvancesForGlyphs
CTFontGetVerticalTranslationsForGlyphs
CTFontCopyGraphicsFont
CTFontCreateWithGraphicsFont
CTFontGetPlatformFont
CTFontCreateWithPlatformFont
CTFontCreateWithQuickdrawInstance
Returns the value associated with an arbitrary attribute of the given font.
CFTypeRef CTFontCopyAttribute ( CTFontRef font, CFStringRef attribute );
The font reference.
The requested attribute.
A retained reference to an arbitrary attribute or NULL if the requested attribute is not present.
Refer to the attribute definitions documentation for information as to how each attribute is packaged as a CFType.
CTFont.hReturns an array of font table tags.
CFArrayRef CTFontCopyAvailableTables ( CTFontRef font, CTFontTableOptions options );
The font reference.
The font table options.
An array of CTFontTableTag values for the given font and the supplied options.
The returned set will contain unboxed values, which can be extracted like so:
CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tags, index); |
CTFont.hReturns the Unicode character set of the font.
CFCharacterSetRef CTFontCopyCharacterSet ( CTFontRef font );
The font reference.
A retained reference to the font's character set.
The returned character set covers the nominal referenced by the font's Unicode 'cmap’ table.
CTFont.hReturns the display name of the given font.
CFStringRef CTFontCopyDisplayName ( CTFontRef font );
The font reference.
A retained reference to the localized display name of the font.
CTFont.hReturns the family name of the given font.
CFStringRef CTFontCopyFamilyName ( CTFontRef font );
The font reference.
A retained reference to the family name of the font.
CTFont.hReturns an array of font features.
CFArrayRef CTFontCopyFeatures ( CTFontRef font );
The font reference.
An array of font feature dictionaries for the font reference.
CTFont.hReturns an array of font feature-setting tuples.
CFArrayRef CTFontCopyFeatureSettings ( CTFontRef font );
The font reference.
A normalized array of font feature-setting dictionaries. The array contains only the nondefault settings that should be applied to the font, or NULL if the default settings should be used.
A feature-setting dictionary is a tuple of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair. Each setting dictionary indicates which setting is enabled. It is the caller's responsibility to handle exclusive and nonexclusive settings as necessary.
The feature settings are verified against those that the font supports and any that do not apply are removed. Further, feature settings that represent a default setting for the font are also removed.
CTFont.hReturns the normalized font descriptor for the given font reference.
CTFontDescriptorRef CTFontCopyFontDescriptor ( CTFontRef font );
The font reference.
A normalized font descriptor for a font containing enough information to recreate this font at a later time.
CTFont.hReturns the full name of the given font.
CFStringRef CTFontCopyFullName ( CTFontRef font );
The font reference.
A retained reference to the full name of the font.
CTFont.hReturns a Core Graphics font reference and attributes.
CGFontRef CTFontCopyGraphicsFont ( CTFontRef font, CTFontDescriptorRef *attributes );
The font reference.
On output, points to a font descriptor containing additional attributes from the font. Can be NULL. Must be released by the caller.
A CGFontRef object for the given font reference.
CTFont.hReturns a reference to a localized name for the given font.
CFStringRef CTFontCopyLocalizedName ( CTFontRef font, CFStringRef nameKey, CFStringRef *language );
The font reference.
The name specifier. See “Name Specifier Constants” for possible values.
On output, points to the language string of the returned name string. The format of the language identifier conforms to the RFC 3066bis standard.
A specific localized name from the font reference or NULL if the font does not have an entry for the requested name key.
The name is localized based on the user's global language preference precedence. That is, the user’s language preference is a list of languages in order of precedence. So, for example, if the list had Japanese and English, in that order, then a font that did not have Japanese name strings but had English strings would return the English strings.
CTFont.hReturns a reference to the requested name of the given font.
CFStringRef CTFontCopyName ( CTFontRef font, CFStringRef nameKey );
The font reference.
The name specifier. See “Name Specifier Constants” for possible values.
The requested name for the font, or NULL if the font does not have an entry for the requested name. The Unicode version of the name is preferred, otherwise the first available version is returned.
CTFont.hReturns the PostScript name of the given font.
CFStringRef CTFontCopyPostScriptName ( CTFontRef font );
The font reference.
A retained reference to the PostScript name of the font.
CTFont.hReturns an array of languages supported by the font.
CFArrayRef CTFontCopySupportedLanguages ( CTFontRef font );
The font reference.
A retained reference to an array of languages supported by the font. The array contains language identifier strings as CFStringRef objects. The format of the language identifier conforms to the RFC 3066bis standard.
CTFont.hReturns a reference to the font table data.
CFDataRef CTFontCopyTable ( CTFontRef font, CTFontTableTag table, CTFontTableOptions options );
The font reference.
The font table identifier as a CTFontTableTag constant. See “Font Table Tag Constants” for possible values.
The font table options.
A retained reference to the font table data as a CFDataRef object. The table data is not actually copied; however, the data reference must be released.
CTFont.hReturns the traits dictionary of the given font.
CFDictionaryRef CTFontCopyTraits ( CTFontRef font );
The font reference.
A retained reference to the font traits dictionary. Individual traits can be accessed with the trait key constants.
See the Constants section of CTFontDescriptor Reference for a definition of the font traits.
CTFont.hReturns a variation dictionary from the font reference.
CFDictionaryRef CTFontCopyVariation ( CTFontRef font );
The font reference.
The current variation instance as a dictionary.
The keys for each variation correspond to the variation identifier obtained via kCTFontVariationAxisIdentifierKey, which represents the four-character axis code as a CFNumber object.
CTFont.hReturns an array of variation axes.
CFArrayRef CTFontCopyVariationAxes ( CTFontRef font );
The font reference.
An array of variation axes dictionaries. Each variation axis dictionary contains the five variation axis keys listed in “Font Variation Axis Dictionary Keys”.
CTFont.hReturns a new font with additional attributes based on the original font.
CTFontRef CTFontCreateCopyWithAttributes ( CTFontRef font, CGFloat size, const CGAffineTransform *matrix, CTFontDescriptorRef attributes );
The original font reference on which to base the new font.
The point size for the font reference. If 0.0 is specified, the original font’s size is preserved.
The transformation matrix for the font. If NULL is specified, the original font’s matrix is preserved.
A font descriptor containing additional attributes that the new font should contain.
A new font reference converted from the original with the specified attributes.
This function provides a mechanism to change attributes quickly on a given font reference in response to user actions. For instance, the size can be changed in response to a user manipulating a size slider.
CTFont.hReturns a new font in the specified family based on the traits of the original font.
CTFontRef CTFontCreateCopyWithFamily ( CTFontRef font, CGFloat size, const CGAffineTransform *matrix, CFStringRef family );
The original font reference on which to base the new font.
The point size for the font reference. If 0.0 is specified, the original font’s size is preserved.
The transformation matrix for the font. If NULL is specified, the original font’s matrix is preserved.
The name of the desired family.
A new font reference with the original traits in the given family, or NULL if none is found in the system.
CTFont.hReturns a new font in the same font family as the original with the specified symbolic traits.
CTFontRef CTFontCreateCopyWithSymbolicTraits ( CTFontRef font, CGFloat size, const CGAffineTransform *matrix, uint32_t symTraitValue, uint32_t symTraitMask );
The original font reference on which to base the new font.
The point size for the font reference. If 0.0 is specified, the original font’s size is preserved.
The transformation matrix for the font. If NULL is specified, the original font’s matrix is preserved.
The value of the symbolic traits.
The mask bits of the symbolic traits.
A new font reference in the same family with the given symbolic traits. or NULL if none is found in the system.
CTFont.hReturns a new font reference that can best map the given string range based on the current font.
CTFontRef CTFontCreateForString ( CTFontRef currentFont, CFStringRef string, CFRange range );
The current font that contains a valid cascade list.
A unicode string containing characters that cannot be encoded by the current font.
A CFRange structure specifying the range of the string that needs to be mapped.
The best substitute font from the cascade list of the current font that can encode the specified string range. If the current font is capable of encoding the string range, then it is retained and returned.
CTFont.hCreates a path for the specified glyph.
CGPathRef CTFontCreatePathForGlyph( CTFontRef font, CGGlyph glyph, const CGAffineTransform *transform );
The font reference.
The glyph.
An affine transform applied to the path. Can be NULL. If NULL, CGAffineTransformIdentity is used.
A CGPath object containing the glyph outlines, NULL on error. Must be released by caller.
Creates a path from the outlines of the glyph for the specified font. The path reflects the font point size, matrix, and transform parameter, applied in that order. The transform parameter is most commonly be used to provide a translation to the desired glyph origin.
CTFont.hReturns the special user-interface font for the given language and user-interface type.
CTFontRef CTFontCreateUIFontForLanguage ( CTFontUIFontType uiType, CGFloat size, CFStringRef language );
A constant specifying the intended user-interface use for the requested font reference. See “Enumerations” for possible values.
The point size for the font reference. If 0.0 is specified, the default size for the requested user-interface type is used.
Language specifier string to select a font for a particular localization. If NULL is specified, the current system language is used. The format of the language identifier should conform to the RFC 3066bis standard.
The correct font for various user-interface uses.
The only required parameter is the uiType selector; the other parameters have default values.
CTFont.hReturns a new font reference that best matches the given font descriptor.
CTFontRef CTFontCreateWithFontDescriptor ( CTFontDescriptorRef descriptor, CGFloat size, const CGAffineTransform *matrix );
A font descriptor containing attributes that specify the requested font.
The point size for the font reference. If 0.0 is specified, the default font size of 12.0 is used.
The transformation matrix for the font. If NULL is specified, the identity matrix is used.
A CTFontRef that best matches the attributes provided with the font descriptor.
The size and matrix parameters override any specified in the font descriptor unless they are unspecified (0.0 for size and NULL for matrix). A best match font is always returned, and default values are used for any unspecified parameters.
CTFont.hCreates a new font reference from an existing Core Graphics font reference.
CTFontRef CTFontCreateWithGraphicsFont ( CGFontRef graphicsFont, CGFloat size, const CGAffineTransform *matrix, CTFontDescriptorRef attributes );
A valid Core Graphics font reference.
The point size for the font reference. If 0.0 is specified the default font size of 12.0 is used.
The transformation matrix for the font. If NULL, the identity matrix is used. Optional.
Additional attributes that should be matched. Optional.
A new font reference for an existing CGFontRef object with the specified size, matrix, and additional attributes.
CTFont.hReturns a new font reference for the given name.
CTFontRef CTFontCreateWithName ( CFStringRef name, CGFloat size, const CGAffineTransform *matrix );
The font name for which you wish to create a new font reference. A valid PostScript name is preferred, although other font name types are matched in a fallback manner.
The point size for the font reference. If 0.0 is specified, the default font size of 12.0 is used.
The transformation matrix for the font. If NULL is specified, the identity matrix is used.
Returns a CTFontRef that best matches the name provided with size and matrix attributes.
The name parameter is the only required parameter, and default values are used for unspecified parameters (0.0 for size and NULL for matrix). If all parameters cannot be matched identically, a best match is found.
CTFont.hCreates a new font reference from an ATS font reference.
CTFontRef CTFontCreateWithPlatformFont ( ATSFontRef platformFont, CGFloat size, const CGAffineTransform *matrix, CTFontDescriptorRef attributes );
A valid ATSFontRef object.
The point size for the font reference. If 0.0 is specified the default font size of 12.0 is used.
The transformation matrix for the font. If NULL, the identity matrix is used. Optional.
A CTFontDescriptorRef containing additional attributes that should be matched. Optional.
A new font reference for an ATSFontRef with the specified size, matrix, and additional attribtues.
CTFont.hReturns a font reference for the given QuickDraw instance.
CTFontRef CTFontCreateWithQuickdrawInstance ( ConstStr255Param name, int16_t identifier, uint8_t style, CGFloat size );
The QuickDraw font name. If zero length, identifier must be specified.
The QuickDraw font identifier. Can be 0, but if so, name must be specified.
The QuickDraw font style.
The point size for the font reference. If 0.0 is specified, the default size of 12.0 is used.
The best font instance matching the QuickDraw instance information.
This function is provided for compatibility support between Core Text and clients needing to support QuickDraw-style font references. QuickDraw is a deprecated technology in Mac OS X v10.4 and later.
CTFont.hCalculates the advances for an array of glyphs and returns the summed advance.
double CTFontGetAdvancesForGlyphs ( CTFontRef font, CTFontOrientation orientation, const CGGlyph glyphs[], CGSize advances[], CFIndex count );
The font reference.
The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
An array of count number of glyphs.
An array of count number of CGSize objects to receive the computed glyph advances. If NULL, only the overall advance is calculated.
The capacity of the glyphs and advances buffers.
The summed glyph advance of an array of glyphs.
Individual glyph advances are passed back via the advances parameter. These are the ideal metrics for each glyph scaled and transformed in font space.
CTFont.hReturns the scaled font-ascent metric of the given font.
CGFloat CTFontGetAscent ( CTFontRef font );
The font reference.
The font-ascent metric scaled according to the point size and matrix of the font reference.
CTFont.hReturns the scaled bounding box of the given font.
CGRect CTFontGetBoundingBox ( CTFontRef font );
The font reference.
The design bounding box of the font, which is the rectangle defined by xMin, yMin, xMax, and yMax values for the font. Returns CGRectNull on error.
CTFont.hCalculates the bounding rects for an array of glyphs and returns the overall bounding rectangle for the glyph run.
CGRect CTFontGetBoundingRectsForGlyphs ( CTFontRef font, CTFontOrientation orientation, const CGGlyph glyphs[], CGRect boundingRects[], CFIndex count );
The font reference.
The intended drawing orientation of the glyphs. Used to determined which glyph metrics to return.
An array of count number of glyphs.
On output, the computed glyph rectangles in an array of count number of CGRect objects. If NULL, only the overall bounding rectangle is calculated.
The capacity of the glyphs and boundingRects buffers.
The overall bounding rectangle for an array or run of glyphs. Returns CGRectNull on error.
The bounding rectangles of the individual glyphs are returned through the boundingRects parameter. These are the design metrics from the font transformed in font space.
CTFont.hReturns the cap-height metric of the given font.
CGFloat CTFontGetCapHeight ( CTFontRef font );
The font reference.
The font cap-height metric scaled according to the point size and matrix of the font reference.
CTFont.hReturns the scaled font-descent metric of the given font.
CGFloat CTFontGetDescent ( CTFontRef font );
The font reference.
The font-descent metric scaled according to the point size and matrix of the font reference.
CTFont.hReturns the number of glyphs of the given font.
CFIndex CTFontGetGlyphCount ( CTFontRef font );
The font reference.
The number of glyphs in the font.
CTFont.hProvides basic Unicode encoding for the given font, returning by reference an array of CGGlyph values corresponding to a given array of Unicode characters for the given font.
Boolean CTFontGetGlyphsForCharacters ( CTFontRef font, const UniChar characters[], CGGlyph glyphs[], CFIndex count );
The font reference.
An array of Unicode characters.
On output, points to an array of glyph values.
The capacity of the character and glyph arrays.
True if the font could encode all Unicode characters; otherwise False.
If a glyph could not be encoded, a value of 0 is passed back at the corresponding index in the glyphs array and the function returns False. It is the responsibility of the caller to handle the Unicode properties of the input characters.
CTFont.hReturns the CGGlyph value for the specified glyph name in the given font.
CGGlyph CTFontGetGlyphWithName ( CTFontRef font, CFStringRef glyphName );
The font reference.
The glyph name as a CFString object.
The glyph value for the named glyph as a CGGlyph object, or if the glyph name is not recognized, the .notdef glyph index value.
The returned CGGlyph object can be used with any of the subsequent glyph data accessors or directly with Core Graphics.
CTFont.hReturns the scaled font-leading metric of the given font.
CGFloat CTFontGetLeading ( CTFontRef font );
The font reference.
The font-leading metric scaled according to the point size and matrix of the font reference.
CTFont.hReturns the transformation matrix of the given font.
CGAffineTransform CTFontGetMatrix ( CTFontRef font );
The font reference.
The transformation matrix for the given font reference. This is the matrix that was provided when the font was created.
CTFont.hReturns an ATS font reference and attributes.
ATSFontRef CTFontGetPlatformFont ( CTFontRef font, CTFontDescriptorRef *attributes );
The font reference.
On output, points to a font descriptor containing additional attributes from the font. Can be NULL. Must be released by the caller.
An ATSFontRef object for the given font reference.
CTFont.hReturns the point size of the given font.
CGFloat CTFontGetSize ( CTFontRef font );
The font reference.
The point size of the given font reference. This is the point size provided when the font was created.
CTFont.hReturns the slant angle of the given font.
CGFloat CTFontGetSlantAngle ( CTFontRef font );
The font reference.
The transformed slant angle of the font. This is equivalent to the italic or caret angle with any skew from the tranformation matrix applied.
CTFont.hReturns the best string encoding for legacy format support.
CFStringEncoding CTFontGetStringEncoding ( CTFontRef font );
The font reference.
The best string encoding for the font.
CTFont.hReturns the symbolic traits of the given font.
CTFontSymbolicTraits CTFontGetSymbolicTraits ( CTFontRef font );
The font reference.
The symbolic traits of the font. This is equivalent to the kCTFontSymbolicTrait value of the traits dictionary.
See the Constants section of CTFontDescriptor Reference for a definition of the font traits.
CTFont.hReturns the type identifier for Core Text font references.
CFTypeID CTFontGetTypeID ( void );
The identifier for the CTFont opaque type.
CTFont.hReturns the scaled underline position of the given font.
CGFloat CTFontGetUnderlinePosition ( CTFontRef font );
The font reference.
The font underline-position metric scaled according to the point size and matrix of the font reference.
CTFont.hReturns the scaled underline-thickness metric of the given font.
CGFloat CTFontGetUnderlineThickness ( CTFontRef font );
The font reference.
The font underline-thickness metric scaled according to the point size and matrix of the font reference.
CTFont.hReturns the units-per-em metric of the given font.
unsigned CTFontGetUnitsPerEm ( CTFontRef font );
The font reference.
The units per em of the font.
CTFont.hCalculates the offset from the default (horizontal) origin to the vertical origin for an array of glyphs.
void CTFontGetVerticalTranslationsForGlyphs ( CTFontRef font, const CGGlyph glyphs[], CGSize translations[], CFIndex count );
The font reference.
An array of count number of glyphs.
On output, the computed origin offsets in an array of count number of CGSize objects.
The capacity of the glyphs and translations buffers.
CTFont.hReturns the x-height metric of the given font.
CGFloat CTFontGetXHeight ( CTFontRef font );
The font reference.
The font x-height metric scaled according to the point size and matrix of the font reference.
CTFont.hA reference to a Core Text font object.
typedef const struct __CTFont *CTFontRef;
CTFont.hName specifier constants provide access to the different names associated with a font.
const CFStringRef kCTFontCopyrightNameKey; const CFStringRef kCTFontFamilyNameKey; const CFStringRef kCTFontSubFamilyNameKey; const CFStringRef kCTFontStyleNameKey; const CFStringRef kCTFontUniqueNameKey; const CFStringRef kCTFontFullNameKey; const CFStringRef kCTFontVersionNameKey; const CFStringRef kCTFontPostScriptNameKey; const CFStringRef kCTFontTrademarkNameKey; const CFStringRef kCTFontManufacturerNameKey; const CFStringRef kCTFontDesignerNameKey; const CFStringRef kCTFontDescriptionNameKey; const CFStringRef kCTFontVendorURLNameKey; const CFStringRef kCTFontDesignerURLNameKey; const CFStringRef kCTFontLicenseNameKey; const CFStringRef kCTFontLicenseURLNameKey; const CFStringRef kCTFontSampleTextNameKey; const CFStringRef kCTFontPostScriptCIDNameKey;
kCTFontCopyrightNameKeyThe name specifier for the copyright name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontFamilyNameKeyThe name specifier for the family name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontSubFamilyNameKeyThe name specifier for the subfamily name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontStyleNameKeyThe name specifier for the style name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontUniqueNameKeyThe name specifier for the unique name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontFullNameKeyThe name specifier for the full name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontVersionNameKeyThe name specifier for the version name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontPostScriptNameKeyThe name specifier for the PostScript name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontTrademarkNameKeyThe name specifier for the trademark name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontManufacturerNameKeyThe name specifier for the manufacturer name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontDesignerNameKeyThe name specifier for the designer name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontDescriptionNameKeyThe name specifier for the description name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontVendorURLNameKeyThe name specifier for the vendor URL name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontDesignerURLNameKeyThe name specifier for the designer URL name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontLicenseNameKeyThe name specifier for the license name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontLicenseURLNameKeyThe name specifier for the license URL name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontSampleTextNameKeyThe name specifier for the sample text name string.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
kCTFontPostScriptCIDNameKeyThe name specifier for the PostScript character identifier (CID) font name.
Available in Mac OS X v10.5 and later.
Declared in CTFont.h
CTFont.hThese constants provide keys to font variation axis dictionary values.
const CFStringRef kCTFontVariationAxisIdentifierKey; const CFStringRef kCTFontVariationAxisMinimumValueKey; const CFStringRef kCTFontVariationAxisMaximumValueKey; const CFStringRef kCTFontVariationAxisDefaultValueKey; const CFStringRef kCTFontVariationAxisNameKey;