iOS Developer Library

Developer

Core Text Reference Collection Core Text Font Manager Reference

Options
Deployment Target:

On This Page
Language:

Core Text Font Manager Reference

This reference document describes the functions and constants used to manage fonts in Core Text.

Functions

  • Returns an array of font descriptors representing each of the fonts in the specified URL.

    Declaration

    Swift

    func CTFontManagerCreateFontDescriptorsFromURL(_ fileURL: CFURL) -> CFArray?

    Objective-C

    CFArrayRef CTFontManagerCreateFontDescriptorsFromURL ( CFURLRef fileURL );

    Parameters

    fileURL

    A file system URL referencing a valid font file.

    Return Value

    This function returns a retained reference to a CFArray of CTFontDescriptorRef objects, or NULL on error. The caller is responsible for releasing the array.

    Availability

    Available in iOS 7.0 and later.

  • Determines whether the referenced font data (usually by file URL) is supported on the current platform.

    Declaration

    Objective-C

    bool CTFontManagerIsSupportedFont( CFURLRef fontURL );

    Parameters

    fontURL

    A URL referring to font data.

    Return Value

    Returns true if the URL refers to a valid font that can be used on the current platform; false otherwise.

Constants

  • These constants define the scope for font registration.

    Declaration

    Swift

    enum CTFontManagerScope : UInt32 { case None case Process case User case Session }

    Objective-C

    enum { kCTFontManagerScopeNone = 0, kCTFontManagerScopeProcess = 1, kCTFontManagerScopeUser = 2, kCTFontManagerScopeSession = 3 }; typedef uint32_t CTFontManagerScope;

    Constants

    • none

      kCTFontManagerScopeNone

      No scope is defined.

      Available in iOS 4.1 and later.

    • process

      kCTFontManagerScopeProcess

      The font is available to the current process for the duration of the process unless directly unregistered.

      Available in iOS 4.1 and later.

    • user

      kCTFontManagerScopeUser

      The font is available to all processes for the current user session and will be available in subsequent sessions unless unregistered.

      Available in iOS 4.1 and later.

    • session

      kCTFontManagerScopeSession

      The font is available to the current user session but will not be available in subsequent sessions.

      Available in iOS 4.1 and later.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in iOS 4.1 and later.

  • Sets the auto-activation for the specified bundle identifier.

    Declaration

    Swift

    enum CTFontManagerAutoActivationSetting : UInt32 { case Default case Disabled case Enabled case PromptUser }

    Objective-C

    enum { kCTFontManagerAutoActivationDefault = 0, kCTFontManagerAutoActivationDisabled = 1, kCTFontManagerAutoActivationEnabled = 2, kCTFontManagerAutoActivationPromptUser = 3 }; typedef uint32_t CTFontManagerAutoActivationSetting;

    Constants

    • default

      kCTFontManagerAutoActivationDefault

      Default auto-activation setting. When specified, the application uses the global setting.

      Available in iOS 4.1 and later.

    • disabled

      kCTFontManagerAutoActivationDisabled

      Disables auto-activation.

      Available in iOS 4.1 and later.

    • enabled

      kCTFontManagerAutoActivationEnabled

      Enables auto-activation.

      Available in iOS 4.1 and later.

    • promptUser

      kCTFontManagerAutoActivationPromptUser

      Requires user input for auto-activation. A dialog is presented to the user to confirm auto-activation of the font.

      Available in iOS 4.1 and later.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in iOS 4.1 and later.

  • Notification name for font registry changes.

    Declaration

    Swift

    let kCTFontManagerRegisteredFontsChangedNotification: CFString

    Objective-C

    const CFStringRef kCTFontManagerRegisteredFontsChangedNotification

    Constants

    • kCTFontManagerRegisteredFontsChangedNotification

      kCTFontManagerRegisteredFontsChangedNotification

      This is the string to use as the notification name when subscribing to Core Text Font Manager notifications. This notification is posted when fonts are added to the font registry. The client is responsible for registered with the distributed notification center to receive notifications for changes to the session or user scopes, and with a local notification center for changes to the process scope.

      Available in iOS 7.0 and later.

  • CFError domain and user info key for Font Manager errors.

    Declaration

    Swift

    let kCTFontManagerErrorDomain: CFString let kCTFontManagerErrorFontURLsKey: CFString

    Objective-C

    const CFStringRef kCTFontManagerErrorDomain; const CFStringRef kCTFontManagerErrorFontURLsKey;

    Constants

    • kCTFontManagerErrorDomain

      kCTFontManagerErrorDomain

      CFError objects with this domain have error codes corresponding to one of the CTFontManagerError errors listed in Font Registration Errors and Font Unregistration Errors.

      Available in iOS 3.2 and later.

    • kCTFontManagerErrorFontURLsKey

      kCTFontManagerErrorFontURLsKey

      User info key to be used with CFError references returned from registration functions. The value associated with this key in the user info dictionary of a CFError object is a CFArray of font URLs that failed with the given error.

      Available in iOS 3.2 and later.

  • Errors that would prevent registration of fonts for a specified font file URL.

    Declaration

    Swift

    enum CTFontManagerError : CFIndex { case FileNotFound case InsufficientPermissions case UnrecognizedFormat case InvalidFontData case AlreadyRegistered case NotRegistered case InUse case SystemRequired }

    Objective-C

    enum { kCTFontManagerErrorFileNotFound = 101, kCTFontManagerErrorInsufficientPermissions = 102, kCTFontManagerErrorUnrecognizedFormat = 103, kCTFontManagerErrorInvalidFontData = 104, kCTFontManagerErrorAlreadyRegistered = 105, };

    Constants

    • fileNotFound

      kCTFontManagerErrorFileNotFound

      The file does not exist at the specified URL.

      Available in iOS 4.1 and later.

    • insufficientPermissions

      kCTFontManagerErrorInsufficientPermissions

      Cannot access the file due to insufficient permissions.

      Available in iOS 4.1 and later.

    • unrecognizedFormat

      kCTFontManagerErrorUnrecognizedFormat

      The file is not a recognized or supported font file format.

      Available in iOS 4.1 and later.

    • invalidFontData

      kCTFontManagerErrorInvalidFontData

      The file contains invalid font data that could cause system problems.

      Available in iOS 4.1 and later.

    • alreadyRegistered

      kCTFontManagerErrorAlreadyRegistered

      The file has already been registered in the specified scope.

      Available in iOS 4.1 and later.

  • Errors that would prevent unregistration of fonts for a specified font file URL.

    Declaration

    Swift

    enum CTFontManagerError : CFIndex { case FileNotFound case InsufficientPermissions case UnrecognizedFormat case InvalidFontData case AlreadyRegistered case NotRegistered case InUse case SystemRequired }

    Objective-C

    enum { kCTFontManagerErrorNotRegistered = 201, kCTFontManagerErrorInUse = 202, kCTFontManagerErrorSystemRequired = 202, }; typedef CFIndex CTFontManagerError;

    Constants

    • notRegistered

      kCTFontManagerErrorNotRegistered

      The file is not registered in the specified scope.

      Available in iOS 4.1 and later.

    • inUse

      kCTFontManagerErrorInUse

      The font file is actively in use and cannot be unregistered.

      Available in iOS 4.1 and later.

    • systemRequired

      kCTFontManagerErrorSystemRequired

      The file is required by the system and cannot be unregistered.

      Available in iOS 4.1 and later.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in iOS 4.1 and later.