Fat fonts in Swing applications

Bug #937200 reported by Martin Weißhaupt
404
This bug affects 88 people
Affects Status Importance Assigned to Milestone
fonts-unfonts-core (Ubuntu)
Invalid
Low
Unassigned
Precise
Invalid
Low
Unassigned
openjdk-7 (Ubuntu)
Fix Released
Low
Unassigned
Precise
Fix Released
Low
Unassigned

Bug Description

SRU justification:

[Impact]

When certain combinations of font packages are installed, the Java font loader may load certain fonts with some of their styles missing, meaning the wrong style is rendered when that font is chosen.

The most well-known example is on Ubuntu systems with fonts-unfonts-core installed (recommended by Wine): the Ubuntu font is loaded without its regular style, so in Swing applications using the GTK look and feel, the Ubuntu font is rendered in bold weight.

[Test Case]

1. Install openjdk-7-jdk, ttf-ubuntu-font-family, and fonts-unfonts-core.

2. Download the test case from comment #61: https://launchpadlibrarian.net/161520209/TestCase.java

3. Compile and run the test case:

  javac TestCase.java
  java TestCase

4. The expected output should begin with:

Font family: Ubuntu plain=** TrueType Font: Family=Ubuntu Name=Ubuntu [...]

The current (broken) output begins with:

Font family: Ubuntu plain=null bold=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold [...]

Note "plain=null" in the broken output, meaning the bold style is going to be used when plain was requested.

[Regression Potential]

* The patch was authored by the maintainer of the surrounding code, and reviewed and accepted upstream.

* If there is a regression, it might be reported upstream against JDK8 or JDK9, so we should be aware of any upstream fixes in that part of the code.

* If there is a regression, the symptoms are likely to be similar to this bug: incorrect or incomplete font loading in certain configurations.

Original description:

Since I upgraded to Ubuntu 12.04 I noticed that the fonts in Java Swing applications use the bold font weight. This looks really ugly and takes up to much space.

1.
lsb_release -rd
Description: Ubuntu precise (development branch)
Release: 12.04

2.
apt-cache policy openjdk-7-jdk
openjdk-7-jdk:
  Installiert: 7~b147-2.0-1ubuntu2
  Kandidat: 7~b147-2.0-1ubuntu2
  Versionstabelle:
 *** 7~b147-2.0-1ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
        100 /var/lib/dpkg/status

3.
Applications rendering with normal fonts

4.
Applications rendering with bold fonts

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: openjdk-7-jdk 7~b147-2.0-1ubuntu2
ProcVersionSignature: Ubuntu 3.2.0-17.26-generic 3.2.6
Uname: Linux 3.2.0-17-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 1.92-0ubuntu1
Architecture: amd64
Date: Mon Feb 20 20:44:43 2012
InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64 (20101007)
SourcePackage: openjdk-7
UpgradeStatus: Upgraded to precise on 2012-02-16 (3 days ago)

Revision history for this message
Martin Weißhaupt (mweisshaupt) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openjdk-7 (Ubuntu):
status: New → Confirmed
Revision history for this message
mjreged (mjreged) wrote :

The workaround I found for now is to switch Fonts in Default font to anything other then Ubuntu, like to Ubuntu Light font.
In the Advanced Settings, fonts section.

Revision history for this message
Shake (shake234) wrote :

The workaround doesn't work for me.

I have switched all fonts, changed the size. I still get a bold default font in Swing applications.
I have written a small test app: The used font is "Dialog, bold, 12"

I have tried several JREs:

OpenJDK 1.7 (from Ubuntu repo)
OpenJDK 1.6 (from Ubuntu repo)
Oracle JRE 7 (installed manually)

Revision history for this message
Shake (shake234) wrote :

Small sample application:

import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * @author Johannes Schneider (<a href="mailto:<email address hidden>"><email address hidden></a>)
 */
public class Tester {
  public static void main( String[] args ) {
    JFrame frame = new JFrame("da Title");
    frame.setSize( 600, 100 );
    frame.setVisible( true );
    frame.setLocationRelativeTo( null );

    JLabel daLabel = new JLabel();
    daLabel.setText( daLabel.getFont().toString() );
    frame.getContentPane().add( daLabel );
  }
}

Revision history for this message
Dan Jared (danjaredg) wrote :

The work arround of mjreged, works, the bold fonts only show with Ubuntu Font, you need change the fond, I change to Droid Sans Font.

$ gsettings set org.gnome.desktop.interface document-font-name 'Droid Sans 11'
$ gsettings set org.gnome.desktop.interface font-name 'Droid Sans 11'
$ gsettings set org.gnome.desktop.interface monospace-font-name 'Ubuntu Mono 12'
$ gsettings set org.gnome.nautilus.desktop font 'Droid Sans 11'
$ gconftool --set /apps/metacity/general/titlebar_font 'Droid Sans Bold 11' --type STRING

And add on netbeans-7.x/etc/netbeans.conf

-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on

on property "netbeans_default_options"

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on"

Revision history for this message
Shake (shake234) wrote :

Okay - I played a little bit around and got this results:

The only thing that is relevant for this problem seems to be the setting "font-name". The other font settings don't matter.

That can be changed with:
gsettings set org.gnome.desktop.interface font-name 'Droid Sans 10'

Now it should with *non-default* Look-and-Feels (e.g. Nimbus, GTK).

Details:

