One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

Font

struct · iOS 13.0+ · SDK 27.1

@frozen struct Font

An environment-dependent font. The system resolves a font's value at the time it uses the font in a given environment because ``Font`` is a late-binding token.

Members (39)

get · iOS 13.0+

largeTitle

TypeScript
static get largeTitle(): Font
Swift declaration
static let largeTitle: Font

A font with the large title text style.

method · iOS 15.0+

monospaced

TypeScript
monospaced(): Font
Swift declaration
func monospaced() -> Font

Returns a fixed-width font from the same family as the base font. If there's no suitable font face in the same family, SwiftUI returns a default fixed-width font. The following example adds the `monospaced()` modifier to the default system font, then applies this font to a ``Text`` view: struct ContentView: View { let myFont = Font .system(size: 24) .monospaced() var body: some View { Text("Hello, world!") .font(myFont) .padding() .navigationTitle("Monospaced") } } ![A macOS window showing the text Hello, world in a 24-point fixed-width font.](Environment-Font-monospaced-1) SwiftUI may provide different fixed-width replacements for standard user interface fonts (such as ``Font/title``, or a system font created with ``Font/system(_:design:)``) than for those same fonts when created by name with ``Font/custom(_:size:)``. The ``View/font(_:)`` modifier applies the font to all text within the view. To mix fixed-width text with other styles in the same `Text` view, use the ``Text/init(_:)-1a4oh`` initializer to use an appropropriately-styled <doc://com.apple.documentation/documentation/Foundation/AttributedString> for the text view's content. You can use the <doc://com.apple.documentation/documentation/Foundation/AttributedString/init(markdown:options:baseURL:)-52n3u> initializer to provide a Markdown-formatted string containing the backtick-syntax (\`…\`) to apply code voice to specific ranges of the attributed string. - Returns: A fixed-width font from the same family as the base font, if one is available, and a default fixed-width font otherwise.

method · iOS 26.0+

monospaced

TypeScript
monospaced30059(isActive: boolean): Font
Swift declaration
func monospaced(_ isActive: Bool) -> Font

Returns a font adding or removing fixed-width design from the same family as the base font. If there's no suitable font face in the same family, SwiftUI returns a default font. The following example adds the `monospaced()` modifier to the default system font, then applies this font to a ``Text`` view: struct ContentView: View { let myFont = Font .system(size: 24) .monospaced(true) var body: some View { Text("Hello, world!") .font(myFont) .padding() .navigationTitle("Monospaced") } } ![A macOS window showing the text Hello, world in a 24-point fixed-width font.](Environment-Font-monospaced-1) SwiftUI may provide different fixed-width replacements for standard user interface fonts (such as ``Font/title``, or a system font created with ``Font/system(_:design:)``) than for those same fonts when created by name with ``Font/custom(_:size:)``. The ``View/font(_:)`` modifier applies the font to all text within the view. To mix fixed-width text with other styles in the same `Text` view, use the ``Text/init(_:)-1a4oh`` initializer to use an appropriately-styled <doc://com.apple.documentation/documentation/Foundation/AttributedString> for the text view's content. You can use the <doc://com.apple.documentation/documentation/Foundation/AttributedString/init(markdown:options:baseURL:)-52n3u> initializer to provide a Markdown-formatted string containing the backtick-syntax (\`…\`) to apply code voice to specific ranges of the attributed string. - Returns: A font with the fixed-width design added or removed, from the same family as the base font, if one is available, and a default font otherwise.

get · iOS 13.0+

subheadline

TypeScript
static get subheadline(): Font
Swift declaration
static let subheadline: Font

A font with the subheadline text style.

method · iOS 13.0+

monospacedDigit

TypeScript
monospacedDigit(): Font
Swift declaration
func monospacedDigit() -> Font

Returns a modified font that uses fixed-width digits, while leaving other characters proportionally spaced. This modifier only affects numeric characters, and leaves all other characters unchanged. If the base font doesn't support fixed-width, or _monospace_ digits, the font remains unchanged. The following example shows two text fields arranged in a ``VStack``. Both text fields specify the 12-point system font, with the second adding the `monospacedDigit()` modifier to the font. Because the text includes the digit 1, normally a narrow character in proportional fonts, the second text field becomes wider than the first. @State private var userText = "Effect of monospacing digits: 111,111." var body: some View { VStack { TextField("Proportional", text: $userText) .font(.system(size: 12)) TextField("Monospaced", text: $userText) .font(.system(size: 12).monospacedDigit()) } .padding() .navigationTitle(Text("Font + monospacedDigit()")) } ![A macOS window showing two text fields arranged vertically. Each shows the text Effect of monospacing digits: 111,111. The even spacing of the digit 1 in the second text field causes it to be noticably wider than the first.](Environment-Font-monospacedDigit-1) - Returns: A font that uses fixed-width numeric characters.

