<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreText",
  "identifier" : "/documentation/CoreText/CTFont",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Text"
    ],
    "preciseIdentifier" : "c:@T@CTFontRef"
  },
  "title" : "CTFont"
}
-->

# CTFont

A font object.

```
class CTFont
```

## 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

[`func CTFontCreateWithName(CFString, CGFloat, UnsafePointer<CGAffineTransform>?) -> CTFont`](/documentation/CoreText/CTFontCreateWithName(_:_:_:))

Returns a new font reference for the given name.

[`func CTFontCreateWithNameAndOptions(CFString, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontOptions) -> CTFont`](/documentation/CoreText/CTFontCreateWithNameAndOptions(_:_:_:_:))

Returns a new font reference for the given name.

[`func CTFontCreateWithFontDescriptor(CTFontDescriptor, CGFloat, UnsafePointer<CGAffineTransform>?) -> CTFont`](/documentation/CoreText/CTFontCreateWithFontDescriptor(_:_:_:))

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

[`func CTFontCreateWithFontDescriptorAndOptions(CTFontDescriptor, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontOptions) -> CTFont`](/documentation/CoreText/CTFontCreateWithFontDescriptorAndOptions(_:_:_:_:))

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

[`func CTFontCreateUIFontForLanguage(CTFontUIFontType, CGFloat, CFString?) -> CTFont?`](/documentation/CoreText/CTFontCreateUIFontForLanguage(_:_:_:))

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

[`func CTFontCreateCopyWithAttributes(CTFont, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontDescriptor?) -> CTFont`](/documentation/CoreText/CTFontCreateCopyWithAttributes(_:_:_:_:))

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

[`func CTFontCreateCopyWithSymbolicTraits(CTFont, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontSymbolicTraits, CTFontSymbolicTraits) -> CTFont?`](/documentation/CoreText/CTFontCreateCopyWithSymbolicTraits(_:_:_:_:_:))

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

[`func CTFontCreateCopyWithFamily(CTFont, CGFloat, UnsafePointer<CGAffineTransform>?, CFString) -> CTFont?`](/documentation/CoreText/CTFontCreateCopyWithFamily(_:_:_:_:))

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

[`func CTFontCreateForString(CTFont, CFString, CFRange) -> CTFont`](/documentation/CoreText/CTFontCreateForString(_:_:_:))

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

[`func CTFontCreateForStringWithLanguage(CTFont, CFString, CFRange, CFString?) -> CTFont`](/documentation/CoreText/CTFontCreateForStringWithLanguage(_:_:_:_:))

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

### Getting Font Data

[`func CTFontCopyFontDescriptor(CTFont) -> CTFontDescriptor`](/documentation/CoreText/CTFontCopyFontDescriptor(_:))

Returns the normalized font descriptor for the given font reference.

[`func CTFontCopyAttribute(CTFont, CFString) -> CFTypeRef?`](/documentation/CoreText/CTFontCopyAttribute(_:_:))

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