I am setting my font settings using this script:
--------------------
gsettings set org.gnome.desktop.interface document-font-name 'Droid Sans 10'
gsettings set org.gnome.desktop.interface font-name 'Droid Sans 10'
gsettings set org.gnome.desktop.interface monospace-font-name 'ProFontWindows 8'
gsettings set org.gnome.nautilus.desktop font 'Droid Sans 10'
gconftool --set /apps/metacity/general/titlebar_font 'Droid Sans Bold 10' --type STRING
--------------------

Reading the values using
--------------------
echo "Document Font: "
gsettings get org.gnome.desktop.interface document-font-name
echo "Font: "
gsettings get org.gnome.desktop.interface font-name

echo "Monospaced Font: "
gsettings get org.gnome.desktop.interface monospace-font-name

echo "Nautilus Desktop Font: "
gsettings get org.gnome.nautilus.desktop font

echo "Titlebar Font: "
gconftool --get /apps/metacity/general/titlebar_font
--------------------

I got the following:
With changed fonts, it looks ok, when:
- Nimbus or GTK LnF is used
It *does* work with the default LnF.

The AA settings just do what one expects: The change the AA settings...

Revision history for this message
Franco (francogpellegrini) wrote :

The #7 fix work for me! (The problem is the FONT) Thanks

Revision history for this message
Ivan Ivanov (obiwanus) wrote :

But what to do if I love Ubuntu Font and don't want any other

Revision history for this message
Martin Weißhaupt (mweisshaupt) wrote :

I bought a new computer recently and needed to do a fresh install of Ubuntu 12.04. The problem does not exist on this machine so I suppose it is a problem with upgrading Ubuntu to 12.04.

Revision history for this message
Ivan Ivanov (obiwanus) wrote :

Martin, on my fresh-installed Ubuntu 12.04 the problem appeared after installing wine.

Revision history for this message
Espen Meidell (espen-meidell) wrote :

I also experienced this problem after installing wine

Revision history for this message
trojkat (trojkat) wrote :

In my case exactly the same: bold fonts appeared after installing wine.

Revision history for this message
higuita (higuita) wrote :

after some debug i found that the /etc/font/conf.d/65-nonlatin.conf is the one that makes java use a bad font.

remove it and restart the java and things will be back to normal.

of course, i dont know what removing that font definition will break, possible non-latin languages :)

Revision history for this message
Dan Jared (danjaredg) wrote :

I remove the /etc/fonts/conf.d/65-nonlatin.conf but don't nothing, the fat Ubuntu font remain

Revision history for this message
Gerhard Radatz (gerhard-radatz) wrote :

Thanks to the comments above stating that the problem appeared after installing wine, I could track down the problem: It is caused by the package fonts-unfonts-core, which is installed together with wine.

sudo apt-get remove fonts-unfonts-core

