<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGFont/init(_:)-1p4b",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGFontCreateWithFontName"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

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

```
init?(_ name: CFString)
```

## Parameters

`name`

The PostScript or full name of a font.

## Return Value

The font object or `NULL` if the font can’t be created. In Objective-C, you’re responsible for releasing this object using [`CGFontRelease`](/documentation/CoreGraphics/CGFontRelease).

## Discussion

Before drawing text in a Core Graphics context, you must set the font in the current graphics state by calling the function [`setFont(_:)`](/documentation/CoreGraphics/CGContext/setFont(_:)).

---

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)