Mac Developer Library

Developer

ApplicationServices Framework Reference CTFontDescriptor Reference

Options
Deployment Target:

On This Page
Language:

CTFontDescriptor Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CoreText

Objective-C

@import CoreText;

The CTFontDescriptor opaque type represents a font descriptor, that is, a dictionary of attributes (such as name, point size, and variation) that can completely specify a font.

A font descriptor can be an incomplete specification, in which case the system chooses the most appropriate font to match the given attributes.

Functions

  • Creates a new font descriptor with the provided PostScript name and size.

    Declaration

    Swift

    func CTFontDescriptorCreateWithNameAndSize(_ name: CFString!, _ size: CGFloat) -> CTFontDescriptor!

    Objective-C

    CTFontDescriptorRef CTFontDescriptorCreateWithNameAndSize ( CFStringRef name, CGFloat size );

    Parameters

    name

    The PostScript name to be used for the font descriptor as a CFStringRef object.

    size

    The point size. If 0.0, the font size attribute (kCTFontSizeAttribute) is omitted from the returned font descriptor.

    Return Value

    A new font descriptor reference with the given PostScript name and point size.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Creates a new font descriptor reference from a dictionary of attributes.

    Declaration

    Swift

    func CTFontDescriptorCreateWithAttributes(_ attributes: CFDictionary!) -> CTFontDescriptor!

    Objective-C

    CTFontDescriptorRef CTFontDescriptorCreateWithAttributes ( CFDictionaryRef attributes );

    Parameters

    attributes

    A dictionary containing arbitrary attributes.

    Return Value

    A new font descriptor with the attributes specified.

    Discussion

    The provided attribute dictionary can contain arbitrary attributes that are preserved; however, unrecognized attributes are ignored on font creation and and may not be preserved over the round trip from descriptor to font   and back to descriptor.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Creates a copy of the original font descriptor with new attributes.

    Declaration

    Swift

    func CTFontDescriptorCreateCopyWithAttributes(_ original: CTFontDescriptor!, _ attributes: CFDictionary!) -> CTFontDescriptor!

    Objective-C

    CTFontDescriptorRef CTFontDescriptorCreateCopyWithAttributes ( CTFontDescriptorRef original, CFDictionaryRef attributes );

    Parameters

    original

    The original font descriptor.

    attributes

    A dictionary containing arbitrary attributes.

    Return Value

    A new copy of the original font descriptor with attributes augmented by those specified. If there are conflicts between attributes, the new attributes replace existing ones.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Creates a copy of the original font descriptor with a new variation instance.

    Declaration

    Swift

    func CTFontDescriptorCreateCopyWithVariation(_ original: CTFontDescriptor!, _ variationIdentifier: CFNumber!, _ variationValue: CGFloat) -> CTFontDescriptor!

    Objective-C

    CTFontDescriptorRef CTFontDescriptorCreateCopyWithVariation ( CTFontDescriptorRef original, CFNumberRef variationIdentifier, CGFloat variationValue );

    Parameters

    original

    The original font descriptor.

    variationIdentifier

    The variation axis identifier. This is the four-character code of the variation axis as a CFNumber object.

    variationValue

    The value corresponding with the variation instance.

    Return Value

    A copy of the original font descriptor with a new variation instance.

    Discussion

    This is a convenience method for easily creating new variation font instances.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Copies a font descriptor with new feature settings.

    Declaration

    Swift

    func CTFontDescriptorCreateCopyWithFeature(_ original: CTFontDescriptor!, _ featureTypeIdentifier: CFNumber!, _ featureSelectorIdentifier: CFNumber!) -> CTFontDescriptor!

    Objective-C

    CTFontDescriptorRef CTFontDescriptorCreateCopyWithFeature ( CTFontDescriptorRef original, CFNumberRef featureTypeIdentifier, CFNumberRef featureSelectorIdentifier );

    Parameters

    original

    The original font descriptor.

    featureTypeIdentifier

    The feature type identifier.

    featureSelectorIdentifier

    The feature selector identifier.

    Return Value

    A copy of the original font descriptor modified with the given feature settings.

    Discussion

    This is a convenience method to toggle more easily the state of individual features.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns an array of normalized font descriptors matching the provided descriptor.

    Declaration

    Swift

    func CTFontDescriptorCreateMatchingFontDescriptors(_ descriptor: CTFontDescriptor!, _ mandatoryAttributes: CFSet!) -> CFArray!

    Objective-C

    CFArrayRef CTFontDescriptorCreateMatchingFontDescriptors ( CTFontDescriptorRef descriptor, CFSetRef mandatoryAttributes );

    Parameters

    descriptor

    The font descriptor.

    mandatoryAttributes

    A set of attribute keys that must be identically matched in any returned font descriptors. May be NULL.

    Return Value

    A retained array of normalized font descriptors matching the attributes present in descriptor.

    Discussion

    If descriptor itself is normalized, then the array will contain only one item: the original descriptor. In the context of font descriptors, normalized infers that the input values were matched up with actual existing fonts, and the descriptors for those existing fonts are the returned normalized descriptors.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns the single preferred matching font descriptor based on the original descriptor and system precedence.

    Declaration

    Swift

    func CTFontDescriptorCreateMatchingFontDescriptor(_ descriptor: CTFontDescriptor!, _ mandatoryAttributes: CFSet!) -> CTFontDescriptor!

    Objective-C

    CTFontDescriptorRef CTFontDescriptorCreateMatchingFontDescriptor ( CTFontDescriptorRef descriptor, CFSetRef mandatoryAttributes );

    Parameters

    descriptor

    The original font descriptor.

    mandatoryAttributes

    A set of attribute keys which must be identically matched in any returned font descriptors. May be NULL.

    Return Value

    A retained, normalized font descriptor matching the attributes present in descriptor.

    Discussion

    The original descriptor may be returned in normalized form. The caller is responsible for releasing the result. In the context of font descriptors, normalized infers that the input values were matched up with actual existing fonts, and the descriptors for those existing fonts are the returned normalized descriptors.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns the attributes dictionary of the font descriptor.

    Declaration

    Swift

    func CTFontDescriptorCopyAttributes(_ descriptor: CTFontDescriptor!) -> CFDictionary!

    Objective-C

    CFDictionaryRef CTFontDescriptorCopyAttributes ( CTFontDescriptorRef descriptor );

    Parameters

    descriptor

    The font descriptor.

    Return Value

    The font descriptor attributes dictionary. This dictionary contains the minimum number of attributes to specify fully this particular font descriptor.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns the value associated with an arbitrary attribute.

    Declaration

    Swift

    func CTFontDescriptorCopyAttribute(_ descriptor: CTFontDescriptor!, _ attribute: CFString!) -> AnyObject!

    Objective-C

    CFTypeRef CTFontDescriptorCopyAttribute ( CTFontDescriptorRef descriptor, CFStringRef attribute );

    Parameters

    descriptor

    The font descriptor.

    attribute

    The requested attribute.

    Return Value

    A retained reference to an arbitrary attribute, or NULL if the requested attribute is not present.

    Discussion

    Refer to Font Attributes for documentation explaining how each attribute is packaged as a CFType object.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns a localized value for the requested attribute, if available.

    Declaration

    Swift

    func CTFontDescriptorCopyLocalizedAttribute(_ descriptor: CTFontDescriptor!, _ attribute: CFString!, _ language: UnsafeMutablePointer<Unmanaged<CFString>?>) -> AnyObject!

    Objective-C

    CFTypeRef CTFontDescriptorCopyLocalizedAttribute ( CTFontDescriptorRef descriptor, CFStringRef attribute, CFStringRef *language );

    Parameters

    descriptor

    The font descriptor.

    attribute

    The requested font attribute.

    language

    On output, contains a reference to the matched language. The language identifier will conform to the RFC 3066bis standard.

    Return Value

    A retained reference to a localized attribute based on the global language list.

    Discussion

    This function passes back the matched language in language. If localization is not possible for the attribute, the behavior matches the value returned from CTFontDescriptorCopyAttribute. Generally, localization of attributes is applicable to name attributes of only a normalized font descriptor.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns the type identifier for Core Text font descriptor references.

    Declaration

    Swift

    func CTFontDescriptorGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CTFontDescriptorGetTypeID ( void );

    Return Value

    The identifier for the CTFontDescriptor opaque type.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

