NSFontDescriptor
A dictionary of attributes that describe a font.
Declaration
class NSFontDescriptorOverview
A font descriptor can be used to create or modify an NSFont object. The system provides a font matching capability, so that you can partially describe a font by creating a font descriptor with, for example, just a family name. You can then find all the available fonts on the system with a matching family name using matchingFontDescriptors(withMandatoryKeys:).
There are several ways to create a new NSFontDescriptor object. You can use alloc and init(fontAttributes:), fontDescriptorWithFontAttributes:, init(name:matrix:), or init(name:size:). to create a font descriptor based on either your custom attributes dictionary or on a specific font’s name and size. Alternatively you can use one of the fontDescriptor… instance methods (such as withFace(_:)) to create a modified version of an existing descriptor. The latter methods are useful if you have an existing descriptor and simply want to change one aspect.
All attributes in the attributes dictionary are optional.
Topics
Creating a Font Descriptor
preferredFontDescriptor(forTextStyle:options:)init(name:matrix:)init(name:size:)init(fontAttributes:)
Modifying an Existing Font Descriptor
addingAttributes(_:)withFace(_:)withFamily(_:)withMatrix(_:)withSize(_:)withSymbolicTraits(_:)withDesign(_:)NSFontDescriptor.SystemDesign
Finding Fonts
Getting the Font Attributes
fontAttributesobject(forKey:)NSFontDescriptor.AttributeNameNSFontDescriptor.SymbolicTraitsmatrixpointSizepostscriptNameNSFontDescriptor.FeatureKeyNSFontFamilyClassNSFontFamilyClassMaskTypeface InformationNSFontDescriptor.VariationKey