method · iOS 13.0+

lowercaseSmallCaps

TypeScript
lowercaseSmallCaps(): Font
Swift declaration
func lowercaseSmallCaps() -> Font

Adjusts the font to enable lowercase small capitals. This function turns lowercase characters into small capitals for the font. It is generally used for display lines set in large and small caps, such as titles. It may include forms related to small capitals, such as old-style figures.

method · iOS 26.0+

lowercaseSmallCaps

TypeScript
lowercaseSmallCaps1507(isActive: boolean): Font
Swift declaration
func lowercaseSmallCaps(_ isActive: Bool) -> Font

Adjusts the font to enable/disable lowercase small capitals. This function controls turning lowercase characters into small capitals for the font. It is generally used for display lines set in large and small caps, such as titles. It may include forms related to small capitals, such as old-style figures.

method · iOS 13.0+

uppercaseSmallCaps

TypeScript
uppercaseSmallCaps(): Font
Swift declaration
func uppercaseSmallCaps() -> Font

Adjusts the font to enable uppercase small capitals. This feature turns capital characters into small capitals. It is generally used for words which would otherwise be set in all caps, such as acronyms, but which are desired in small-cap form to avoid disrupting the flow of text.

method · iOS 26.0+

uppercaseSmallCaps

TypeScript
uppercaseSmallCaps98364(isActive: boolean): Font
Swift declaration
func uppercaseSmallCaps(_ isActive: Bool) -> Font

Adjusts the font to enable/disable uppercase small capitals. This feature controls turning capital characters into small capitals. It is generally used for words which would otherwise be set in all caps, such as acronyms, but which are desired in small-cap form to avoid disrupting the flow of text.

get · iOS 13.0+

body

TypeScript
static get body(): Font
Swift declaration
static let body: Font

A font with the body text style.

method · iOS 13.0+

bold

TypeScript
bold(): Font
Swift declaration
func bold() -> Font

Adds bold or emphasized styling to the font. For fonts created from text styles, it could mean applying emphasized styling, which does not necessarily mean the bold weight specifically, so this modifier is not to be confused with <doc://com.apple.documentation/documentation/SwiftUI/Font/weight(_:)>. For example: Font.body.bold() will most likely get you the emphasized version of body text style, which is often in <doc://com.apple.documentation/documentation/SwiftUI/Font/weight/semibold> weight. While Font.body.weight(.bold) will specifically get you the body text style font in the <doc://com.apple.documentation/documentation/SwiftUI/Font/weight/bold> weight.

method · iOS 26.0+

bold

TypeScript
bold91310(isActive: boolean): Font
Swift declaration
func bold(_ isActive: Bool) -> Font

Adds or removes bold or emphasized styling on the font. For fonts created from text styles, passing `true` could mean applying emphasized styling, which does not necessarily mean the bold weight specifically, so this modifier is not to be confused with <doc://com.apple.documentation/documentation/SwiftUI/Font/weight(_:)>. For example: Font.body.bold(true) will most likely get you the emphasized version of body text style, which is often in <doc://com.apple.documentation/documentation/SwiftUI/Font/weight/semibold> weight. While Font.body.weight(.bold) will specifically get you the body text style font in the <doc://com.apple.documentation/documentation/SwiftUI/Font/weight/bold> weight. Using: Font.body.bold(false) will remove any emphasized styling from the font returning to its default weight which is most likely but not guaranteed to be 0.0 or ``Weight/regular``.

get · iOS 13.0+

title

TypeScript
static get title(): Font
Swift declaration
static let title: Font

A font with the title text style.

method · iOS 16.0+

width

TypeScript
width(width: Font_Width): Font
Swift declaration
func width(_ width: Font.Width) -> Font

Sets the width of the font.

static · iOS 14.0+

custom

TypeScript
static customSizeRelativeTo(name: string, size: number, textStyle: Font_TextStyle): Font
Swift declaration
static func custom(_ name: String, size: CGFloat, relativeTo textStyle: Font.TextStyle) -> Font

Create a custom font with the given `name` and `size` that scales relative to the given `textStyle`.

static · iOS 13.0+

custom

