Inherits from NSObject
Conforms to NSCoding
NSCopying
Declared in DTCoreTextFontDescriptor.h

Overview

This class describes the attributes of a font. It is used to represent fonts throughout the parsing and when needed is able to generated matching CTFont instances.

Properties

UIoptimizedTrait

Whether the described font is optimized for use in User Interfaces

@property (nonatomic) BOOL UIoptimizedTrait

Declared In

DTCoreTextFontDescriptor.h

boldTrait

Whether the described font has the bold trait

@property (nonatomic) BOOL boldTrait

Declared In

DTCoreTextFontDescriptor.h

condensedTrait

Whether the described font has the condensed trait

@property (nonatomic) BOOL condensedTrait

Declared In

DTCoreTextFontDescriptor.h

expandedTrait

Whether the described font has the expanded trait

@property (nonatomic) BOOL expandedTrait

Declared In

DTCoreTextFontDescriptor.h

fontFamily

The font family name of the described font

@property (nonatomic, copy) NSString *fontFamily

Declared In

DTCoreTextFontDescriptor.h

fontName

The font name of the described font

@property (nonatomic, copy) NSString *fontName

Declared In

DTCoreTextFontDescriptor.h

italicTrait

Whether the described font has the italic trait

@property (nonatomic) BOOL italicTrait

Declared In

DTCoreTextFontDescriptor.h

monospaceTrait

Whether the described font has the monospace trait

@property (nonatomic) BOOL monospaceTrait

Declared In

DTCoreTextFontDescriptor.h

pointSize

The point size of the described font

@property (nonatomic) CGFloat pointSize

Declared In

DTCoreTextFontDescriptor.h

smallCapsFeature

YES if the small caps style is enabled, NO if not

@property (nonatomic) BOOL smallCapsFeature

Declared In

DTCoreTextFontDescriptor.h

stylisticClass

The stylistic class of the receiver

@property (nonatomic) CTFontStylisticClass stylisticClass

Declared In

DTCoreTextFontDescriptor.h

symbolicTraits

The symbolic traits of the receiver

@property (nonatomic) CTFontSymbolicTraits symbolicTraits

Declared In

DTCoreTextFontDescriptor.h

verticalTrait

Whether the described font has the vertical trait

@property (nonatomic) BOOL verticalTrait

Declared In

DTCoreTextFontDescriptor.h

Class Methods

asyncPreloadFontLookupTable

A call to the method is ideally placed into your app delegate. This loads all available system fonts into a look up table to allow DTCoreText to quickly find a specific combination of font-family and italic and bold attributes. Please refer to the Programming Guide for information when you should be using this.

+ (void)asyncPreloadFontLookupTable

Discussion

Calling this does not replace entries already existing in the lookup table, for example loaded from the DTCoreTextFontOverrides.plist included in the app bundle.

Declared In

DTCoreTextFontDescriptor.h

fallbackFontFamily

Returns the font family to use if the font family in a font descriptor is invalid. The default is Times New Roman.

+ (NSString *)fallbackFontFamily

Return Value

The font family

Declared In

DTCoreTextFontDescriptor.h

fontDescriptorForCTFont:

Convenience method for creates a font descriptor from a Core Text font

+ (DTCoreTextFontDescriptor *)fontDescriptorForCTFont:(CTFontRef)ctFont

Parameters

ctFont

The Core Text font

Return Value

An initialized font descriptor

Declared In

DTCoreTextFontDescriptor.h

fontDescriptorWithFontAttributes:

Convenience method to create a font descriptor from a font attributes dictionary

+ (DTCoreTextFontDescriptor *)fontDescriptorWithFontAttributes:(NSDictionary *)attributes

Parameters

attributes

The dictionary of font attributes

Return Value

An initialized font descriptor

Declared In

DTCoreTextFontDescriptor.h

overrideFontNameforFontFamily:bold:italic:

Retrieves the gobal font name override for a given font family with bold and italic traits.

+ (NSString *)overrideFontNameforFontFamily:(NSString *)fontFamily bold:(BOOL)bold italic:(BOOL)italic