Solves the issue (at least if you don't need korean fonts, which are contained within it).

Revision history for this message
Hanine HAMZIOUI (hanynowsky) wrote :

@Gerhard Radatz thanks. This works for me.

Revision history for this message
Espen Meidell (espen-meidell) wrote :

Removing fonts-unfonts-core worked for me too.

Revision history for this message
Natan Volkovich (natan-volkovich) wrote :

Removing fonts-unfonts-core also did the trick here.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in fonts-unfonts-core (Ubuntu):
status: New → Confirmed
Revision history for this message
Dac Chartrand (conner-bw) wrote :

`sudo apt-get remove fonts-unfonts-core` works for me.
Thanks Gerhard Radatz.

Revision history for this message
Rocko (rockorequin) wrote :

Thanks, removing fonts-unfonts-core fixes it for me, too.

Another alternative is to use java-6-sun instead of openjdk (any version) or java-7-oracle, but then you need to keep an old version of java installed on your machine.

Revision history for this message
enz (markus-enzenberger) wrote :

Confirming that this bug still exists in Ubuntu 12.10 beta 2.

Revision history for this message
Hanine HAMZIOUI (hanynowsky) wrote : Re: [Bug 937200] Re: Fat fonts in Swing applications

Seems like it only occurs when one installs wine.
I have 12.10 and the bug does not happen since I did not install WINE.
*--------------------------*

On Fri, Oct 5, 2012 at 9:11 AM, enz <email address hidden> wrote:

> Confirming that this bug still exists in Ubuntu 12.10 beta 2.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/937200
>
> Title:
> Fat fonts in Swing applications
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/fonts-unfonts-core/+bug/937200/+subscriptions
>

Revision history for this message
enz (markus-enzenberger) wrote :

On 10/5/12, hanynowsky <email address hidden> wrote:
> Seems like it only occurs when one installs wine.
> I have 12.10 and the bug does not happen since I did not install WINE.

I did have WINE 1.4 installed and uninstalled it for a test (with
apt-get purge). It did not help, Java Swing applications still use
bold fonts everywhere.

Revision history for this message
Ivan Ivanov (obiwanus) wrote :

It seems to be because wine also installs fonts-unfonts-core, which isn't removed after uninstall. I can be wrong, but removing this package fixes the problem.

Revision history for this message
Adrian Wilkins (adrian-wilkins) wrote :

Confirmed that removing fonts-unfonts-core stopped JConsole and other Swing applications looking distinctly chunky

Revision history for this message
enz (markus-enzenberger) wrote :

Yes, removing fonts-unfonts-core also fixed the problem for me.

On 10/5/12, Adrian Wilkins <email address hidden> wrote:
> Confirmed that removing fonts-unfonts-core stopped JConsole and other
> Swing applications looking distinctly chunky
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/937200
>
> Title:
> Fat fonts in Swing applications
>
> Status in “fonts-unfonts-core” package in Ubuntu:
> Confirmed
> Status in “openjdk-7” package in Ubuntu:
> Confirmed
>
> Bug description:
> Since I upgraded to Ubuntu 12.04 I noticed that the fonts in Java
> Swing applications use the bold font weight. This looks really ugly
> and takes up to much space.
>
>
> 1.
> lsb_release -rd
> Description: Ubuntu precise (development branch)
> Release: 12.04
>
>
> 2.
> apt-cache policy openjdk-7-jdk
> openjdk-7-jdk:
> Installiert: 7~b147-2.0-1ubuntu2
> Kandidat: 7~b147-2.0-1ubuntu2
> Versionstabelle:
> *** 7~b147-2.0-1ubuntu2 0
> 500 http://archive.ubuntu.com/ubuntu/ precise/universe amd64
> Packages
> 100 /var/lib/dpkg/status
>
> 3.
> Applications rendering with normal fonts
>
> 4.
> Applications rendering with bold fonts
>
> ProblemType: Bug
> DistroRelease: Ubuntu 12.04
> Package: openjdk-7-jdk 7~b147-2.0-1ubuntu2
> ProcVersionSignature: Ubuntu 3.2.0-17.26-generic 3.2.6
> Uname: Linux 3.2.0-17-generic x86_64
> NonfreeKernelModules: nvidia
> ApportVersion: 1.92-0ubuntu1
> Architecture: amd64
> Date: Mon Feb 20 20:44:43 2012
> InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64
> (20101007)
> SourcePackage: openjdk-7
> UpgradeStatus: Upgraded to precise on 2012-02-16 (3 days ago)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/fonts-unfonts-core/+bug/937200/+subscriptions
>

Revision history for this message
Matthias Klose (doko) wrote :

it would be good to know which font is causing this. could you reinstall the fonts package, and then remove one font at a time, to see which font is causing this?

Revision history for this message
enz (markus-enzenberger) wrote :

I don't know what you mean by remove a font. Should I delete ttf files
in /usr/share/fonts/truetype/unfonts-core/. Or remove something from
one (or both) of those files:

/etc/fonts/conf.avail/90-fonts-unfonts-core.conf
/etc/fonts/conf.d/90-fonts-unfonts-core.conf

On 10/6/12, Matthias Klose <email address hidden> wrote:
> it would be good to know which font is causing this. could you reinstall
> the fonts package, and then remove one font at a time, to see which font
> is causing this?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/937200
>
> Title:
> Fat fonts in Swing applications
>
> Status in “fonts-unfonts-core” package in Ubuntu:
> Confirmed
> Status in “openjdk-7” package in Ubuntu:
> Confirmed
>
> Bug description:
> Since I upgraded to Ubuntu 12.04 I noticed that the fonts in Java
> Swing applications use the bold font weight. This looks really ugly
> and takes up to much space.
>
>
> 1.
> lsb_release -rd
> Description: Ubuntu precise (development branch)
> Release: 12.04
>
>
> 2.
> apt-cache policy openjdk-7-jdk
> openjdk-7-jdk:
> Installiert: 7~b147-2.0-1ubuntu2
> Kandidat: 7~b147-2.0-1ubuntu2
> Versionstabelle:
> *** 7~b147-2.0-1ubuntu2 0
> 500 http://archive.ubuntu.com/ubuntu/ precise/universe amd64
> Packages
> 100 /var/lib/dpkg/status
>
> 3.
> Applications rendering with normal fonts
>
> 4.
> Applications rendering with bold fonts
>
> ProblemType: Bug
> DistroRelease: Ubuntu 12.04
> Package: openjdk-7-jdk 7~b147-2.0-1ubuntu2
> ProcVersionSignature: Ubuntu 3.2.0-17.26-generic 3.2.6
> Uname: Linux 3.2.0-17-generic x86_64
> NonfreeKernelModules: nvidia
> ApportVersion: 1.92-0ubuntu1
> Architecture: amd64
> Date: Mon Feb 20 20:44:43 2012
> InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64
> (20101007)
> SourcePackage: openjdk-7
> UpgradeStatus: Upgraded to precise on 2012-02-16 (3 days ago)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/fonts-unfonts-core/+bug/937200/+subscriptions
>

Revision history for this message
Matthias Klose (doko) wrote :

yes, removing single font files. after removing a file and testing, re-install the package using
apt-get --reinstall install fonts-unfonts-core

Revision history for this message
enz (markus-enzenberger) wrote :

ok, I went through all fonts in
/usr/share/fonts/truetype/unfonts-core/ and the problem with the bold
fonts went away after removing this one:

/usr/share/fonts/truetype/unfonts-core/UnDotum.ttf

On 10/7/12, Matthias Klose <email address hidden> wrote:
> yes, removing single font files. after removing a file and testing,
> re-install the package using
> apt-get --reinstall install fonts-unfonts-core
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/937200
>
> Title:
> Fat fonts in Swing applications
>
> Status in “fonts-unfonts-core” package in Ubuntu:
> Confirmed
> Status in “openjdk-7” package in Ubuntu:
> Confirmed
>
> Bug description:
> Since I upgraded to Ubuntu 12.04 I noticed that the fonts in Java
> Swing applications use the bold font weight. This looks really ugly
> and takes up to much space.
>
>
> 1.
> lsb_release -rd
> Description: Ubuntu precise (development branch)
> Release: 12.04
>
>
> 2.
> apt-cache policy openjdk-7-jdk
> openjdk-7-jdk:
> Installiert: 7~b147-2.0-1ubuntu2
> Kandidat: 7~b147-2.0-1ubuntu2
> Versionstabelle:
> *** 7~b147-2.0-1ubuntu2 0
> 500 http://archive.ubuntu.com/ubuntu/ precise/universe amd64
> Packages
> 100 /var/lib/dpkg/status
>
> 3.
> Applications rendering with normal fonts
>
> 4.
> Applications rendering with bold fonts
>
> ProblemType: Bug
> DistroRelease: Ubuntu 12.04
> Package: openjdk-7-jdk 7~b147-2.0-1ubuntu2
> ProcVersionSignature: Ubuntu 3.2.0-17.26-generic 3.2.6
> Uname: Linux 3.2.0-17-generic x86_64
> NonfreeKernelModules: nvidia
> ApportVersion: 1.92-0ubuntu1
> Architecture: amd64
> Date: Mon Feb 20 20:44:43 2012
> InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64
> (20101007)
> SourcePackage: openjdk-7
> UpgradeStatus: Upgraded to precise on 2012-02-16 (3 days ago)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/fonts-unfonts-core/+bug/937200/+subscriptions
>

Revision history for this message
Spam Trash (spam-trash) wrote :

This bug appeared when I installed Wine, which brought ms-core-fonts.

Revision history for this message
Spam Trash (spam-trash) wrote :

Confirming that #16 FIXED this. Thanks, Gerhard Radatz.

Revision history for this message
Ricky Brent (rickybrent) wrote :

I ran into this with 12.10 (with wine installed), and did #16 to fix it -- though it looks like #32 has a much better solution.

Revision history for this message
Sergio Benjamim (sergio-br2) wrote :

#16 work well here, fonts are doesn't bold and fat anymore, but now fonts are very thin compared to the system.

Revision history for this message
Sergio Benjamim (sergio-br2) wrote :

Take a look at the picture

Revision history for this message
dgoosens (dgoosens) wrote :

had the same issue after installing Wine...

sudo apt-get remove fonts-unfonts-core
did the trick and Wine is still running fine

thanks

Revision history for this message
PowerKiKi (adrien-crivelli) wrote :

The following did not work for me:
sudo mv /usr/share/fonts/truetype/unfonts-core/UnDotum.ttf /usr/share/fonts/truetype/unfonts-core/UnDotum.ttf.backup

Hoewever I successfully solved this issue with sudo apt-get remove fonts-unfonts-core and can still write in Korean (but didn't reboot yet).

Revision history for this message
Bootch (di-man) wrote :

Thanks. "sudo apt-get remove fonts-unfonts-core" helps.

Revision history for this message
Thomas Meire (blackskad) wrote :

The bold fonts can be removed by copying fontconfig.Ubuntu.properties.src and fontconfig.Ubuntu.bfc from an older java install to ./jre/lib in your new java install. I don't need to remove fonts-unfonts-core.

Revision history for this message
Ari (ari-lp) wrote :

Removing the unfonts-core font package resolved this issue for me. Thank you, @hanynowsky. Isn't it strange how a seemingly unrelated package can cause so many problems?

Revision history for this message
Nick B (declension) wrote :

@blackskad: Thanks that did it, in a much more satisfactory way than removing other packages...

To re-iterate, it seems Oracle have dropped the Ubuntu font configuration from their latest Java 7 packages (for Ubuntu at least). The minimal change is, (assuming you have java-6-sun installed):

sudo cp /usr/lib/jvm/java-6-sun/jre/lib/fontconfig.Ubuntu.* /usr/lib/jvm/java-7-oracle/jre/lib/

Revision history for this message
Pascal Mons (anton+) wrote :

@blackslad & Nick B: Thanks. That worked :) However you do not need to have java-6-sun installed.

I just downloaded the latest Oracle update for Java 6 : jdk-6u43-linux-x64.bin from their website
http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html

Then just make it executable and extract it in a local folder like Downloads

$ chmod +x jdk-6u43-linux-x64.bin
$ ./jdk-6u43-linux-x64.bin

Then copy the 2 files to the working Java 7 installation

$ sudo cp ~/Downloads/jdk1.6.0_41/jre/lib/fontconfig.Ubuntu.* /usr/lib/jvm/java-7-oracle/jre/lib/

That fixed the flaw instantly. Obviously you should keep these 2 files as you will need them each time you update your Oracle Java.

fontconfig.Ubuntu.bfc
fontconfig.Ubuntu.properties.src

It looks like Oracle only keeped the fontconfig for the Red Hat based (rpm) distributions and bumped the only Debian [Ubuntu]. Their own Linux version being Red Hat based (rpm).

Revision history for this message
md_5 (md-5) wrote :

Still present in 13.04 :|

Revision history for this message
Vikas Tiwari (vikastiwari47) wrote :

sudo apt-get remove fonts-unfonts-core
Above command is work for me in both version 13.04, 12.10 of ubuntu

Revision history for this message
Vadim Peretokin (vperetokin) wrote :

Removing fonts-unfonts-core worked for me, although the fotn used is still a bit wrong (Ubuntu Light or something, and not normal). I am using Oracle's Java 7.

Could the fontconfig files be shared and attached to this report, so we don't have to obtain the old Java?

Revision history for this message
Ryan Tandy (rtandy) wrote :

On Wed, Aug 28, 2013 at 6:27 PM, Vadim Peretokin <email address hidden> wrote:
> Could the fontconfig files be shared and attached to this report, so we
> don't have to obtain the old Java?

Attached.

Revision history for this message
Anton Keks (anton-azib) wrote :

Still present in 13.10 :-(

Again, uninstalling fonts-unfonts-core helps, but it was to recall what exactly needed to uninstalled after I have done it for 13.04 6 months ago.

Revision history for this message
Loris Pederiva (siddharta) wrote :

Confirm it's still present in 13.10: fat fonts in Android Studio 0.3 after installing Wine.
Removing fonts-unfonts-core worked for me

Revision history for this message
nvrmndr (nvrmndr) wrote :

Still present in 13.10.1
Fonts look just ugly in Netbeans and IntelliJ IDEA
Oracle JVM 1.7.0_45

Felix (cebor)
tags: added: raring saucy
Revision history for this message
Alberto Salvia Novella (es20490446e) wrote :

Since the package that handles font configuration is "openjdk-7", although the work-around is to remove a component in "fonts-unfonts-core", the real affected package is "openjdk-7" only.

Changed in openjdk-7 (Ubuntu):
importance: Undecided → Low
Changed in fonts-unfonts-core (Ubuntu):
importance: Undecided → Low
status: Confirmed → Invalid
Revision history for this message
Matthias Klose (doko) wrote :

you are wrong. fonts-unfonts-core advertises a font which it doesn't support. openjdk doesn't use that font explicitly, it's selected using fontconfig

Changed in fonts-unfonts-core (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Alberto Salvia Novella (es20490446e) wrote :

Mattias:

Thanks for the correction. Then the package to be fixed is "fonts-unfonts-core" only, isn't it?

Changed in openjdk-7 (Ubuntu):
status: Confirmed → Invalid
no longer affects: openjdk
Changed in fonts-unfonts-core (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
pcworld (pcworld) wrote :

@Matthias Klose:
> fonts-unfonts-core advertises a font which it doesn't support
How do you know that?

So far I could reliably reproduce that removing at least one of the following fonts fixes the probem: UnBatangBold, UnDotum (both in /usr/share/fonts/truetype/unfonts-core).
Note that you have to wait a few seconds for fontconfig(?) to recognize the removal of a font file.

If a JDK fontconfig file as in comment #48 should be used to fix this bug, make sure all font paths are right, e.g. in #48 the unfonts path is wrong.
The following line of "fontconfig.Ubuntu.properties.src" from #48 is the one that fixes the bug at least in simple test cases:
filename.-dejavu-dejavu_serif-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf
You can compile and install the src file e.g. via:
java -jar /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/compilefontconfig.jar ./fontconfig.Ubuntu.properties.src ./fontconfig.Ubuntu.bfc
sudo cp ./fontconfig.Ubuntu.bfc /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/

I have attached a simple test case. If the bug appears, it will output "Ubuntu Bold", otherwise just "Ubuntu".

I have also checked if the commit http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/raring/fonts-unfonts-core/raring/revision/5 introduced this bug, though this is not the case.

Revision history for this message
Alberto Salvia Novella (es20490446e) wrote :

If you know the affected package isn't "fonts-unfonts-core", please mark:

- "fonts-unfonts-core" as invalid.
- "openjdk-7" as confirmed.

and then I will mark ""openjdk-7" as triaged.

Revision history for this message
Changwoo Ryu (cwryu) wrote :

This is a bug by font setting in other packages, not a bug from this font package itself.

Changed in fonts-unfonts-core (Ubuntu):
status: Triaged → Invalid
Changed in openjdk-7 (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Ryan Tandy (rtandy) wrote :

pcworld, thanks for that test case.

Some helpful debug output can be had by running it like this:

    java -Dsun.java2d.debugfonts=true TestCase

It's especially instructive to do that after:

    gsettings reset org.gnome.desktop.interface font-name

and after:

    gsettings set org.gnome.desktop.interface font-name 'DejaVu Sans 11' # or 'Droid Sans 11', or something else

and compare the results.

This does seem to work properly in current trusty. I'll try to figure out whether it was fixed by a change in openjdk-7 or in some other package.

Revision history for this message
Ryan Tandy (rtandy) wrote :

> This does seem to work properly in current trusty.

Sorry, I wrote that too quickly: actually the trusty system I tried on didn't have fonts-unfonts-core installed. After installing that package the bug has appeared again. Not fixed in trusty!

Revision history for this message
Ryan Tandy (rtandy) wrote :

Making some progress on this. I think the bug is present whether or not fonts-unfonts-core is installed, just the behaviour is different. I'm working on trusty right now and source code references are from openjdk-7-source 7u45-2.4.3-4ubuntu2.

Output of the attached testcase when fonts-unfonts-core is not installed:

Font family: Ubuntu plain=** TrueType Font: Family=Ubuntu Name=Ubuntu style=0 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf bold=null italic=null bolditalic=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold Italic style=3 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf

and when fonts-unfonts-core is installed:

Font family: Ubuntu plain=null bold=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold style=1 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf italic=** TrueType Font: Family=Ubuntu Name=Ubuntu Italic style=2 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf bolditalic=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold Italic style=3 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf

We should be seeing all four styles present in either case, because ttf-ubuntu-font-family does provide all of them. The code that returns the bold style as a fallback when plain is null is at SunFontManager.java:2140.

What I'm seeing is that some but not all styles of the Ubuntu family are registered earlier with rank 2. The missing styles are seen later at rank 3, but rejected (SunFontManager.java:766). (There might be more than one bug here... is it just me or is the test on that line backwards?) I haven't figured out yet why some styles are seen at different times.

I will keep digging :) but the time I can spend on this is limited... any help is more than welcome!

tags: added: trusty
Revision history for this message
Ryan Tandy (rtandy) wrote :

getFontConfig (fontpath.c:773) is interesting. For each of the fontConfigNames defined at FontConfigManager.java:82, it runs code similar to "fc-match -s $fontConfigName | head -n 10". The fonts returned from that are registered with rank 2 (Font2D.FONT_CONFIG_RANK). Later, if a requested font isn't found in that set, the system font paths are scanned for TTFs which are all registered with rank 3 (Font2D.TTF_RANK).

Here's an odd thing I noticed. In a minimal chroot with fontconfig (which pulls in fonts-dejavu-core) and ttf-ubuntu-font-family installed:

~$ fc-match -s sans:regular:roman | grep Ubuntu
Ubuntu-C.ttf: "Ubuntu Condensed" "Regular"
Ubuntu-R.ttf: "Ubuntu" "Regular"

and after installing fonts-unfonts-core:

~$ fc-match -s sans:regular:roman | grep Ubuntu
Ubuntu-C.ttf: "Ubuntu Condensed" "Regular"

This seems like a bug but I don't know which package would be responsible: fontconfig, fonts-unfonts-core, or ttf-ubuntu-font-family? Is this what doko was talking about in #54?

The above notwithstanding, I'm also still suspicious about the rank comparison in SunFontManager that I already mentioned...

Revision history for this message
Ryan Tandy (rtandy) wrote :

I understand the fontconfig part better now. UnDotum is listed (in /etc/fonts/conf.d/65-nonlatin.conf) as an alternative for sans-serif. Ubuntu is not mentioned anywhere, meaning it would only appear in fc-match -s output if there are glyphs that no other font provides. Adding Ubuntu to the appropriate families in 60-latin.conf would help with this; maybe I'll file a wishlist bug to that effect, if there isn't one already.

So IMO this does come back to being a bug in openjdk-7, where fonts that aren't included in the early fontconfig "top 10" results (but some of their siblings, e.g. of a different style, are) aren't included in the appropriate FontFamily.

Am I close? :)

Revision history for this message
pdknsk (pdknsk) wrote :

I don't know if it's relevant, but this bug also occurs with deb packages build from the official Oracle releases via java-package.

Revision history for this message
pdknsk (pdknsk) wrote :

PS. As already mentioned, removing fonts-uncore-extra is not a proper workaround as it sets the fonts to Ubuntu Light and not Ubuntu. It's better than having bold fonts though.

Revision history for this message
Sérgio (barulheira) wrote :

Trebuchet MS is affected, too. No problem with other MS fonts. Maybe it helps.

Changed in openjdk-7 (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Ryan Tandy (rtandy) wrote :

The OpenJDK folks know about this bug and have an issue open for it, https://bugs.openjdk.java.net/browse/JDK-8012351 (but sadly LP doesn't understand JIRA bugs yet, bug 157488).

Only OpenJDK developers can post bug comments on that site, so I sent a summary of my investigation to the Java2D development list: http://mail.openjdk.java.net/pipermail/2d-dev/2014-January/004111.html

xnox already filed bug 1003857 for teaching fontconfig about the Ubuntu fonts.

pdknsk (pdknsk) wrote on 2014-01-04:
> I don't know if it's relevant, but this bug also occurs with deb packages
> build from the official Oracle releases via java-package.

Since the buggy code I identified is in the "sun.font" package, I think (hope) the code is shared between OpenJDK and Oracle JDK. We're close to the release of JDK 8, though, so I wouldn't count on having this fixed in JDK 7.

pdknsk (pdknsk) wrote on 2014-01-04:
> PS. As already mentioned, removing fonts-uncore-extra is not a proper
> workaround as it sets the fonts to Ubuntu Light and not Ubuntu. It's better
> than having bold fonts though.

I would be interested to see the output of my TestCase.java (attached to comment 61) on your system.

I do think installing the JDK6 fontconfig.Ubuntu.properties is a better workaround than uninstalling unfonts. I'll try to come up with an updated fontconfig file since, as pcworld mentioned in comment 56, it's not quite correct for modern Ubuntu.

Alberto, thanks for keeping the bug status up to date! :)

Revision history for this message
Ryan Tandy (rtandy) wrote :

BTW, JDK 7 doesn't actually read fontconfig.properties any more (the automatic configuration via libfontconfig is preferred). The fontconfig.properties installed in /etc/java-7-openjdk already has the proper fonts and paths for Ubuntu but it's unused!

If you make a symlink with a more specific name like this:

    sudo ln -s /etc/java-7-openjdk/fontconfig.properties /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/fontconfig.Ubuntu.properties

then it does get read. So that's an easy way to work around this bug. (Same for Oracle JDK 7, with paths adjusted appropriately.)

Revision history for this message
bademux (bademux) wrote :

+Ryan Tandy (rtandy), Genius! It fixes IntelliJ Idea fonts both for OracleJDK7 and OpenJDK7
Maybe one day Ubuntu will work out-of-box...
One tweak less. Thanks!

Revision history for this message
pdknsk (pdknsk) wrote :

Where do I find this file when using Oracle JDK? Both oracle-j2sdk1.7 and oracle-j2re1.7 don't install any files in the /etc/ dir. And sudo find / -name fontconfig.properties yields no results either.

Revision history for this message
pdknsk (pdknsk) wrote :

I got the file from package openjdk-7-jre-headless and copied it to /usr/lib/jvm/j2re1.7-oracle/lib/fontconfig.Ubuntu.properties but it doesn't seem to make any difference.

This is the result from your file.

Font family: Ubuntu plain=** TrueType Font: Family=Ubuntu Name=Ubuntu style=0 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf bold=null italic=null bolditalic=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold Italic style=3 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf

Maybe I'm wrong on Ubuntu Light rather than Ubuntu being used. I've attached a screenshot.

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

$ apt-file search fontconfig |grep proper
openjdk-6-jre-headless: /etc/java-6-openjdk/fontconfig.properties
openjdk-6-jre-headless: /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/fontconfig.properties
openjdk-7-jre-headless: /etc/java-7-openjdk/fontconfig.properties
openjdk-7-jre-headless: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/fontconfig.properties

Revision history for this message
Ryan Tandy (rtandy) wrote :

pdknsk (pdknsk) wrote:
> Where do I find this file when using Oracle JDK?

I think it isn't installed any more, which is why earlier comments suggested copying it from JDK 6. The one from openjdk-7 is more appropriate though because it uses the correct fonts and paths for Ubuntu.

> I got the file from package openjdk-7-jre-headless and copied it to
> /usr/lib/jvm/j2re1.7-oracle/lib/fontconfig.Ubuntu.properties but it
> doesn't seem to make any difference.

That should be ../jre/lib/fontconfig.Ubuntu.properties. You should see other fontconfig files for e.g. Redhat, Suse in the same location.

But either way in your case it probably won't change anything, because...

> This is the result from your file.
>
> Font family: Ubuntu plain=** TrueType Font: Family=Ubuntu Name=Ubuntu
> style=0 fileName=/usr/share/fonts/truetype/ubuntu-font-
> family/Ubuntu-R.ttf bold=null italic=null bolditalic=** TrueType Font:
> Family=Ubuntu Name=Ubuntu Bold Italic style=3
> fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf
>
> Maybe I'm wrong on Ubuntu Light rather than Ubuntu being used. I've
> attached a screenshot.

So you can see in the output that the plain style is in fact registered but the bold and italic are not; that's the same result I get on a system without fonts-unfonts-core installed.

I think the font in your screenshot is Ubuntu and not Ubuntu Light, but using wrong hinting or rendering settings. That would be a bug in Java certainly, but separate from this. (You're not the first person to notice the incorrect hinting and in fact I can reproduce it easily.)

Revision history for this message
pdknsk (pdknsk) wrote :

Sorry, I made a mistake. The output was without fonts-uncore-core installed. With the package the output is as follows.

Font family: Ubuntu plain=null bold=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold style=1 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf italic=** TrueType Font: Family=Ubuntu Name=Ubuntu Italic style=2 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf bolditalic=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold Italic style=3 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf

I copied fontconfig.properties to the proper location which fixed the bold fonts.

Font family: Ubuntu plain=** TrueType Font: Family=Ubuntu Name=Ubuntu style=0 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf bold=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold style=1 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf italic=** TrueType Font: Family=Ubuntu Name=Ubuntu Italic style=2 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf bolditalic=** TrueType Font: Family=Ubuntu Name=Ubuntu Bold Italic style=3 fileName=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf

In case someone else with Oracle Java wants to reproduce, I'm listing simple steps.

$ apt-get download openjdk-7-jre-headless
$ dpkg-deb -x openjdk-7-jre-headless_7u25-2.3.12-4ubuntu3_i386.deb jdk
$ sudo cp jdk/etc/java-7-openjdk/fontconfig.properties /usr/lib/jvm/j2sdk1.7-oracle/jre/lib/fontconfig.Ubuntu.properties

Revision history for this message
Ryan Tandy (rtandy) wrote :

Ryan Tandy (rtandy) wrote:
> I think the font in your screenshot is Ubuntu and not Ubuntu Light, but using wrong
> hinting or rendering settings.

You were right, actually: it's definitely Ubuntu Light. Now why would that be happening...? There are some other bugs discussing how the different weights of the Ubuntu font are arranged, I'm sort of wondering if it's related...

pdknsk (pdknsk) wrote:
> I copied fontconfig.properties to the proper location which fixed the bold fonts.

Good, so that much is working then (getting the proper font when Ubuntu Regular is requested). So then on to investigating why the GTK look and feel is choosing Light and not Regular...

Revision history for this message
Ryan Tandy (rtandy) wrote :

BTW: I put up a PPA of openjdk-7 for precise and trusty (other releases are possible) to test the very small code change that I think fixes this specific bug.

add-apt-repository ppa:rtandy/lp937200

Would be happy to hear whether this works well for others and whether it introduces any regressions.

Revision history for this message
Gerhard Radatz (gerhard-radatz) wrote :

Ryan, I would be happy to test your PPA under 13.10 (saucy).
Since I've upgrade my system to this release, I have this fat fonts regression again.
Could you provide a PPA for saucy, too?

Revision history for this message
Ryan Tandy (rtandy) wrote :

Gerhard Radatz (gerhard-radatz) wrote:
> Could you provide a PPA for saucy, too?

Uploaded. It's building now, should be done in about 10 hours. Thanks for offering to test!

pdknsk (and anyone else affected), about the Ubuntu/Ubuntu Light confusion... the same happens for me with OpenJDK 6 and Sun JDK6 as well, so it's definitely not a JDK7 regression like this bug is... Fixing this bug gets us back to the same behaviour we had in Java 6.

Revision history for this message
Gerhard Radatz (gerhard-radatz) wrote :

Ryan,

thanks for the PPA. I can confirm that it fixes the bug for me.

Ryan Tandy (rtandy)
Changed in openjdk:
assignee: nobody → Ryan Tandy (rtandy)
Revision history for this message
Ryan Tandy (rtandy) wrote :

I've been in contact with upstream about this bug and I've just uploaded a new PPA package with the patch which will likely be included upstream once it passes review.

precise: 7u51-2.4.4-0ubuntu0.12.04.2ppa2
saucy: 7u51-2.4.4-0ubuntu0.13.10.1ppa2

After these finish building (in 10 or 12 hours from now), please test them and let me know whether they fix the bug for you and whether you notice any new problems. Thanks for helping!

Revision history for this message
bademux (bademux) wrote :

Sorry for offtopic
Font fix and new ayatana2* (Global menu integration for Java Swing Apps) make me and my internal perfectionist almost happy ;)

 Thanks!

IntelliJ Idea 13 with Dracula theme screenshot attached

*https://code.google.com/p/java-swing-ayatana/

Revision history for this message
Gerhard Radatz (gerhard-radatz) wrote :

Ryan, I have tested your new PPA2 under saucy. It fixes the Fat Fonts problem for me and doesn't seem to introduce any new bugs so far...
Thanks for the great work!

Revision history for this message
Ryan Tandy (rtandy) wrote :
no longer affects: openjdk
Revision history for this message
Ryan Tandy (rtandy) wrote :

Hi OpenJDK maintainers, or any developers,

Is there anything I can do to help get this patch into openjdk-7 in Debian and Ubuntu?

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Hi Ryan, sorry but I don't see any patch against openjdk7, neither a debdiff or similar.

Mattias is the debian/ubuntu maintainer and uploader, and I think will be happy to include your patch if you provide one ;)

thanks!

Revision history for this message
pdknsk (pdknsk) wrote :

I confirm this is fixed in Oracle JDK.

Revision history for this message
pdknsk (pdknsk) wrote :

Well, bold fonts are. The lesser problem, light fonts, isn't.

Revision history for this message
Ryan Tandy (rtandy) wrote :

On Sun, Mar 16, 2014 at 11:59 PM, LocutusOfBorg
<email address hidden> wrote:
> Hi Ryan, sorry but I don't see any patch against openjdk7, neither a
> debdiff or similar.
>
> Mattias is the debian/ubuntu maintainer and uploader, and I think will
> be happy to include your patch if you provide one ;)

Fair enough. Attached.

Ryan Tandy (rtandy)
tags: added: patch
Revision history for this message
Ryan Tandy (rtandy) wrote :

BTW, if a person who has the power reads this, please nominate for P/Q/S... thanks :)

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work, that was uploaded to trusty with
https://launchpad.net/ubuntu/+source/openjdk-7/7u51-2.4.6-1ubuntu1

