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

List:       openjdk-2d-dev
Subject:    [OpenJDK 2D-Dev] JDK-8012351
From:       Ryan Tandy <rtandy () sd63 ! bc ! ca>
Date:       2014-01-07 0:26:55
Message-ID: 52CB49CF.7050807 () sd63 ! bc ! ca
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Dear JDK team,

[I'm not subscribed, so please Cc me on replies. I hope this is the
right list for this, or that you can direct me to the appropriate one.]

I've been working on Ubuntu bug #937200 [http://pad.lv/937200], which is
JDK-8012351 in your tracker, and wanted to share my results with you.
(See also my comments on that bug, starting from #59.)

As far as I can tell, the root of this bug is that a sun.font.FontFamily
created with a certain rank does not actually get additional styles
added to it if they have a higher rank, contrary to the comments in
sun.font.SunFontManager.

In Ubuntu, the Ubuntu font is the default GTK/GNOME UI font but is not
listed in the fontconfig configuration, so it has a low priority and is
only used as a fallback font. On a stock system Ubuntu-R.ttf is included
in "fc-match -s sans" output, but on a system with "fonts-unfonts-core"
installed (for example after installing Wine, which has an optional
dependency on it), UnDotum.ttf from that package is used instead,
because fontconfig prefers it.

So when I run the attached test case on Ubuntu with fonts-unfonts-core
installed, what I see is that the bold and italic styles of the Ubuntu
family are referenced by fontconfig, and so loaded with rank 2, but the
plain style is not. The plain style is seen later, with rank 3. Stepping
through sun.font.SunFontManager.addToFontList in detail:

- physicalFonts doesn't contain "Ubuntu" (only "Ubuntu Bold" and "Ubuntu
Italic").
- the existing "Ubuntu" FontFamily is retrieved; it has rank 2.
- the (family.getRank() >= rank) test fails, because rank is 3!

Eventually findFont2D tries to retrieve the requested font and style
from the family. At this point the Ubuntu family still has bold and
italic styles but no plain, FontFamily.getClosestStyle returns the bold
style even though plain was requested, and that's the symptom that users
have been reporting.

Installing fontconfig.Ubuntu.properties from JDK6 (as suggested in the
Launchpad comments) works around the problem because that one doesn't
mention the Ubuntu font family at all, and so all of its styles are
loaded with the same rank (3).

I'm of course not familiar with this code, but the tests on lines 766
and 857 seem strange to me. Looking at the context, I think the "else
if" conditions on both of those lines could be changed to just "else",
because the operations around them (updating physicalFonts and
fullNameToFont) are all done unconditionally.

I hope this helps! Please let me know if I can help any more, for
example if you still have trouble reproducing the bug.

Thanks for your time,

Ryan

-- 
Ryan Tandy - Programmer/Analyst           rtandy@sd63.bc.ca
School District 63 (Saanich)                +1 250 652 7385

["TestCase.java" (text/x-java)]

import java.awt.Font;
import sun.font.FontFamily;
import sun.font.FontManager;
import sun.font.FontManagerFactory;

public class TestCase {
	public static void main(String[] args) throws Exception {
		FontManager fontManager = FontManagerFactory.getInstance();
		fontManager.findFont2D("Ubuntu", Font.PLAIN, FontManager.NO_FALLBACK);
		FontFamily family = FontFamily.getFamily("Ubuntu");
		System.out.println(family.toString());
	}
}

["signature.asc" (application/pgp-signature)]

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

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