TypeScript
static customSize(name: string, size: number): Font
Swift declaration
static func custom(_ name: String, size: CGFloat) -> Font

Create a custom font with the given `name` and `size` that scales with the body text style.

static · iOS 14.0+

custom

TypeScript
static customFixedSize(name: string, fixedSize: number): Font
Swift declaration
static func custom(_ name: String, fixedSize: CGFloat) -> Font

Create a custom font with the given `name` and a fixed `size` that does not scale with Dynamic Type.

method · iOS 13.0+

italic

TypeScript
italic(): Font
Swift declaration
func italic() -> Font

Adds italics to the font.

method · iOS 26.0+

italic

TypeScript
italic41867(isActive: boolean): Font
Swift declaration
func italic(_ isActive: Bool) -> Font

Adds/removes italics on the font.

method · iOS 26.0+

scaled

TypeScript
scaled(factor: number): Font
Swift declaration
func scaled(by factor: CGFloat) -> Font

Scales the point size of the font. Calls to scale are multiplicative, based on the size of the resolved font. For example, Font.body .scaled(by: 2) .bold() .scaled(by: 3) results in a bold body font 6x its usual size.

static · iOS 13.0+ · Deprecated in iOS 100000.0

system

TypeScript
static systemSizeWeightDesign(size: number, weight?: Font_Weight, design?: Font_Design): Font
Swift declaration
static func system(size: CGFloat, weight: Font.Weight = .regular, design: Font.Design = .default) -> Font

Specifies a system font to use, along with the style, weight, and any design parameters you want applied to the text. Use this function to create a system font by specifying the size and weight, and a type design together. The following styles the system font as 17 point, ``Font/Weight/semibold`` text: Text("Hello").font(.system(size: 17, weight: .semibold)) While the following styles the text as 17 point ``Font/Weight/bold``, and applies a `serif` ``Font/Design`` to the system font: Text("Hello").font(.system(size: 17, weight: .bold, design: .serif)) If you want to use the default ``Font/Weight`` (``Font/Weight/regular``), you don't need to specify the `weight` in the method. The following example styles the text as 17 point ``Font/Weight/regular``, and uses a ``Font/Design/rounded`` system font: Text("Hello").font(.system(size: 17, design: .rounded)) This function has been deprecated, use the one with nullable `weight` and `design` instead.

static · iOS 16.0+

system

TypeScript
static systemSizeWeightDesign6513(size: number, weight?: (Font_Weight) | null, design?: (Font_Design) | null): Font
Swift declaration
static func system(size: CGFloat, weight: Font.Weight? = nil, design: Font.Design? = nil) -> Font

Specifies a system font to use, along with the style, weight, and any design parameters you want applied to the text. Use this function to create a system font by specifying the size and weight, and a type design together. The following styles the system font as 17 point, ``Font/Weight/semibold`` text: Text("Hello").font(.system(size: 17, weight: .semibold)) While the following styles the text as 17 point ``Font/Weight/bold``, and applies a `serif` ``Font/Design`` to the system font: Text("Hello").font(.system(size: 17, weight: .bold, design: .serif)) Both `weight` and `design` can be optional. When you do not provide a `weight` or `design`, the system can pick one based on the current context, which may not be ``Font/Weight/regular`` or ``Font/Design/default`` in certain context. The following example styles the text as 17 point system font using ``Font/Design/rounded`` design, while its weight can depend on the current context: Text("Hello").font(.system(size: 17, design: .rounded))

static · iOS 16.0+

system

TypeScript
static systemDesignWeight(style: Font_TextStyle, design?: (Font_Design) | null, weight?: (Font_Weight) | null): Font
Swift declaration
static func system(_ style: Font.TextStyle, design: Font.Design? = nil, weight: Font.Weight? = nil) -> Font

Gets a system font that uses the specified style, design, and weight. Use this method to create a system font that has the specified properties. The following example creates a system font with the ``TextStyle/body`` text style, a ``Design/serif`` design, and a ``Weight/bold`` weight, and applies the font to a ``Text`` view using the ``View/font(_:)`` view modifier: Text("Hello").font(.system(.body, design: .serif, weight: .bold)) The `design` and `weight` parameters are both optional. If you omit either, the system uses a default value for that parameter. The default values are typically ``Design/default`` and ``Weight/regular``, respectively, but might vary depending on the context.

static · iOS 13.0+ · Deprecated in iOS 100000.0

system

TypeScript
static systemDesign(style: Font_TextStyle, design?: Font_Design): Font
Swift declaration
static func system(_ style: Font.TextStyle, design: Font.Design = .default) -> Font

