If I have my own group of UIFonts with different sizes and weights, for example:
let customFont03 = UIFont.systemFont(ofSize: 40, weight: .thin)
How can I support Dynamic Type while still preserving my custom size and weight as a default standard and scaling that depending on how the user selects accessibility sizes?
I'm not sure that preferredFont(forTextStyle:) is what I want because it only accepts a UIFont.TextStyle and I don't want to lock customFont03 in as a .body or .headline etc...
UIFontMetricsis the class designed to solve this problem. In particular-[UIFontMetrics scaledFontForFont:]will do what you ask, but be sure to check out the other members of that class, which can do things like cap the font increase at some maximum (at the very largest content size categories a size 40 font would be scaled to a very large size indeed).https://developer.apple.com/documentation/uikit/uifontmetrics/2877385-scaledfontforfont