[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] Font bug with minimal fonts installed
From:       Mario Torre <neugens () redhat ! com>
Date:       2017-09-05 12:39:30
Message-ID: CAJwKKmZy0ypadymRs6nGZe8T35dXjvfK4vsznLqojgS8-5a-Sg () mail ! gmail ! com
[Download RAW message or body]

Any ideas or suggestion?

Mario

On Thu, Aug 31, 2017 at 1:54 PM, Mario Torre <neugens@redhat.com> wrote:
> I have a weird issue with fonts in RHEL (and that means likely means
> all derivative, like CentOS and Oracle Linux), although it appears
> that the same issue can be replicated on a Fedora 26.
>
> The issue is this one, in case you want to see more details:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1484079
>
> From what I can see, basically in this weird setting with no fonts
> installed except the bare minimum required and this STIX font package,
> the font subsystem fails to initialise properly. STIX fonts are open
> type but are CFF format, so they are skipped during the first round of
> initialisation.
>
> What I can't fully get though is why they are still used by default
> when simply asking for a SanSerif font:
>
> Font font = new Font("SansSerif", Font.PLAIN, 12);
>
> I can see the font code (in fontpath.c) reading this font information
> and then skipping it, at the end it still creates an array with 0
> elements (the native method is created with includeFallbacks true, but
> there's no fallback, so the array is 0 length), which causes the
> exception in the original report (or some variation of it, but they
> are basically all the same):
>
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
>     at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:75)
>     at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
>     at sun.font.Font2D.getFontMetrics(Font2D.java:415)
>     at java.awt.Font.defaultLineMetrics(Font.java:2176)
>     at java.awt.Font.getLineMetrics(Font.java:2283)
>     at java.awt.font.TextLayout.fastInit(TextLayout.java:598)
>     at java.awt.font.TextLayout.<init>(TextLayout.java:393)
>     at TestJava.main(TestJava.java:15)
>
> I suspect there's an actual bug in this logic and we shouldn't try to
> access the font (perhaps in the java side) if fontCount, is 0, but I'm
> not entirely sure.
>
> A quick workaround is to just scan also CFF, it seems correct to me
> anyway, although maybe the correct check should go after TrueType and
> not after Type1, but I left this Linux specific.
>
> I would like some comment before I go ahead and create an OpenJDK bug
> report, perhaps I'm just confused and I'm looking in the wrong place.
> The following patch was taken from a 8u-dev in case you want to try
> it, and I suggest using a throwaway VM since uninstalling all the
> fonts is guaranteed to mess your setup :)
>
> There is a full attached test case in the bug report, but I can paste
> it in the email if you can't look at the link.
>
> diff -r e96c4a40fdf9 src/solaris/native/sun/awt/fontpath.c
> --- a/src/solaris/native/sun/awt/fontpath.c     Wed Aug 23 14:14:49 2017 -0400
> +++ b/src/solaris/native/sun/awt/fontpath.c     Thu Aug 24 12:14:41 2017 -0400
> @@ -1239,6 +1239,7 @@
>                  && (strcmp((char*)fontformat, "TrueType") != 0)
>  #if defined(__linux__) || defined(_AIX)
>                  && (strcmp((char*)fontformat, "Type 1") != 0)
> +                && (strcmp((char*)fontformat, "CFF") != 0)
>  #endif
>               ) {
>                  continue;
>
> Cheers,
> Mario
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic