Fonts in generateText

It seems MeshResource.generateText() has been broken since RealityKit was released. Whenever creating a mesh using this an error appears in the logs like this:

Code Block
2020-02-29 14:30:40.994123+0000 appName[13892:4226658] CoreText note: Client requested name ".SFUI-Regular", it will get TimesNewRomanPSMT rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[UIFont systemFontOfSize:].
2020-02-29 14:30:40.994176+0000 appName[13892:4226658] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.


And the result is, as stated, that it just uses Times New Roman for all generated text (yuck!).
I created a FB item back in Feb this year (2020): FB7606700, but no update yet.

Are there any engineers who can comment on this?

Accepted Reply

I was able to use other normal fonts from the list of apple standard fonts. Helvetica I think. I think it is just the standard user interface fonts that do not work.

Code Block
let fontName = "Helvetica"
let meshResource = MeshResource.generateText(
        message,
        extrusionDepth: 0.001,
        font: .init(descriptor: .init(name: fontName, size: size), size: size),
        containerFrame: .init(x: -width/2, y: -height/2, width: width, height: height),
        alignment: .center,
        lineBreakMode: .byWordWrapping)

Replies

I was able to use other normal fonts from the list of apple standard fonts. Helvetica I think. I think it is just the standard user interface fonts that do not work.

Code Block
let fontName = "Helvetica"
let meshResource = MeshResource.generateText(
        message,
        extrusionDepth: 0.001,
        font: .init(descriptor: .init(name: fontName, size: size), size: size),
        containerFrame: .init(x: -width/2, y: -height/2, width: width, height: height),
        alignment: .center,
        lineBreakMode: .byWordWrapping)

Thanks @BillyBag2, that worked for me.
Thanks @BillyBag2, that works for me too!

I'll leave the FB request open, as passing in an otherwise valid font (even .systemFont) is broken, but this solves most of my issues 🙌