<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIFontMetrics",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIFontMetrics"
  },
  "title" : "UIFontMetrics"
}
-->

# UIFontMetrics

A utility object for obtaining custom fonts that scale to support Dynamic Type.

```
class UIFontMetrics
```

## Overview

Use a [`UIFontMetrics`](/documentation/UIKit/UIFontMetrics) object to support scalable custom fonts in your app. You create a font metrics object that specifies the font style—for example, body or title—that you want to use in your app. You then pass your custom font to the [`scaledFont(for:)`](/documentation/UIKit/UIFontMetrics/scaledFont(for:)) method (or one of the other methods of this class) to obtain a font object that is based on your custom font, has the appropriate style information, and automatically scales to match the current Dynamic Type settings.

## Topics

### Creating a Font Metrics Object

[`-  initForTextStyle:`](/documentation/UIKit/UIFontMetrics/init(forTextStyle:))

Creates a font metrics object for the specified text style.

[`+  metricsForTextStyle:`](/documentation/UIKit/UIFontMetrics/metricsForTextStyle:)

Creates and returns a font metrics object for the specified text style.

[`defaultMetrics`](/documentation/UIKit/UIFontMetrics/default)

The default font metrics object for content.

[`TextStyle`](/documentation/UIKit/UIFont/TextStyle)

Constants that describe the preferred styles for fonts.

### Creating Scaled Fonts

[Scaling fonts automatically](/documentation/UIKit/scaling-fonts-automatically)

Scale text in your interface automatically using Dynamic Type.

[`-  scaledFontForFont:`](/documentation/UIKit/UIFontMetrics/scaledFont(for:))

Returns a version of the specified font that adopts the current font metrics.

[`-  scaledFontForFont:compatibleWithTraitCollection:`](/documentation/UIKit/UIFontMetrics/scaledFont(for:compatibleWith:))

Returns a version of the specified font that adopts the current font metrics and supports the specified traits.

[`-  scaledFontForFont:maximumPointSize:`](/documentation/UIKit/UIFontMetrics/scaledFont(for:maximumPointSize:))

Returns a version of the specified font that adopts the current font metrics and is constrained to the specified maximum size.

[`-  scaledFontForFont:maximumPointSize:compatibleWithTraitCollection:`](/documentation/UIKit/UIFontMetrics/scaledFont(for:maximumPointSize:compatibleWith:))

Returns a version of the specified font that adopts the current font metrics and is constrained to the specified traits and size.

### Scaling Layout Values

[`-  scaledValueForValue:`](/documentation/UIKit/UIFontMetrics/scaledValue(for:))

Scales an arbitrary layout value based on the current Dynamic Type settings.

[`-  scaledValueForValue:compatibleWithTraitCollection:`](/documentation/UIKit/UIFontMetrics/scaledValue(for:compatibleWith:))

Scales an arbitrary layout value based on the current Dynamic Type settings and the specified traits.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)