Data Types

  • A reference to a CTFontDescriptor object.

    Declaration

    Swift

    typealias CTFontDescriptorRef = CTFontDescriptor

    Objective-C

    typedef const struct __CTFontDescriptor *CTFontDescriptorRef;

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

Constants

Font Attributes

  • These constants are keys for accessing font attributes from a font descriptor.

    Declaration

    Swift

    let kCTFontURLAttribute: CFString! let kCTFontNameAttribute: CFString! let kCTFontDisplayNameAttribute: CFString! let kCTFontFamilyNameAttribute: CFString! let kCTFontStyleNameAttribute: CFString! let kCTFontTraitsAttribute: CFString! let kCTFontVariationAttribute: CFString! let kCTFontSizeAttribute: CFString! let kCTFontMatrixAttribute: CFString! let kCTFontCascadeListAttribute: CFString! let kCTFontCharacterSetAttribute: CFString! let kCTFontLanguagesAttribute: CFString! let kCTFontBaselineAdjustAttribute: CFString! let kCTFontMacintoshEncodingsAttribute: CFString! let kCTFontFeaturesAttribute: CFString! let kCTFontFeatureSettingsAttribute: CFString! let kCTFontFixedAdvanceAttribute: CFString! let kCTFontOrientationAttribute: CFString! let kCTFontFormatAttribute: CFString! let kCTFontRegistrationScopeAttribute: CFString! let kCTFontPriorityAttribute: CFString! let kCTFontEnabledAttribute: CFString!

    Objective-C

    const CFStringRef kCTFontURLAttribute; const CFStringRef kCTFontNameAttribute; const CFStringRef kCTFontDisplayNameAttribute; const CFStringRef kCTFontFamilyNameAttribute; const CFStringRef kCTFontStyleNameAttribute; const CFStringRef kCTFontTraitsAttribute; const CFStringRef kCTFontVariationAttribute; const CFStringRef kCTFontSizeAttribute; const CFStringRef kCTFontMatrixAttribute; const CFStringRef kCTFontCascadeListAttribute; const CFStringRef kCTFontCharacterSetAttribute; const CFStringRef kCTFontLanguagesAttribute; const CFStringRef kCTFontBaselineAdjustAttribute; const CFStringRef kCTFontMacintoshEncodingsAttribute; const CFStringRef kCTFontFeaturesAttribute; const CFStringRef kCTFontFeatureSettingsAttribute; const CFStringRef kCTFontFixedAdvanceAttribute; const CFStringRef kCTFontOrientationAttribute; const CFStringRef kCTFontFormatAttribute; const CFStringRef kCTFontRegistrationScopeAttribute; const CFStringRef kCTFontPriorityAttribute; const CFStringRef kCTFontEnabledAttribute;

    Constants

    • kCTFontURLAttribute

      kCTFontURLAttribute

      Key for accessing the font URL from the font descriptor. The value associated with this key is a CFURLRef object.

      Available in OS X v10.6 and later.

    • kCTFontNameAttribute

      kCTFontNameAttribute

      Key for accessing the PostScript name from the font descriptor. The value associated with this key is a CFStringRef object. If the value is unspecified, it defaults to Helvetica, and if that font is unavailable, it falls back to the global font cascade list.

      Available in OS X v10.5 and later.

    • kCTFontDisplayNameAttribute

      kCTFontDisplayNameAttribute

      Key for accessing the name used to display the font. Most commonly this is the full name. The value associated with this key is a CFStringRef object. If the value is unspecified, it defaults to Helvetica, and if that font is unavailable, it falls back to the global font cascade list.

      Available in OS X v10.5 and later.

    • kCTFontFamilyNameAttribute

      kCTFontFamilyNameAttribute

      Key for accessing the font family name from the font descriptor. The value associated with this key is a CFStringRef object.

      Available in OS X v10.5 and later.

    • kCTFontStyleNameAttribute

      kCTFontStyleNameAttribute

      Key for accessing the style name of the font. This name represents the designer's description of the font's style. The value associated with this key is a CFStringRef object.

      Available in OS X v10.5 and later.

    • kCTFontTraitsAttribute

      kCTFontTraitsAttribute

      Key for accessing the dictionary of font traits for stylistic information. See Font Traits for the list of font traits. The value associated with this key is a CFDictionaryRef object.

      Available in OS X v10.5 and later.

    • kCTFontVariationAttribute

      kCTFontVariationAttribute

      Key to obtain the font variation dictionary instance as a CFDictionaryRef object. If specified in a font descriptor, fonts with the specified axes are primary match candidates; if no such fonts exist, this attribute is ignored.

      Available in OS X v10.5 and later.

    • kCTFontSizeAttribute

      kCTFontSizeAttribute

      Key to obtain or specify the font point size. Creating a font with this unspecified will default to a point size of 12.0. The value for this key is represented as a CFNumberRef object.

      Available in OS X v10.5 and later.

    • kCTFontMatrixAttribute

      kCTFontMatrixAttribute

      Key to specify the font transformation matrix when creating a font. If unspecified it defaults to the unit matrix. The value for this key is a CFDataRef object containing a CGAffineTransform object.

      Available in OS X v10.5 and later.

    • kCTFontCascadeListAttribute

      kCTFontCascadeListAttribute

      Key to specify or obtain the cascade list used for a font reference. The cascade list is a CFArrayRef object containing CTFontDescriptorRef elements. If unspecified, the global cascade list is used.

      Available in OS X v10.5 and later.

    • kCTFontCharacterSetAttribute

      kCTFontCharacterSetAttribute

      Key to specify or obtain the Unicode character coverage set for a font reference. The value for this key is a CFCharacterSetRef object. If specified, this attribute can be used to restrict the font to a subset of its actual character set. If unspecified, this attribute is ignored and the actual character set is used.

      Available in OS X v10.5 and later.

    • kCTFontLanguagesAttribute

      kCTFontLanguagesAttribute

      Key to specify or obtain a list of covered languages for a font reference. The value for this key is a CFArrayRef object containing CFStringRef elements. If specified, this attribute restricts the search to matching fonts that support the specified languages. The language identifier string should conform to the RFC 3066bis standard. If unspecified, this attribute is ignored.

      Available in OS X v10.5 and later.

    • kCTFontBaselineAdjustAttribute

      kCTFontBaselineAdjustAttribute

      Key to specify or obtain the baseline adjustment for a font reference. This is primarily used when defining font descriptors for a cascade list to keep the baseline of all fonts even. The value associated with this is a float represented as a CFNumberRef object.

      Available in OS X v10.5 and later.

    • kCTFontMacintoshEncodingsAttribute

      kCTFontMacintoshEncodingsAttribute

      Key to specify or obtain the Macintosh encodings for a font reference. The value associated with this key is a CFNumberRef object containing a bit field of the Macintosh encodings. This attribute is provided for legacy compatibility.

      Available in OS X v10.5 and later.

    • kCTFontFeaturesAttribute

      kCTFontFeaturesAttribute

      Key to specify or obtain the font features for a font reference. The value associated with this key is a CFArrayRef object containing font feature dictionaries. This feature list contains the feature information from the 'feat' table of the font. For more information, see CTFontCopyFeatures.

      Available in OS X v10.5 and later.

    • kCTFontFeatureSettingsAttribute

      kCTFontFeatureSettingsAttribute

      Key to specify or obtain the font features settings for a font reference. The value associated with this key is a CFArrayRef object containing font feature-setting dictionaries. A feature-setting dictionary contains a tuple of a kCTFontFeatureTypeIdentifierKey key-value pair and a kCTFontFeatureSelectorIdentifierKey key-value pair. Each setting dictionary indicates which setting should be turned on. In the case of duplicate or conflicting setting, the last setting in the list takes precedence. It is the caller's responsibility to handle exclusive and nonexclusive settings as necessary.

      Available in OS X v10.5 and later.

    • kCTFontFixedAdvanceAttribute

      kCTFontFixedAdvanceAttribute

      Key to specify a fixed advance to be used for a font reference. If present and specified, this attribute is used to specify a constant advance to override any font values. The value associated with this key is a float represented as a CFNumberRef object.

      Available in OS X v10.5 and later.

    • kCTFontOrientationAttribute

      kCTFontOrientationAttribute

      Key to specify a particular orientation for the glyphs of the font. The value associated with this key is an integer represented as a CFNumberRef object containing one of the constants in Font Orientation Constants. If you want to receive vertical metrics from a font for vertical rendering, specify kCTFontVerticalOrientation. If unspecified, the font uses its native orientation.

      Available in OS X v10.5 and later.

    • kCTFontFormatAttribute

      kCTFontFormatAttribute

      Key to specify or obtain the recognized format of the font. The value associated with this key is an integer represented as a CFNumberRef object containing one of the constants in Font Format Constants.

      Available in OS X v10.6 and later.

    • kCTFontRegistrationScopeAttribute

      kCTFontRegistrationScopeAttribute

      Key to specify or obtain the font descriptor's registration scope. The value associated with this key is an integer represented as a CFNumberRef object containing one of the CTFontManagerScope enumerated values. A value of NULL can be returned for font descriptors that are not registered.

      Available in OS X v10.6 and later.

    • kCTFontPriorityAttribute

      kCTFontPriorityAttribute

      Key to specify or obtain the font priority used by font descriptors when resolving duplicates and sorting match results. The value associated with this key is an integer represented as a CFNumberRef object containing one of the values enumerated in Font Priority Constants. The higher the value, the higher the priority of the font. Only registered fonts have a priority. Unregistered font descriptors return NULL.

      Available in OS X v10.6 and later.

    • kCTFontEnabledAttribute

      kCTFontEnabledAttribute

      Key to obtain the font enabled state. The returned value is an integer represented as a CFNumberRef object representing a Boolean value. Unregistered font descriptors return NULL, which is equivalent to false.

      Available in OS X v10.6 and later.

  • Specifies the intended rendering orientation of the font for obtaining glyph metrics. These constants are used as values of kCTFontOrientationAttribute.

    Declaration

    Swift

    enum CTFontOrientation : UInt32 { case OrientationDefault case OrientationHorizontal case OrientationVertical }

    Objective-C

    enum { kCTFontDefaultOrientation = 0, kCTFontHorizontalOrientation = 1, kCTFontVerticalOrientation = 2 }; typedef uint32_t CTFontOrientation;

    Constants

    • kCTFontDefaultOrientation

      kCTFontDefaultOrientation

      The native orientation of the font.

      Available in OS X v10.5 and later.

    • kCTFontHorizontalOrientation

      kCTFontHorizontalOrientation

      Specifies horizontal orientation.

      Available in OS X v10.5 and later.

    • kCTFontVerticalOrientation

      kCTFontVerticalOrientation

      Specifies vertical orientation.

      Available in OS X v10.5 and later.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Specifies the recognized format of the font.

    Declaration

    Swift

    enum CTFontFormat : UInt32 { case Unrecognized case OpenTypePostScript case OpenTypeTrueType case TrueType case PostScript case Bitmap }

    Objective-C

    enum { kCTFontFormatUnrecognized = 0, kCTFontFormatOpenTypePostScript = 1, kCTFontFormatOpenTypeTrueType = 2, kCTFontFormatTrueType = 3, kCTFontFormatPostScript = 4, kCTFontFormatBitmap = 5 }; typedef uint32_t CTFontFormat;

    Constants

    • Unrecognized

      kCTFontFormatUnrecognized

      The font is not a recognized format.

      Available in OS X v10.6 and later.

    • OpenTypePostScript

      kCTFontFormatOpenTypePostScript

      The font is an OpenType format containing PostScript data.

      Available in OS X v10.6 and later.

    • OpenTypeTrueType

      kCTFontFormatOpenTypeTrueType

      The font is an OpenType format containing TrueType data.

      Available in OS X v10.6 and later.

    • TrueType

      kCTFontFormatTrueType

      The font is a recognized TrueType format.

      Available in OS X v10.6 and later.

    • PostScript

      kCTFontFormatPostScript

      The font is a recognized PostScript format.

      Available in OS X v10.6 and later.

    • Bitmap

      kCTFontFormatBitmap

      The font is a bitmap-only format.

      Available in OS X v10.6 and later.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.6 and later.

  • Specifies the priority of font descriptors when resolving duplicates and sorting match results.

    Declaration

    Swift

    typealias CTFontPriority = UInt32

    Objective-C

    enum { kCTFontPrioritySystem = 10000, kCTFontPriorityNetwork = 20000, kCTFontPriorityComputer = 30000, kCTFontPriorityUser = 40000, kCTFontPriorityDynamic = 50000, kCTFontPriorityProcess = 60000 }; typedef uint32_t CTFontPriority;

    Constants

    • kCTFontPrioritySystem

      kCTFontPrioritySystem

      Priority of system fonts (located in /System/Library/Fonts).

      Available in OS X v10.6 and later.

    • kCTFontPriorityNetwork

      kCTFontPriorityNetwork

      Priority of network fonts (located in /Network/Library/Fonts).

      Available in OS X v10.6 and later.

    • kCTFontPriorityComputer

      kCTFontPriorityComputer

      Priority of computer local fonts (located in /Library/Fonts).

      Available in OS X v10.6 and later.

    • kCTFontPriorityUser

      kCTFontPriorityUser

      Priority of local fonts (located in user's Library/Fonts).

      Available in OS X v10.6 and later.

    • kCTFontPriorityDynamic

      kCTFontPriorityDynamic

      Priority of fonts registered dynamically, not located in a standard location (either kCTFontManagerScopeUser or kCTFontManagerScopeSession).

      Available in OS X v10.6 and later.

    • kCTFontPriorityProcess

      kCTFontPriorityProcess

      Priority of fonts registered for the process (kCTFontManagerScopeProcess).

      Available in OS X v10.6 and later.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.6 and later.

Font Traits

  • These constants are keys for accessing font traits from a font descriptor.

    Declaration

    Swift

    let kCTFontSymbolicTrait: CFString! let kCTFontWeightTrait: CFString! let kCTFontWidthTrait: CFString! let kCTFontSlantTrait: CFString!

    Objective-C

    const CFStringRef kCTFontSymbolicTrait; const CFStringRef kCTFontWeightTrait; const CFStringRef kCTFontWidthTrait; const CFStringRef kCTFontSlantTrait;

    Constants

    • kCTFontSymbolicTrait

      kCTFontSymbolicTrait

      Key to access the symbolic traits value from the font traits dictionary. The value is returned as a CFNumberRef object.

      Available in OS X v10.5 and later.

    • kCTFontWeightTrait

      kCTFontWeightTrait

      Key to access the normalized weight trait from the font traits dictionary. The value returned is a CFNumberRef representing a float value between -1.0 and 1.0 for normalized weight. The value of 0.0 corresponds to the regular or medium font weight.

      Available in OS X v10.5 and later.

    • kCTFontWidthTrait

      kCTFontWidthTrait

      Key to access the normalized proportion (width condense or expand) trait from the font traits dictionary. This value corresponds to the relative interglyph spacing for a given font. The value returned is a CFNumberRef object representing a float between -1.0 and 1.0. The value of 0.0 corresponds to regular glyph spacing, and negative values represent condensed glyph spacing.

      Available in OS X v10.5 and later.

    • kCTFontSlantTrait

      kCTFontSlantTrait

      Key to access the normalized slant angle from the font traits dictionary. The value returned is a CFNumberRef object representing a float value between -1.0 and 1.0 for normalized slant angle. The value of 0.0 corresponds to 0 degrees clockwise rotation from the vertical and 1.0 corresponds to 30 degrees clockwise rotation.

      Available in OS X v10.5 and later.

  • These constants represent the font class mask shift.

    Declaration

    Objective-C

    enum { kCTFontClassMaskShift = 28};

    Constants

    • kCTFontClassMaskShift

      kCTFontClassMaskShift

      Value used to shift the font class to the uppermost four bits of the symbolic traits

  • These constants represent the symbolic representation of stylistic font attributes.

    Declaration

    Swift

    struct CTFontSymbolicTraits : RawOptionSetType { init(_ rawValue: UInt32) init(rawValue rawValue: UInt32) static var TraitItalic: CTFontSymbolicTraits { get } static var TraitBold: CTFontSymbolicTraits { get } static var TraitExpanded: CTFontSymbolicTraits { get } static var TraitCondensed: CTFontSymbolicTraits { get } static var TraitMonoSpace: CTFontSymbolicTraits { get } static var TraitVertical: CTFontSymbolicTraits { get } static var TraitUIOptimized: CTFontSymbolicTraits { get } static var TraitColorGlyphs: CTFontSymbolicTraits { get } static var TraitComposite: CTFontSymbolicTraits { get } static var TraitClassMask: CTFontSymbolicTraits { get } static var ItalicTrait: CTFontSymbolicTraits { get } static var BoldTrait: CTFontSymbolicTraits { get } static var ExpandedTrait: CTFontSymbolicTraits { get } static var CondensedTrait: CTFontSymbolicTraits { get } static var MonoSpaceTrait: CTFontSymbolicTraits { get } static var VerticalTrait: CTFontSymbolicTraits { get } static var UIOptimizedTrait: CTFontSymbolicTraits { get } static var ColorGlyphsTrait: CTFontSymbolicTraits { get } static var CompositeTrait: CTFontSymbolicTraits { get } static var ClassMaskTrait: CTFontSymbolicTraits { get } }

    Objective-C

    enum { kCTFontItalicTrait = (1 << 0), kCTFontBoldTrait = (1 << 1), kCTFontExpandedTrait = (1 << 5), kCTFontCondensedTrait = (1 << 6), kCTFontMonoSpaceTrait = (1 << 10), kCTFontVerticalTrait = (1 << 11), kCTFontUIOptimizedTrait = (1 << 12), kCTFontClassMaskTrait = (15 << kCTFontClassMaskShift ) }; typedef uint32_t CTFontSymbolicTraits;

    Constants

    • ItalicTrait

      kCTFontItalicTrait

      The font typestyle is italic. Additional detail is available via kCTFontSlantTrait.

      Available in OS X v10.5 and later.

    • BoldTrait

      kCTFontBoldTrait

      The font typestyle is boldface. Additional detail is available via kCTFontWeightTrait.

      Available in OS X v10.5 and later.

    • ExpandedTrait

      kCTFontExpandedTrait

      The font typestyle is expanded. Expanded and condensed traits are mutually exclusive.

      Available in OS X v10.5 and later.

    • CondensedTrait

      kCTFontCondensedTrait

      The font typestyle is condensed. Expanded and condensed traits are mutually exclusive. Additional detail is available via kCTFontWidthTrait.

      Available in OS X v10.5 and later.

    • MonoSpaceTrait

      kCTFontMonoSpaceTrait

      The font uses fixed-pitch glyphs if available. The font may have multiple glyph advances (many CJK glyphs contain two spaces).

      Available in OS X v10.5 and later.

    • VerticalTrait

      kCTFontVerticalTrait

      The font uses vertical glyph variants and metrics.

      Available in OS X v10.5 and later.

    • UIOptimizedTrait

      kCTFontUIOptimizedTrait

      The font synthesizes appropriate attributes for user interface rendering, such as control titles, if necessary.

      Available in OS X v10.5 and later.

    • ClassMaskTrait

      kCTFontClassMaskTrait

      Mask for the font class.

      Available in OS X v10.5 and later.

    Discussion

    CTFontSymbolicTraits symbolically describes stylistic aspects of a font. The upper 16 bits are used to describe appearance of the font, whereas the lower 16 bits are for typeface information. The font appearance information represented by the upper 16 bits can be used for stylistic font matching.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • These constants represent the stylistic class values of the font.

    Declaration

    Swift

    struct CTFontStylisticClass : RawOptionSetType { init(_ rawValue: UInt32) init(rawValue rawValue: UInt32) static var ClassUnknown: CTFontStylisticClass { get } static var ClassOldStyleSerifs: CTFontStylisticClass { get } static var ClassTransitionalSerifs: CTFontStylisticClass { get } static var ClassModernSerifs: CTFontStylisticClass { get } static var ClassClarendonSerifs: CTFontStylisticClass { get } static var ClassSlabSerifs: CTFontStylisticClass { get } static var ClassFreeformSerifs: CTFontStylisticClass { get } static var ClassSansSerif: CTFontStylisticClass { get } static var ClassOrnamentals: CTFontStylisticClass { get } static var ClassScripts: CTFontStylisticClass { get } static var ClassSymbolic: CTFontStylisticClass { get } static var UnknownClass: CTFontStylisticClass { get } static var OldStyleSerifsClass: CTFontStylisticClass { get } static var TransitionalSerifsClass: CTFontStylisticClass { get } static var ModernSerifsClass: CTFontStylisticClass { get } static var ClarendonSerifsClass: CTFontStylisticClass { get } static var SlabSerifsClass: CTFontStylisticClass { get } static var FreeformSerifsClass: CTFontStylisticClass { get } static var SansSerifClass: CTFontStylisticClass { get } static var OrnamentalsClass: CTFontStylisticClass { get } static var ScriptsClass: CTFontStylisticClass { get } static var SymbolicClass: CTFontStylisticClass { get } }

    Objective-C

    enum { kCTFontUnknownClass = (0 << kCTFontClassMaskShift ), kCTFontOldStyleSerifsClass = (1 << kCTFontClassMaskShift ), kCTFontTransitionalSerifsClass = (2 << kCTFontClassMaskShift ), kCTFontModernSerifsClass = (3 << kCTFontClassMaskShift ), kCTFontClarendonSerifsClass = (4 << kCTFontClassMaskShift ), kCTFontSlabSerifsClass = (5 << kCTFontClassMaskShift ), kCTFontFreeformSerifsClass = (7 << kCTFontClassMaskShift ), kCTFontSansSerifClass = (8 << kCTFontClassMaskShift ), kCTFontOrnamentalsClass = (9 << kCTFontClassMaskShift ), kCTFontScriptsClass = (10 << kCTFontClassMaskShift ), kCTFontSymbolicClass = (12 << kCTFontClassMaskShift ) }; typedef uint32_t CTFontStylisticClass;

    Constants

    • UnknownClass

      kCTFontUnknownClass

      The font has no design classification.

      Available in OS X v10.5 and later.

    • OldStyleSerifsClass

      kCTFontOldStyleSerifsClass

      The font’s style is based on the Latin printing style of the 15th to 17th century.

      Available in OS X v10.5 and later.

    • TransitionalSerifsClass

      kCTFontTransitionalSerifsClass

      The font’s style is based on the Latin printing style of the 18th to 19th century.

      Available in OS X v10.5 and later.

    • ModernSerifsClass

      kCTFontModernSerifsClass

      The font’s style is based on the Latin printing style of the 20th century.

      Available in OS X v10.5 and later.

    • ClarendonSerifsClass

      kCTFontClarendonSerifsClass

      The font’s style is a variation of the Oldstyle Serifs and the Transitional Serifs.

      Available in OS X v10.5 and later.

    • SlabSerifsClass

      kCTFontSlabSerifsClass

      The font’s style is characterized by serifs with a square transition between the strokes and the serifs (no brackets).

      Available in OS X v10.5 and later.

    • FreeformSerifsClass

      kCTFontFreeformSerifsClass

      The font’s style includes serifs, but it expresses a design freedom that does not generally fit within the other serif design classifications.

      Available in OS X v10.5 and later.

    • SansSerifClass

      kCTFontSansSerifClass

      The font’s style includes most basic letter forms (excluding Scripts and Ornamentals) that do not have serifs on the strokes.

      Available in OS X v10.5 and later.

    • OrnamentalsClass

      kCTFontOrnamentalsClass

      The font’s style includes highly decorated or stylized character shapes such as those typically used in headlines.

      Available in OS X v10.5 and later.

    • ScriptsClass

      kCTFontScriptsClass

      The font’s style is among those typefaces designed to simulate handwriting.

      Available in OS X v10.5 and later.

    • SymbolicClass

      kCTFontSymbolicClass

      The font’s style is generally design independent, making it suitable for special characters (icons, dingbats, technical symbols, and so on) that may be used equally well with any font.

      Available in OS X v10.5 and later.

    Discussion

    CTFontStylisticClass classifies certain stylistic qualities of the font. These values correspond closely to the font class values in the OpenType OS/2 table. The class values are bundled in the upper four bits of the “Font Symbolic Traits Constants” and can be obtained via kCTFontClassMaskTrait.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.