Dynamic Type Can’t Work On Custom Fonts

Wyn
1 min readMay 19, 2020

The feature, Dynamic Type. It doesn’t work when I change the Label Font to custom font and check the box “Automatically Adjusts Font” on Attributes Inspector. It would get a warning “Automatically adjusts font requires using a dynamic type text style”. It also doesn’t support Dynamic Type on the simulator.

It could only work when I using the text style that predefined supported dynamic types.

But It could work by typing these codes in ViewController.

if let customFont = UIFont(name: “Kefa”, size: 20.0) {    let fontMatrics = UIFontMetrics(forTextStyle: .title1)    textLabel.font = fontMatrics.scaledFont(for: customFont)}textLabel.adjustsFontForContentSizeCategory = true

By the way, the label font would always automatically adjusts font when I use the list of predefined supported dynamic type text style. Whatever I uncheck the box “Automatically Adjusts Font” or use .adjustsFontForContentSizeCategory = false.

--

--