[OpenJDK 2D-Dev] RFR: 8244621: [macos10.15] Garbled FX printing plus CoreText warnings on Catalina when building with Xcode 11
Prasanta Sadhukhan
prasanta.sadhukhan at oracle.com
Mon Jun 1 12:21:27 UTC 2020
Hi Phil,
I was reading somewhere that the warning is caused by JDK-8234916. Will
we still get the problem if we remove 8234916?
Regards
Prasanta
On 22-May-20 2:26 AM, Philip Race wrote:
> Bug: https://bugs.openjdk.java.net/browse/JDK-8244621
> Webrev : http://cr.openjdk.java.net/~prr/8244621/
>
> macOS ships some UI fonts which it does not enumerate, all having
> names beginning with "."
> It expects you to create them using APIs such as
> CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0, NULL);
> or
> nsFont = [NSFont systemFontOfSize:1.0];
>
> In apps built with all SDKs to date, so long as you can get the real
> "." name you can still
> request it by name.
>
> But with the latest Xcode 11 this not only prints a warning that you
> should not do it,
> it also gives you Times New Roman instead - not a standard UI font -
> probably a choice
> so it is obvious it is not a UI font.
>
> Our problem here is that JavaFX uses the system font as its "logical"
> font called System
> and also JavaFX uses Java 2D for printing. It messages over the ".*"
> name to Java 2D
> to use as the font to print. But with the latest Xcode 2D is not
> allowed to create the font using that name.
>
> This fix changes the JDK code for macOS that creates the native font
> pointer to check if the name being requested
> is one of the UI fonts. If it is, then it uses the NSFont
> systemFontOfSize API to create the font, which fixes the problem.
>
> If someone asks for a random name such as ".foo"
> Note that
> 1) JDK only enumerates the regular and bold system font which is all
> FX uses.
>
> 2) The fix *could* have just tested to see if the requested name
> begins with "." and that worked too but it
> wasn't clear what would happen if there is some other font called
> ".Foo". We tested and
> names starting with "." seem to be absolutely reserved for these
> system fonts on macOS
> If you see such a font. it is a system font. We tested and if you have
> a random name such as ".FOO"
> macOS does the same thing - it assumes it is a system font and won't
> give it to you.
> So probably testing for a "." prefix would have been OK but as written
> it is more certain and
> is robust against Apple changing the nameing scheme to be (sa) a "~"
> prefix.
>
> No regression test as this isn't easily testable and the main place it
> matters is FX printing.
> However we've verified this on 10.13.6 with the old tool chain and
> 10.15.2 with the new toolchain
> and fixes the warnings and FX printing.
>
> The removal of adding the fixed width font is because we never needed
> it and it is just Monaco anyway ...
>
> -phil.
>
>
>
More information about the 2d-dev
mailing list