Running on MacOS Catalina, when doing static builds of `libjavafx_font.a` and 
linking against this in a JavaFX app compiled with GraalVM native-image, if 
default fonts are used, the rendered text is garbled, and a warning message is 

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:]. 
CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug. 

On Mac OS, when a map with all the regular fonts is created, we also add two 
system fonts: [System 
 and [System 
 These will be the default fonts to be used if the project doesn't specify a 

On runtime, when a font is 
 `CTFontCreateWithName` is 
 which according to Apple guidelines should be used only for the regular fonts 
(those that are not system fonts). In fact the above warning doesn't happen 
when creating any of those fonts.

Following the warning message, one of the options to create system fonts is to 
use `CTFontCreateUIFontForLanguage`, which according to the documentation in 
> Returns the special UI font for the given language and UI type.

and matches what we already do in `MacFontFinder` to create such fonts. (The 
other option will require the use of UIKit.)

This PR modifies `CTFontCreateWithName` in `coretext.c` to detect if the font 
is a system font in the first place, else use the same existing mechanism.

As an aside, the constants `kCTFontSystemFontType` and 
`kCTFontEmphasizedSystemFontType` are deprecated, and this PR uses now the new 
ones, but in both cases their int value is the same (2 and 3, in that order). 
As a follow-up PR, we could replace these deprecated constants.


 - 693dfa78: Use CTFontCreateUIFontForLanguage for system fonts

  Stats: 9 lines in 1 file changed: 8 ins; 0 del; 1 mod
  Fetch: git fetch pull/55/head:pull/55


Reply via email to