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.


Creating Fonts

func CTFontCreateWithFontDescriptor(CTFontDescriptor, CGFloat, UnsafePointer<CGAffineTransform>?)

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

func CTFontCreateUIFontForLanguage(CTFontUIFontType, CGFloat, CFString?)

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

func CTFontCreateCopyWithAttributes(CTFont, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontDescriptor?)

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

func CTFontCreateCopyWithSymbolicTraits(CTFont, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontSymbolicTraits, CTFontSymbolicTraits)

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

func CTFontCreateCopyWithFamily(CTFont, CGFloat, UnsafePointer<CGAffineTransform>?, CFString)

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

func CTFontCreateForString(CTFont, CFString, CFRange)

Returns a new font reference that can best map the given string range based on the current font.

Getting Font Data

func CTFontCopyFontDescriptor(CTFont)

Returns the normalized font descriptor for the given font reference.

func CTFontCopyAttribute(CTFont, CFString)

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

func CTFontGetSize(CTFont)

Returns the point size of the given font.

func CTFontGetMatrix(CTFont)

Returns the transformation matrix of the given font.

func CTFontGetSymbolicTraits(CTFont)

Returns the symbolic traits of the given font.

func CTFontCopyTraits(CTFont)

Returns the traits dictionary of the given font.

Getting Font Names

func CTFontCopyPostScriptName(CTFont)

Returns the PostScript name of the given font.

func CTFontCopyFamilyName(CTFont)

Returns the family name of the given font.

func CTFontCopyFullName(CTFont)

Returns the full name of the given font.

func CTFontCopyDisplayName(CTFont)

Returns the display name of the given font.

func CTFontCopyName(CTFont, CFString)

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

Working With Encoding

func CTFontCopyCharacterSet(CTFont)

Returns the Unicode character set of the font.

func CTFontGetStringEncoding(CTFont)

Returns the best string encoding for legacy format support.

func CTFontCopySupportedLanguages(CTFont)

Returns an array of languages supported by the font.

Getting Font Metrics

func CTFontGetAscent(CTFont)

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

func CTFontGetDescent(CTFont)

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

func CTFontGetLeading(CTFont)

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

func CTFontGetUnitsPerEm(CTFont)

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

func CTFontGetGlyphCount(CTFont)

Returns the number of glyphs of the given font.

func CTFontGetBoundingBox(CTFont)

Returns the scaled bounding box of the given font.

func CTFontGetUnderlinePosition(CTFont)

Returns the scaled underline position of the given font.

func CTFontGetUnderlineThickness(CTFont)

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

func CTFontGetSlantAngle(CTFont)

Returns the slant angle of the given font.

func CTFontGetCapHeight(CTFont)

Returns the cap-height metric of the given font.

func CTFontGetXHeight(CTFont)

Returns the x-height metric of the given font.

Getting Glyph Data

func CTFontGetGlyphWithName(CTFont, CFString)

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

func CTFontGetBoundingRectsForGlyphs(CTFont, CTFontOrientation, UnsafePointer<CGGlyph>, UnsafeMutablePointer<CGRect>?, CFIndex)

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

func CTFontGetVerticalTranslationsForGlyphs(CTFont, UnsafePointer<CGGlyph>, UnsafeMutablePointer<CGSize>, CFIndex)

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

Working With Font Variations

func CTFontCopyVariationAxes(CTFont)

Returns an array of variation axes.

func CTFontCopyVariation(CTFont)

Returns a variation dictionary from the font reference.

Getting Font Features

func CTFontCopyFeatures(CTFont)

Returns an array of font features.

func CTFontCopyFeatureSettings(CTFont)

Returns an array of font feature-setting tuples.

Working with Glyphs

func CTFontGetGlyphsForCharacters(CTFont, UnsafePointer<UniChar>, UnsafeMutablePointer<CGGlyph>, CFIndex)

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.

func CTFontDrawGlyphs(CTFont, UnsafePointer<CGGlyph>, UnsafePointer<CGPoint>, Int, CGContext)

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

Getting Font Table Data

Getting the Type Identifier

func CTFontGetTypeID()

Returns the type identifier for Core Text font references.

Data Types

class CTFont

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.


enum CTFontUIFontType

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

typealias CTFontTableTag

Font table tags provide access to font table data.

struct CTFontTableOptions

These constants describe font table options.

struct CTFontOptions

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

See Also

Opaque Types


The CTFontCollection opaque type represents a font collection, that is, a group of font descriptors taken together as a single object.


The CTFontDescriptor opaque type represents a font descriptor, that is, a dictionary of attributes (such as name, point size, and variation) that can completely specify a font.


The CTFrame opaque type represents a frame containing multiple lines of text. The frame object is the output resulting from the text-framing process performed by a framesetter object.


The CTFramesetter opaque type is used to generate text frames. That is, CTFramesetter is an object factory for CTFrame objects.


The CTGlyphInfo opaque type enables you to override a font's specified mapping from Unicode to the glyph ID.


The CTLine opaque type represents a line of text.


The CTParagraphStyle opaque type represents paragraph or ruler attributes in an attributed string.


The CTRun opaque type represents a glyph run, which is a set of consecutive glyphs sharing the same attributes and direction.


The CTRunDelegate opaque type represents a run delegate, which is assigned to a run (attribute range) to control typographic traits such glyph ascent, glyph descent, and glyph width.


The CTTextTab opaque type represents a tab in a paragraph style, storing an alignment type and location.


The CTTypesetter opaque type represents a typesetter, which performs line layout.