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?

Mathias
  • 3,879
  • 5
  • 36
  • 48
  • 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. – David James Jul 20 '21 at 15:09
  • 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. – Corbell Aug 23 '21 at 16:35

6 Answers6

14

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

CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.

clatt
  • 176
  • 1
  • 3
  • 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. – PDG Jan 08 '20 at 16:11
  • @PDG What exactly was the 3rd party software doing? – Kaunteya Mar 30 '20 at 16:36
  • NChart 3D was the software, just using an illegal font I assume – PDG Jul 24 '20 at 00:24
  • So, I'm not sure this will help, but worth a try ( and for future people ) https://stackoverflow.com/questions/67893273/javafx-font-not-being-rendered-correctly < this solved my issue This solution helped me. – R.J. Robinson Apr 29 '22 at 02:01
10

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)
gheclipse
  • 971
  • 8
  • 13
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

Tony Law
  • 293
  • 2
  • 13
  • 2
    Same issue here, in a macOS app. I'm starting to suspect SDK bug? – Jorge Leandro Perez Nov 06 '19 at 18:09
  • I traced mine to an older version of a pod I am using. – Tony Law Nov 06 '19 at 18:15
  • 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? – Tap Forms Nov 07 '19 at 08:31
  • 7
    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 gentlemen – Jorge Leandro Perez Nov 07 '19 at 19:12
  • 2
    @Klaas apologies about being late! YES... this is the official response I got, thru Tech Support: – Jorge Leandro Perez Dec 23 '19 at 15:15
  • 3
    `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") – Jorge Leandro Perez Dec 23 '19 at 15:16
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)
anorskdev
  • 1,867
  • 1
  • 15
  • 18
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.

Mathias
  • 3,879
  • 5
  • 36
  • 48
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

Olcay Ertaş
  • 5,987
  • 8
  • 76
  • 112
Jagveer Singh
  • 2,258
  • 19
  • 34