[`func CTFontGetSize(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetSize(_:))

Returns the point size of the given font.

[`func CTFontGetMatrix(CTFont) -> CGAffineTransform`](/documentation/CoreText/CTFontGetMatrix(_:))

Returns the transformation matrix of the given font.

[`func CTFontGetSymbolicTraits(CTFont) -> CTFontSymbolicTraits`](/documentation/CoreText/CTFontGetSymbolicTraits(_:))

Returns the symbolic traits of the given font.

[`func CTFontCopyTraits(CTFont) -> CFDictionary`](/documentation/CoreText/CTFontCopyTraits(_:))

Returns the traits dictionary of the given font.

[`func CTFontCopyDefaultCascadeListForLanguages(CTFont, CFArray?) -> CFArray?`](/documentation/CoreText/CTFontCopyDefaultCascadeListForLanguages(_:_:))

Retrieves an ordered list of font substitution preferences.

### Getting Font Names

[`func CTFontCopyPostScriptName(CTFont) -> CFString`](/documentation/CoreText/CTFontCopyPostScriptName(_:))

Returns the PostScript name of the given font.

[`func CTFontCopyFamilyName(CTFont) -> CFString`](/documentation/CoreText/CTFontCopyFamilyName(_:))

Returns the family name of the given font.

[`func CTFontCopyFullName(CTFont) -> CFString`](/documentation/CoreText/CTFontCopyFullName(_:))

Returns the full name of the given font.

[`func CTFontCopyDisplayName(CTFont) -> CFString`](/documentation/CoreText/CTFontCopyDisplayName(_:))

Returns the display name of the given font.

[`func CTFontCopyName(CTFont, CFString) -> CFString?`](/documentation/CoreText/CTFontCopyName(_:_:))

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

[`func CTFontCopyLocalizedName(CTFont, CFString, UnsafeMutablePointer<Unmanaged<CFString>?>?) -> CFString?`](/documentation/CoreText/CTFontCopyLocalizedName(_:_:_:))

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

### Working With Encoding

[`func CTFontCopyCharacterSet(CTFont) -> CFCharacterSet`](/documentation/CoreText/CTFontCopyCharacterSet(_:))

Returns the Unicode character set of the font.

[`func CTFontGetStringEncoding(CTFont) -> CFStringEncoding`](/documentation/CoreText/CTFontGetStringEncoding(_:))

Returns the best string encoding for legacy format support.

[`func CTFontCopySupportedLanguages(CTFont) -> CFArray`](/documentation/CoreText/CTFontCopySupportedLanguages(_:))

Returns an array of languages supported by the font.

### Getting Font Metrics

[`func CTFontGetAscent(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetAscent(_:))

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

[`func CTFontGetDescent(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetDescent(_:))

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

[`func CTFontGetLeading(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetLeading(_:))

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

[`func CTFontGetUnitsPerEm(CTFont) -> UInt32`](/documentation/CoreText/CTFontGetUnitsPerEm(_:))

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

[`func CTFontGetGlyphCount(CTFont) -> CFIndex`](/documentation/CoreText/CTFontGetGlyphCount(_:))

Returns the number of glyphs of the given font.

[`func CTFontGetBoundingBox(CTFont) -> CGRect`](/documentation/CoreText/CTFontGetBoundingBox(_:))

Returns the scaled bounding box of the given font.

[`func CTFontGetUnderlinePosition(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetUnderlinePosition(_:))

Returns the scaled underline position of the given font.

[`func CTFontGetUnderlineThickness(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetUnderlineThickness(_:))

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

[`func CTFontGetSlantAngle(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetSlantAngle(_:))

Returns the slant angle of the given font.

[`func CTFontGetCapHeight(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetCapHeight(_:))

Returns the cap-height metric of the given font.

[`func CTFontGetXHeight(CTFont) -> CGFloat`](/documentation/CoreText/CTFontGetXHeight(_:))

Returns the x-height metric of the given font.

### Getting Glyph Data

[`func CTFontCreatePathForGlyph(CTFont, CGGlyph, UnsafePointer<CGAffineTransform>?) -> CGPath?`](/documentation/CoreText/CTFontCreatePathForGlyph(_:_:_:))

Creates a path for the specified glyph.

[`func CTFontGetGlyphWithName(CTFont, CFString) -> CGGlyph`](/documentation/CoreText/CTFontGetGlyphWithName(_:_:))

Returns the glyph for the specified name.

[`func CTFontGetBoundingRectsForGlyphs(CTFont, CTFontOrientation, UnsafePointer<CGGlyph>, UnsafeMutablePointer<CGRect>?, CFIndex) -> CGRect`](/documentation/CoreText/CTFontGetBoundingRectsForGlyphs(_:_:_:_:_:))

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

[`func CTFontGetAdvancesForGlyphs(CTFont, CTFontOrientation, UnsafePointer<CGGlyph>, UnsafeMutablePointer<CGSize>?, CFIndex) -> Double`](/documentation/CoreText/CTFontGetAdvancesForGlyphs(_:_:_:_:_:))

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

[`func CTFontGetOpticalBoundsForGlyphs(CTFont, UnsafePointer<CGGlyph>, UnsafeMutablePointer<CGRect>?, CFIndex, CFOptionFlags) -> CGRect`](/documentation/CoreText/CTFontGetOpticalBoundsForGlyphs(_:_:_:_:_:))

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

[`func CTFontGetVerticalTranslationsForGlyphs(CTFont, UnsafePointer<CGGlyph>, UnsafeMutablePointer<CGSize>, CFIndex)`](/documentation/CoreText/CTFontGetVerticalTranslationsForGlyphs(_:_:_:_:))

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

### Working With Font Variations

[`func CTFontCopyVariationAxes(CTFont) -> CFArray?`](/documentation/CoreText/CTFontCopyVariationAxes(_:))

Returns an array of variation axes.

[`func CTFontCopyVariation(CTFont) -> CFDictionary?`](/documentation/CoreText/CTFontCopyVariation(_:))

Returns a variation dictionary from the font reference.

### Getting Font Features

[`func CTFontCopyFeatures(CTFont) -> CFArray?`](/documentation/CoreText/CTFontCopyFeatures(_:))

Returns an array of font features.

[`func CTFontCopyFeatureSettings(CTFont) -> CFArray?`](/documentation/CoreText/CTFontCopyFeatureSettings(_:))

Returns an array of font feature-setting tuples.

### Working with Glyphs

[`func CTFontGetGlyphsForCharacters(CTFont, UnsafePointer<UniChar>, UnsafeMutablePointer<CGGlyph>, CFIndex) -> Bool`](/documentation/CoreText/CTFontGetGlyphsForCharacters(_:_:_:_:))

Performs basic character-to-glyph mapping.

[`func CTFontDrawGlyphs(CTFont, UnsafePointer<CGGlyph>, UnsafePointer<CGPoint>, Int, CGContext)`](/documentation/CoreText/CTFontDrawGlyphs(_:_:_:_:_:))

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

[`func CTFontGetLigatureCaretPositions(CTFont, CGGlyph, UnsafeMutablePointer<CGFloat>?, CFIndex) -> CFIndex`](/documentation/CoreText/CTFontGetLigatureCaretPositions(_:_:_:_:))

Returns caret positions within a glyph.

### Converting Fonts

[`func CTFontCopyGraphicsFont(CTFont, UnsafeMutablePointer<Unmanaged<CTFontDescriptor>?>?) -> CGFont`](/documentation/CoreText/CTFontCopyGraphicsFont(_:_:))

Returns a Core Graphics font reference and attributes.

[`func CTFontCreateWithGraphicsFont(CGFont, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontDescriptor?) -> CTFont`](/documentation/CoreText/CTFontCreateWithGraphicsFont(_:_:_:_:))

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

[`func CTFontGetPlatformFont(CTFont, UnsafeMutablePointer<Unmanaged<CTFontDescriptor>?>?) -> ATSFontRef`](/documentation/CoreText/CTFontGetPlatformFont(_:_:))

Returns an ATS font reference and attributes.

[`func CTFontCreateWithPlatformFont(ATSFontRef, CGFloat, UnsafePointer<CGAffineTransform>?, CTFontDescriptor?) -> CTFont?`](/documentation/CoreText/CTFontCreateWithPlatformFont(_:_:_:_:))

Creates a new font reference from an ATS font reference.

[`func CTFontCreateWithQuickdrawInstance(ConstStr255Param?, Int16, UInt8, CGFloat) -> CTFont`](/documentation/CoreText/CTFontCreateWithQuickdrawInstance(_:_:_:_:))

Returns a font reference for the given QuickDraw instance.

### Getting Font Table Data

[`func CTFontCopyAvailableTables(CTFont, CTFontTableOptions) -> CFArray?`](/documentation/CoreText/CTFontCopyAvailableTables(_:_:))

Returns an array of font table tags.

[`func CTFontCopyTable(CTFont, CTFontTableTag, CTFontTableOptions) -> CFData?`](/documentation/CoreText/CTFontCopyTable(_:_:_:))

Returns a reference to the font table data.

### Getting the Type Identifier

[`func CTFontGetTypeID() -> CFTypeID`](/documentation/CoreText/CTFontGetTypeID())

Returns the type identifier for Core Text font references.

### Global Variables

[Name Specifier Constants](/documentation/CoreText/name-specifier-constants)

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

[Font Variation Axis Dictionary Keys](/documentation/CoreText/font-variation-axis-dictionary-keys)

These constants provide keys to font variation axis dictionary values.

[Font Feature Constants](/documentation/CoreText/font-feature-constants)

These constants provide keys to font feature dictionary values.

### Enumerations

[`enum CTFontUIFontType`](/documentation/CoreText/CTFontUIFontType)

Constants that represent the specific user-interface purpose to specify for font creation.

[`typealias CTFontTableTag`](/documentation/CoreText/CTFontTableTag)

Font table tags provide access to font table data.

[`struct CTFontTableOptions`](/documentation/CoreText/CTFontTableOptions)

Constants that describe font table options.

[`struct CTFontOptions`](/documentation/CoreText/CTFontOptions)

Options for font creation and descriptor matching.

### Initializers

[`init(CTFontUIFontType, size: CGFloat)`](/documentation/CoreText/CTFont/init(_:size:)-3do9m)

[`init(CTFontDescriptor, size: CGFloat)`](/documentation/CoreText/CTFont/init(_:size:)-6lcja)

[`init(CFString, size: CGFloat)`](/documentation/CoreText/CTFont/init(_:size:)-8bj7b)

[`init(CTFontUIFontType, size: CGFloat, language: CFString?)`](/documentation/CoreText/CTFont/init(_:size:language:))

[`init(CFString, transform: CGAffineTransform)`](/documentation/CoreText/CTFont/init(_:transform:)-3sscp)

[`init(CTFontDescriptor, transform: CGAffineTransform)`](/documentation/CoreText/CTFont/init(_:transform:)-a23v)

[`init(font: CTFont, string: CFString, range: CFRange)`](/documentation/CoreText/CTFont/init(font:string:range:))

[`init(font: CTFont, string: CFString, range: CFRange, language: CFString?)`](/documentation/CoreText/CTFont/init(font:string:range:language:))

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)