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

# CGFont

A set of character glyphs and layout information for drawing text.

```
class CGFont
```

## Overview

A glyph can represent a single character (such as ‘b’), more than one character (such as the “ﬁ” ligature), or a special character such as a space. Core Graphics retrieves the glyphs for the font from ATS (Apple Type Services) and paints the glyphs based on the relevant parameters of the current graphics state.

Core Graphics provides a limited, low-level interface for drawing text. For information on text-drawing functions, see [`CGContext`](/documentation/CoreGraphics/CGContext). For full Unicode and text-layout support,  use the services provided by TextKit).

## Topics

### Creating Font Objects

[`CGFontCreateWithDataProvider`](/documentation/CoreGraphics/CGFont/init(_:)-9aour)

Creates a font object from data supplied from a data provider.

[`CGFontCreateWithFontName`](/documentation/CoreGraphics/CGFont/init(_:)-1p4b)

Creates a font object corresponding to the font specified by a PostScript or full name.

[`CGFontCreateWithPlatformFont`](/documentation/CoreGraphics/CGFontCreateWithPlatformFont)

Creates a font object from an Apple Type Services (ATS) font.

### Retaining and Releasing a CGFont Object

[`CGFontRelease`](/documentation/CoreGraphics/CGFontRelease)

Decrements the retain count of a font.

[`CGFontRetain`](/documentation/CoreGraphics/CGFontRetain)

Increments the retain count of a font.

### Examining Font Metadata

[`CGFontCopyFullName`](/documentation/CoreGraphics/CGFont/fullName)

Returns the full name associated with a font object.

### Examining Font Metrics

[`CGFontGetAscent`](/documentation/CoreGraphics/CGFont/ascent)

Returns the ascent of a font.

[`CGFontGetCapHeight`](/documentation/CoreGraphics/CGFont/capHeight)

Returns the cap height of a font.

[`CGFontGetDescent`](/documentation/CoreGraphics/CGFont/descent)

Returns the descent of a font.

[`CGFontGetFontBBox`](/documentation/CoreGraphics/CGFont/fontBBox)

Returns the bounding box of a font.

[`CGFontGetItalicAngle`](/documentation/CoreGraphics/CGFont/italicAngle)

Returns the italic angle of a font.

[`CGFontGetLeading`](/documentation/CoreGraphics/CGFont/leading)

Returns the leading of a font.

[`CGFontGetStemV`](/documentation/CoreGraphics/CGFont/stemV)

Returns the thickness of the dominant vertical stems of glyphs in a font.

[`CGFontGetUnitsPerEm`](/documentation/CoreGraphics/CGFont/unitsPerEm)

Returns the number of glyph space units per em for the provided font.

[`CGFontGetXHeight`](/documentation/CoreGraphics/CGFont/xHeight)

Returns the x-height of a font.

### Working with PostScript Fonts

[`CGFontCopyPostScriptName`](/documentation/CoreGraphics/CGFont/postScriptName)

Obtains the PostScript name of a font.

[`CGFontCanCreatePostScriptSubset`](/documentation/CoreGraphics/CGFont/canCreatePostScriptSubset(_:))

Determines whether Core Graphics can create a subset of the font in PostScript format.

[`CGFontCreatePostScriptSubset`](/documentation/CoreGraphics/CGFont/createPostScriptSubset(subsetName:format:glyphs:count:encoding:))

Creates a subset of the font in the specified PostScript format.

[`CGFontPostScriptFormat`](/documentation/CoreGraphics/CGFontPostScriptFormat)

Possible formats for a PostScript font subset.

[`CGFontCreatePostScriptEncoding`](/documentation/CoreGraphics/CGFont/createPostScriptEncoding(encoding:))

Creates a PostScript encoding of a font.

### Working with Font Tables

[`CGFontCopyTableTags`](/documentation/CoreGraphics/CGFont/tableTags)

Returns an array of tags that correspond to the font tables for a font.

[`CGFontCopyTableForTag`](/documentation/CoreGraphics/CGFont/table(for:))

Returns the font table that corresponds to the provided tag.

[Font Table Index Values](/documentation/CoreGraphics/font-table-index-values)

Possible values for an index into a font table.

[Obsolete Font Table Index Values](/documentation/CoreGraphics/obsolete-font-table-index-values)

Deprecated values for an index into a font table.

### Working with Variations

[`CGFontCreateCopyWithVariations`](/documentation/CoreGraphics/CGFont/copy(withVariations:))

Creates a copy of a font using a variation specification dictionary.

[`CGFontCopyVariations`](/documentation/CoreGraphics/CGFont/variations)

Returns the variation specification dictionary for a font.

[`CGFontCopyVariationAxes`](/documentation/CoreGraphics/CGFont/variationAxes)

Returns an array of the variation axis dictionaries for a font.

[Font Variation Axis Keys](/documentation/CoreGraphics/font-variation-axis-keys)

Keys used for a font variation axis dictionary.

### Working with Glyphs

[`CGFontGetNumberOfGlyphs`](/documentation/CoreGraphics/CGFont/numberOfGlyphs)

Returns the number of glyphs in a font.

[`CGFontCopyGlyphNameForGlyph`](/documentation/CoreGraphics/CGFont/name(for:))

Returns the glyph name of the specified glyph in the specified font.

[`CGFontGetGlyphWithGlyphName`](/documentation/CoreGraphics/CGFont/getGlyphWithGlyphName(name:))

Returns the glyph for the glyph name associated with the specified font object.

[`CGFontGetGlyphBBoxes`](/documentation/CoreGraphics/CGFont/getGlyphBBoxes(glyphs:count:bboxes:))

Get the bounding box of each glyph in an array.

[`CGFontGetGlyphAdvances`](/documentation/CoreGraphics/CGFont/getGlyphAdvances(glyphs:count:advances:))

Gets the advance width of each glyph in the provided array.

[`CGGlyph`](/documentation/CoreGraphics/CGGlyph)

An index into the internal glyph table of a font.

[`kCGGlyphMax`](/documentation/CoreGraphics/kCGGlyphMax)

The maximum allowed value of a [`CGGlyph`](/documentation/CoreGraphics/CGGlyph).

[`CGFontIndex`](/documentation/CoreGraphics/CGFontIndex)

An index into a font table.

[`kCGFontIndexMax`](/documentation/CoreGraphics/kCGFontIndexMax)

The maximum allowed value of a [`CGFontIndex`](/documentation/CoreGraphics/CGFontIndex).

[`kCGFontIndexInvalid`](/documentation/CoreGraphics/kCGFontIndexInvalid)

An invalid font index (a value which never represents a valid glyph).

### Working with Core Foundation Types

[`CGFontGetTypeID`](/documentation/CoreGraphics/CGFont/typeID)

Returns the Core Foundation type identifier for Core Graphics fonts.

## See Also

  [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066)

## Relationships

### Conforms To

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

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

---

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)