Parameters

fontFamily

The font family to retrieve the override for

bold

The bold trait

italic

The italic trait

Return Value

The font name to use for this combination of parameters

Declared In

DTCoreTextFontDescriptor.h

setFallbackFontFamily:

Sets the font family to use if the font family in a font descriptor is invalid.

+ (void)setFallbackFontFamily:(NSString *)fontFamily

Parameters

fontFamily

The font family

Discussion

The fallback font family cannot be nil and must be a valid font family. The default is Times New Roman.

Declared In

DTCoreTextFontDescriptor.h

setOverrideFontName:forFontFamily:bold:italic:

Sets the global font name override to use when encountering a font family with given bold and italic attributes.

+ (void)setOverrideFontName:(NSString *)fontName forFontFamily:(NSString *)fontFamily bold:(BOOL)bold italic:(BOOL)italic

Parameters

fontName

The font name to use

fontFamily

The font family to use this for

bold

The bold trait

italic

The italic trait

Declared In

DTCoreTextFontDescriptor.h

setSmallCapsFontName:forFontFamily:bold:italic:

Sets the global font name override to use when encountering small caps text in a font family with given bold and italic attributes.

+ (void)setSmallCapsFontName:(NSString *)fontName forFontFamily:(NSString *)fontFamily bold:(BOOL)bold italic:(BOOL)italic

Parameters

fontName

The font name to use

fontFamily

The font family to use this for

bold

The bold trait

italic

The italic trait

Declared In

DTCoreTextFontDescriptor.h

smallCapsFontNameforFontFamily:bold:italic:

Retrieves the gobal font name override to use for small caps text for a given font family with bold and italic traits.

+ (NSString *)smallCapsFontNameforFontFamily:(NSString *)fontFamily bold:(BOOL)bold italic:(BOOL)italic

Parameters

fontFamily

The font family to retrieve the override for

bold

The bold trait

italic

The italic trait

Return Value

The font name to use for this combination of parameters

Declared In

DTCoreTextFontDescriptor.h

Instance Methods

cssStyleRepresentation

The CSS style sheet representation of the receiver

- (NSString *)cssStyleRepresentation

Return Value

A CSS style string

Declared In

DTCoreTextFontDescriptor.h

fontAttributes

Retrieves a dictionary of font attributes

- (NSDictionary *)fontAttributes

Declared In

DTCoreTextFontDescriptor.h

initWithCTFont:

Creates a font descriptor from a Core Text font

- (id)initWithCTFont:(CTFontRef)ctFont

Parameters

ctFont

The Core Text font

Return Value

An initialized font descriptor

Declared In

DTCoreTextFontDescriptor.h

initWithCTFontDescriptor:

Creates a font descriptor from a Core Text font descriptor

- (id)initWithCTFontDescriptor:(CTFontDescriptorRef)ctFontDescriptor

Parameters

ctFontDescriptor

The Core Text font descriptor

Return Value

An initialized font descriptor

Declared In

DTCoreTextFontDescriptor.h

initWithFontAttributes:

Creates a font descriptor from a font attributes dictionary

- (id)initWithFontAttributes:(NSDictionary *)attributes

Parameters

attributes

The dictionary of font attributes

Return Value

An initialized font descriptor

Declared In

DTCoreTextFontDescriptor.h

newMatchingFont

Creates a CTFont matching the receiver’s attribute

- (CTFontRef)newMatchingFont

Return Value

a +1 owning reference of a Core Text font

Declared In

DTCoreTextFontDescriptor.h

setFontAttributes:

Sets the font attributes from a dictionary

- (void)setFontAttributes:(NSDictionary *)newAttributes

Parameters

newAttributes

The font attributes dictionary

Declared In

DTCoreTextFontDescriptor.h

supportsNativeSmallCaps

Determining if the font described by the receiver has native small caps support

- (BOOL)supportsNativeSmallCaps

Return Value

YES if this font supports native small caps

Declared In

DTCoreTextFontDescriptor.h