<!--
{
  "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

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

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

[`init(_:)`](/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

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

Returns the full name associated with a font object.

### Examining Font Metrics

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

Returns the ascent of a font.

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

Returns the cap height of a font.

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

Returns the descent of a font.

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

Returns the bounding box of a font.

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

Returns the italic angle of a font.

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

Returns the leading of a font.

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

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

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

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

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

Returns the x-height of a font.

### Working with PostScript Fonts

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

Obtains the PostScript name of a font.

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

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

[`createPostScriptSubset(subsetName:format:glyphs:count:encoding:)`](/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.

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

Creates a PostScript encoding of a font.

### Working with Font Tables

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

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

[`table(for:)`](/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

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

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

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

Returns the variation specification dictionary for a font.

[`variationAxes`](/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

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

Returns the number of glyphs in a font.

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

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

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

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

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

Get the bounding box of each glyph in an array.

[`getGlyphAdvances(glyphs:count:advances:)`](/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

[`typeID`](/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)



---

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)