How can i find the source of this font-related coretext warning in IOS13?
Asked Answered
O

6

30

Working on an update of my app i notice that i get tons of warnings in the log when running the app in Xcode 11.2 on IOS13.

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:].

I dug around a bit and found this quote from WWDC:

As mentioned in numerous WWDC sessions, dot-prefixed font names are not to be directly used.

I am myself almost exclusively using IB and nibs to set fonts for textfields etc., and there is no reference to "SFUI-Regular" in my code anywhere, so i am not sure how to find the actual reason for these warnings (i have something like 20-30 rows of these in the logs).

Does anyone have any tips on how i can find where the warning comes from, and how to fix it?

Oligoclase answered 5/11, 2019 at 7:39 Comment(2)
I get this when using Reveal app (v24). Open my app in simulator, go to Reveal, refresh, log gets filled with warnings. This started for me with Xcode 13 beta 3.Kiley
Just adding another note that I see this in my Mac OS app and I think it must be considered an OS/SDK bug. My app retrieves a list of font names with NSFontManager availableFonts. The results are used to instantiate NSFont instances with [NSFont fontWithName:]. This previously worked fine, but now this error is logged for all of the font names that the system itself returns which begin with a period. Clearly the OS should not reject font names it provides, or should not return those font names as available.Gilles
Y
14

There is another output in console, you can try to add a symbolic breakpoint

CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.

Yoga answered 5/11, 2019 at 9:37 Comment(4)
Yes, set this symbolic breakpoint. When it breaks, check out your call stack. You will then see what the culprit is. For me, 3rd party software.Overdose
@Overdose What exactly was the 3rd party software doing?Michael
NChart 3D was the software, just using an illegal font I assumeOverdose
So, I'm not sure this will help, but worth a try ( and for future people ) #67893773 < this solved my issue This solution helped me.Jackass
S
11

I started experiencing this warning in the console starting with Xcode 11, with both MacOS and iOS targets.

You will receive ".SFUI-Regular" from UIFont.systemFont(ofSize: X).fontName. The warning will then occur if you try to instantiate using UIFont(name: fontName, size: size).

In my case I am letting the user customize the display font, but the default was ".SFUI-Regular", so I have changed that to "TimesNewRomanPSMT"

let defaultFont = UIFont.systemFont(ofSize: X).fontName

// replace with
let defaultFont = "TimesNewRomanPSMT"

UIFont(name: defaultFont, size: size)
Superhighway answered 19/11, 2019 at 15:39 Comment(0)
T
2

Having the same issue and no reference to dot-prefixed font in my code either. Set a symbolic breakpoint but nothing of any use

Traverse answered 6/11, 2019 at 11:29 Comment(6)
Same issue here, in a macOS app. I'm starting to suspect SDK bug?Cosec
I traced mine to an older version of a pod I am using.Traverse
I see this issue too. But it's caused by me unarchiving an NSMutableString that has font references in it. Shouldn't that be ok?Annmarieannnora
For the record, I've reproduced this issue in an empty macOS project, no external dependencies, and just 2 lines of code. Tech Support ticket submitted, will keep you posted, ladies and gentlemenCosec
@Klaas apologies about being late! YES... this is the official response I got, thru Tech Support:Cosec
Regarding the error mesage shown in your video, I view it as a system bug because I don’t see any of your code requesting “.AppleColorEmojiUI” – If your real app indeed does that, you should follow the message to correct it. Other than that, I don’t have anything worth to mentioning. (And they didn't add anything further.... "system bug")Cosec
B
1

I got this if I blindly used:

UIFont(name: fontName, size: fontSize)

and the fontName was "System Font", which was part of a list I got from:

let fontFamilyNames = UIFont.familyNames.sorted()

Workaround was to check the name.

let isSystemFont = fontName == "System Font"
let useFont = isSystemFont ? UIFont.systemFont(ofSize: fontSize) : UIFont(name: fontName, size: fontSize) ?? UIFont.systemFont(ofSize: fontSize)
Butyl answered 11/1, 2022 at 1:5 Comment(0)
O
0

For me, it turns out it was a third-party library that has not been updated in a while that was the culprit.

I put a breakpoint as the user clatt suggested and found the source. In my case it was TOMSMorphingLabel.

Oligoclase answered 8/11, 2019 at 8:31 Comment(0)
O
0
let fontCT = CTFontCreateUIFontForLanguage(.label, fontSize as CGFloat, nil)
attrStr.addAttribute(.font, value: fontCT as Any, range: NSMakeRange(0, text.count))

solution for uifont issue for ios 13

Outside answered 9/12, 2019 at 13:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.