Gets a system font with the given text style and design. This function has been deprecated, use the one with nullable `design` and `weight` instead.

get · iOS 14.0+

title2

TypeScript
static get title2(): Font
Swift declaration
static let title2: Font

Create a font for second level hierarchical headings.

get · iOS 14.0+

title3

TypeScript
static get title3(): Font
Swift declaration
static let title3: Font

Create a font for third level hierarchical headings.

method · iOS 13.0+

weight

TypeScript
weight(weight: Font_Weight): Font
Swift declaration
func weight(_ weight: Font.Weight) -> Font

Sets the weight of the font.

get · iOS 13.0+

callout

TypeScript
static get callout(): Font
Swift declaration
static let callout: Font

A font with the callout text style.

get · iOS 13.0+

caption

TypeScript
static get caption(): Font
Swift declaration
static let caption: Font

A font with the caption text style.

get · iOS 26.0+

default

TypeScript
static get default(): Font
Swift declaration
static var `default`: Font { get }

The effective SwiftUI font used in any given environment. The font specified by environment, preferring first any developer specified font, via ``EnvironmentValues/font``, then any framework specified font, and finally the default SwiftUI font.

method · iOS 14.0+

leading

TypeScript
leading(leading: Font_Leading): Font
Swift declaration
func leading(_ leading: Font.Leading) -> Font

Adjusts the line spacing of a font. You can change a font's line spacing while maintaining other characteristics of the font by applying this modifier. For example, you can decrease spacing of the ``body`` font by applying the ``Leading/tight`` value to it: let myFont = Font.body.leading(.tight) The availability of leading adjustments depends on the font. For some fonts, the modifier has no effect and returns the original font. - Parameter leading: The line spacing adjustment to apply. - Returns: A modified font that uses the specified line spacing, or the original font if it doesn't support line spacing adjustments.

method · iOS 26.0+

resolve

TypeScript
resolve(context: Font_Context): Font_Resolved
Swift declaration
func resolve(in context: Font.Context) -> Font.Resolved

Evaluates this font to a resolved font given the current context. The system resolves a font's value at the time it uses the font in a given environment's context because ``Font`` is a late-binding token. - SeeAlso: ``EnvironmentValues/fontResolutionContext``

get · iOS 14.0+

caption2

TypeScript
static get caption2(): Font
Swift declaration
static let caption2: Font

Create a font with the alternate caption text style.

get · iOS 13.0+

footnote

TypeScript
static get footnote(): Font
Swift declaration
static let footnote: Font

A font with the footnote text style.

get · iOS 13.0+

headline

TypeScript
static get headline(): Font
Swift declaration
static let headline: Font

A font with the headline text style.

method · iOS 26.0+

pointSize

TypeScript
pointSize(size: number): Font
Swift declaration
func pointSize(_ size: CGFloat) -> Font

Sets the point size of the font explicitly. Setting the point size explicitly will result in style based fonts no longer scaling with the device's preferred text size. To scale a font's size relative to its current size, see ``Font/scaled(by:)``.

method · iOS 13.0+

smallCaps

TypeScript
smallCaps(): Font
Swift declaration
func smallCaps() -> Font

Adjusts the font to enable all small capitals. See ``Font/lowercaseSmallCaps()`` and ``Font/uppercaseSmallCaps()`` for more details.

method · iOS 26.0+

smallCaps

TypeScript
smallCaps43824(isActive: boolean): Font
Swift declaration
func smallCaps(_ isActive: Bool) -> Font

Adjusts the font to enable/disable all small capitals. See ``Font/lowercaseSmallCaps()`` and ``Font/uppercaseSmallCaps()`` for more details.

init · iOS 13.0+

init

TypeScript
static init(font: _CoreText_CTFont): Font
Swift declaration
init(_ font: CTFont)

Creates a custom font from a platform font instance. Initializing ``Font`` with platform font instance (<doc://com.apple.documentation/documentation/CoreText/CTFont-q6r>) can bridge SwiftUI ``Font`` with <doc://com.apple.documentation/documentation/AppKit/NSFont> or <doc://com.apple.documentation/documentation/UIKit/UIFont>, both of which are toll-free bridged to <doc://com.apple.documentation/documentation/CoreText/CTFont-q6r>. For example: // Use native Core Text API to create desired ctFont. let ctFont = CTFontCreateUIFontForLanguage(.system, 12, nil)! // Create SwiftUI Text with the CTFont instance. let text = Text("Hello").font(Font(ctFont))

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUICore types →