That might be a candidate for stable update to other series, if you are interested on seeing that happening and helping please follow https://wiki.ubuntu.com/StableReleaseUpdates

Changed in openjdk-7 (Ubuntu):
status: Triaged → Fix Committed
Changed in openjdk-7 (Ubuntu Precise):
importance: Undecided → Low
status: New → Triaged
Changed in fonts-unfonts-core (Ubuntu Precise):
importance: Undecided → Low
status: New → Invalid
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Nack Sebastien Bacher, you started from the wrong version to apply the patch and upload.
https://launchpad.net/ubuntu/+source/openjdk-7/7u51-2.4.6~pre1-1ubuntu2 was the right one.

now your build will fail on arm* and so on

Revision history for this message
Ryan Tandy (rtandy) wrote :
description: updated
Revision history for this message
Ryan Tandy (rtandy) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

everything is fine. just don't bother with any stable updates. will be included with the next security updates.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openjdk-7 - 7u51-2.4.6-1ubuntu3

---------------
openjdk-7 (7u51-2.4.6-1ubuntu3) trusty; urgency=medium

  * Don't search ecj.jar when it is not required for the build.
 -- Matthias Klose <email address hidden> Tue, 01 Apr 2014 11:07:32 +0200

Changed in openjdk-7 (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openjdk-7 - 7u55-2.4.7-1ubuntu1~0.12.04.2

---------------
openjdk-7 (7u55-2.4.7-1ubuntu1~0.12.04.2) precise-security; urgency=medium

  * Backport for Ubuntu 12.04 LTS (LP: #1283828)
  * debian/control: Breaks: icedtea-netx (<< 1.2.3-0ubuntu0.12.04.3)
  * update Makefile.am and Makefile.in to restore quoting. Patch thanks to
    Matthias Klose
 -- Jamie Strandboge <email address hidden> Fri, 25 Apr 2014 07:04:23 -0500

Changed in openjdk-7 (Ubuntu Precise):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.