How does CoreText's CTFontManager deal with variable UIFont?

Suppose I make a UIFont like this:

    let variations = myCustomVariationsDictionary
    let key = kCTFontVariationAttribute as UIFontDescriptor.AttributeName
    let uiFontDescriptor = UIFontDescriptor(fontAttributes: [.name: Self.name, key: variations])
    let updatedUIFont = UIFont(descriptor: uiFontDescriptor, size: uiFont.pointSize)
    self.uiFont = updatedUIFont

—thereby creating a variable font in RAM and saving it to some object.

How do I then register that created font in the CTFontManager such that we can access it by name from SwiftUI? The variation name doesn't correspond with any font file on disk; it will be something crazy like "RobotoFlex_wght0BADF00D_YXCD8282384729" (or whatever) and will be different based the values used for each of the variation axes.

The problem I'm facing is that you have to specify the font size when you create a given variable font, or UIFont instance. Now, that font is baked in at that particular size, which might not be the appropriate optical size for the final size it might scale to as a result of DynamicType (e.g. as with an @ScaledMetric for the size). But we can't have the wrapper around the CTFont methods use @ScaledFont property wrapper, since this wrapper does nothing unless used on a conformance to View that's actively being used in an actual SwiftUI graph.

In other words, it seems like we have to dynamically recreate the font every single time we want to use it in a Text view, which causes all kinds of nasty memory leaks and unbounded growth of RAM not to mention horrible performance.

I've looked at various options available in github—there's exactly one SwiftUI wrapper around dynamic fonts, and it's very uninspiring. So here I am, asking you lot for any advice.

Really, I prolly need to file a DTS ticket, but figured I'd try here first. Thanks!

How does CoreText's CTFontManager deal with variable UIFont?
 
 
Q