CTFont

A font object.

Overview

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.

Topics

Creating Fonts

CTFontCreateWithName

Returns a new font reference for the given name.

CTFontCreateWithNameAndOptions

Returns a new font reference for the given name.

CTFontCreateWithFontDescriptor

Returns a new font reference that best matches the given font descriptor.

CTFontCreateWithFontDescriptorAndOptions

Returns a new font reference that best matches the given font descriptor.

CTFontCreateUIFontForLanguage

Returns the special user-interface font for the given language and user-interface type.

CTFontCreateCopyWithAttributes

Returns a new font with additional attributes based on the original font.

CTFontCreateCopyWithSymbolicTraits

Returns a new font in the same font family as the original with the specified symbolic traits.

CTFontCreateCopyWithFamily

Returns a new font in the specified family based on the traits of the original font.

CTFontCreateForString

Returns a font reference that most accurately maps the string range based on the current font.

CTFontCreateForStringWithLanguage

Returns a font reference that most accurately maps the string range based on the current font and language.

Getting Font Data

CTFontCopyFontDescriptor

Returns the normalized font descriptor for the given font reference.

CTFontCopyAttribute

Returns the value associated with an arbitrary attribute of the given font.

CTFontGetSize

Returns the point size of the given font.

CTFontGetMatrix

Returns the transformation matrix of the given font.

CTFontGetSymbolicTraits

Returns the symbolic traits of the given font.

CTFontCopyTraits

Returns the traits dictionary of the given font.

CTFontCopyDefaultCascadeListForLanguages

Retrieves an ordered list of font substitution preferences.

Getting Font Names

CTFontCopyPostScriptName

Returns the PostScript name of the given font.

CTFontCopyFamilyName

Returns the family name of the given font.

CTFontCopyFullName

Returns the full name of the given font.

CTFontCopyDisplayName

Returns the display name of the given font.

CTFontCopyName

Returns a reference to the requested name of the given font.

CTFontCopyLocalizedName

Returns a reference to a localized name for the given font.

Working With Encoding

CTFontCopyCharacterSet

Returns the Unicode character set of the font.

CTFontGetStringEncoding

Returns the best string encoding for legacy format support.

CTFontCopySupportedLanguages

Returns an array of languages supported by the font.

Getting Font Metrics

CTFontGetAscent

Returns the scaled font-ascent metric of the given font.

CTFontGetDescent

Returns the scaled font-descent metric of the given font.

CTFontGetLeading

Returns the scaled font-leading metric of the given font.

CTFontGetUnitsPerEm

Returns the units-per-em metric of the given font.

CTFontGetGlyphCount

Returns the number of glyphs of the given font.

CTFontGetBoundingBox

Returns the scaled bounding box of the given font.

CTFontGetUnderlinePosition

Returns the scaled underline position of the given font.

CTFontGetUnderlineThickness

Returns the scaled underline-thickness metric of the given font.

CTFontGetSlantAngle

Returns the slant angle of the given font.

CTFontGetCapHeight

Returns the cap-height metric of the given font.

CTFontGetXHeight

Returns the x-height metric of the given font.

Getting Glyph Data

CTFontCreatePathForGlyph

Creates a path for the specified glyph.

CTFontGetGlyphWithName

Returns the CGGlyph value for the specified glyph name in the given font.

CTFontGetBoundingRectsForGlyphs

Calculates the bounding rects for an array of glyphs and returns the overall bounding rectangle for the glyph run.

CTFontGetAdvancesForGlyphs

Calculates the advances for an array of glyphs and returns the summed advance.

CTFontGetOpticalBoundsForGlyphs

Calculates the optical bounds for an array of glyphs and returns the overall optical bounds for the run.

CTFontGetVerticalTranslationsForGlyphs

Calculates the offset from the default (horizontal) origin to the vertical origin for an array of glyphs.

Working With Font Variations

CTFontCopyVariationAxes

Returns an array of variation axes.

CTFontCopyVariation

Returns a variation dictionary from the font reference.

Getting Font Features

CTFontCopyFeatures

Returns an array of font features.

CTFontCopyFeatureSettings

Returns an array of font feature-setting tuples.

Working with Glyphs

CTFontGetGlyphsForCharacters

Provides 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.

CTFontDrawGlyphs

Renders the given glyphs of a font at the specified positions in the supplied graphics context.

CTFontGetLigatureCaretPositions

Returns caret positions within a glyph.

Converting Fonts

CTFontCopyGraphicsFont

Returns a Core Graphics font reference and attributes.

CTFontCreateWithGraphicsFont

Creates a new font reference from an existing Core Graphics font reference.

CTFontGetPlatformFont

Returns an ATS font reference and attributes.

CTFontCreateWithPlatformFont

Creates a new font reference from an ATS font reference.

CTFontCreateWithQuickdrawInstance

Returns a font reference for the given QuickDraw instance.

Deprecated

Getting Font Table Data

CTFontCopyAvailableTables

Returns an array of font table tags.

CTFontCopyTable

Returns a reference to the font table data.

Getting the Type Identifier

CTFontGetTypeID

Returns the type identifier for Core Text font references.

Data Types

CTFontRef

A reference to a Core Text font object.

Global Variables

Name Specifier Constants

Name specifier constants provide access to the different names associated with a font.

Font Variation Axis Dictionary Keys

These constants provide keys to font variation axis dictionary values.

Font Feature Constants

These constants provide keys to font feature dictionary values.

Enumerations

CTFontUIFontType

These constants represent the specific user-interface purpose to specify for font creation.

CTFontTableTag

Font table tags provide access to font table data.

CTFontTableOptions

These constants describe font table options.

CTFontOptions

These constants describe options for font creation and descriptor matching. They are used by the functions CTFontCreateWithNameAndOptions and CTFontCreateWithFontDescriptorAndOptions.

See Also

Opaque Types

CTFramesetter

Generate text frames.

CTGlyphInfo

Override a font's specified mapping from Unicode to the glyph ID.

CTLine

A line of text.

CTParagraphStyle

Paragraph or ruler attributes in an attributed string.

CTTextTab

A tab in a paragraph style, storing an alignment type and location.

CTTypesetter

A typesetter which performs line layout.