NSFont
The representation of a font in an app.
Declaration
class NSFontOverview
NSFont objects represent fonts to an app, providing access to characteristics of the font and assistance in laying out glyphs relative to one another. Font objects are also used to establish the current font for drawing text directly into a graphics context, using the set() method.
You don’t create NSFont objects using the alloc and init methods. Instead, you use either init(descriptor:size:) or init(name:size:) to look up an available font and alter its size or matrix to your needs. These methods check for an existing font object with the specified characteristics, returning it if there is one. Otherwise, they look up the font data requested and create the appropriate object. NSFont also defines a number of methods for getting standard system fonts, such as systemFont(ofSize:), userFont(ofSize:), and messageFont(ofSize:). To request the default size for these standard fonts, pass a negative number or 0 as the font size. For more information on system fonts, see Human Interface Guidelines > Typography.
Topics
Creating Arbitrary Fonts
Creating User Fonts
Creating System Fonts
preferredFont(forTextStyle:options:)systemFont(ofSize:)systemFont(ofSize:weight:)boldSystemFont(ofSize:)monospacedSystemFont(ofSize:weight:)monospacedDigitSystemFont(ofSize:weight:)systemFontSizesmallSystemFontSizeNSFont.WeightNSFont.TextStyleNSFont.TextStyleOptionKey
Creating UI Element Fonts
labelFont(ofSize:)messageFont(ofSize:)menuBarFont(ofSize:)menuFont(ofSize:)controlContentFont(ofSize:)titleBarFont(ofSize:)paletteFont(ofSize:)toolTipsFont(ofSize:)labelFontSizesystemFontSize(for:)
Using a Font to Draw
Getting Font Metrics and Information
pointSizecoveredCharacterSetfontDescriptorisFixedPitchmostCompatibleStringEncodingAdvanced Font Metrics
Getting Information About Glyphs
Getting Font Names
Setting User Fonts
Vertical Fonts
Responding to Font-Related Notifications
Deprecated
Type Aliases
Instance Properties
Instance Methods
advancement(forGlyph:)boundingRect(forGlyph:)getAdvancements(_:forGlyphs:count:)getAdvancements(_:forPackedGlyphs:length:)getBoundingRects(_:forGlyphs:count:)glyph(withName:)screenFont(with:)withSize(_:)