netbeans is not well rendered using openjdk

Bug #289784 reported by Nicolò Chieffo
64
This bug affects 8 people
Affects Status Importance Assigned to Milestone
OpenJDK
Fix Released
Medium
netbeans (Ubuntu)
Invalid
Undecided
Unassigned
Hardy
Invalid
Undecided
Unassigned
Intrepid
Invalid
Undecided
Unassigned
openjdk-6 (Ubuntu)
Fix Released
Low
Unassigned
Hardy
Won't Fix
Low
Unassigned
Intrepid
Invalid
Low
Unassigned
ttf-indic-fonts (Ubuntu)
Confirmed
Medium
Unassigned
Hardy
Won't Fix
Undecided
Unassigned
Intrepid
Invalid
Undecided
Unassigned

Bug Description

using openjdk 6b12-0ubuntu6

running netbeans 6.1, there are some problems with graphic. Maybe the problem is in rendering fonts.
Everything is bigger in comparison to sun java.
Even the UML editor has the same text problems for labels: the label text is not inside the field, as it should be, but under it.
screenshot for the example

Related branches

Revision history for this message
In , asch (asch) wrote :

The java.awt.font.TextLayout.getBounds() method returns a box that is shifted upwards compared to the box that is returned by Sun's official JRE.

Sample code:
package swingbug;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;

import javax.swing.JFrame;

public class SwingBug extends JFrame {

 private static final long serialVersionUID = 1L;

 public static void main(String[] args) {
  new SwingBug().setVisible(true);
 }
 public SwingBug() {
  setTitle("Swing bug");
  setSize(400, 400);
  repaint();
 }
 @Override
 public void paint(Graphics g) {
  Graphics2D graphics=(Graphics2D) g;
  graphics.setColor(Color.BLUE);
  graphics.fillRect(0,0,400,400);
  drawString(graphics, "Hello Kitty!", 100, 100);
 }

 public void drawString(
   Graphics2D graphics, String string, int x, int y) {
  if (string.length() > 0) {
   Font f = new Font("times", 0, 16);
   graphics.setFont(f);
   FontRenderContext fontRendererContext = new FontRenderContext(null, true, true);
   TextLayout textLayout = new TextLayout(string, f, fontRendererContext);
   Rectangle2D rectangleOfText=textLayout.getBounds();
   Rectangle backgroundRectangle=rectangleOfText.getBounds();
   graphics.setColor(new Color(1.0f,1.0f,1.0f,0.5f));
   graphics.fillRect(backgroundRectangle.x+x,backgroundRectangle.y+y,backgroundRectangle.width,backgroundRectangle.height);
   graphics.setColor(new Color(0,0,0));
   textLayout.draw(graphics, x, y);
  }
 }
}

Revision history for this message
In , asch (asch) wrote :

Created attachment 123
The result of the example code on icedtea6

When generating this screenshot this JRE is used:
$ java -version
java version "1.6.0_0"
IcedTea6 1.3.1 Runtime Environment (build 1.6.0_0-b12)
OpenJDK 64-Bit Server VM (build 1.6.0_0-b12, mixed mode)

Revision history for this message
In , asch (asch) wrote :

Created attachment 124
This is how Sun JRE renders the same window

Revision history for this message
In , asch (asch) wrote :

Created attachment 125
With Compiz activated the result is getting more weird

The "dust" on the picture appears when I run the test code with compiz activated. It is not deterministic but is always different on each run of the code. The "extra" white rectangle is always the same.

It seems to be video driver problem but other (non Java) programs on the desktop all work fine and are not affected.

Revision history for this message
In , Martin Buchholz (martinrb) wrote :

(In reply to comment #0)
I'm no 2-d expert, but these appear to be the same bug:

swing TextLayout.getBounds() returns shifted bounds
http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=227

OpenJDK: vertical text metrics may be significanly different from
those returned by Sun JDK
http://bugs.sun.com/view_bug.do?bug_id=6761856

See also thread on this on <email address hidden>

Revision history for this message
Nicolò Chieffo (yelo3) wrote :
Revision history for this message
Nicolò Chieffo (yelo3) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

openjdk-6 uses the system font by default. I don't think this is a bug in openjdk-6 itself. can netbeans be made aware of different font sizes?

Revision history for this message
Nicolò Chieffo (yelo3) wrote : Re: [Bug 289784] Re: netbeans is not well rendered using openjdk

What do you mean when you say "it uses the system fonts"? What does
sun-java use instead?

I tried to change the application system font, from the apparence
applet, but the font did not change in netbeans.
Anyway it's not only that the font is bigger, but as you can see in
the screenshots, the spacing is huge.

From netbeans I can only change the syntax font, not the menu font.

Revision history for this message
Marek Slama (mslama-email) wrote :

Yes it is possible to change only editor font from inside NetBeans IDE. The rest (menu, tree, tab, ...) use default Swing font. Yes I can see spacing is bigger on openjdk. I will check default Swing component as IMO it is not specific to NetBeans. Note that it is Metal L&F.

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

see /etc/java-6-openjdk/fontconfig.properties.src. it points to DejaVu, as this is used by Ubuntu by default.

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

Shouldn't the file be called fontconfig.properties like the one of
java-6-sun? maybe an error...

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

it's the binary (.bfc) file which does matter.

Revision history for this message
Yulia Novozhilova (yulia-novozhilova) wrote :

It looks like it is better to use GTK look and feel.

To use it, please, edit /usr/share/netbeans/6.1/etc/netbeans.conf:

netbeans_default_options="... --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel"

Revision history for this message
Flávio Martins (flavioxmartins) wrote :

I think we should mark this Invalid for netbeans.
However, I've been bitten by this in the stuff I run with openjdk, the menubars specifically are taller than they should be.
In my opinion there is a significant departure in the look of java apps with openjdk, I would investigate if something can be done to attenuate that difference.

Revision history for this message
Nicolò Chieffo (yelo3) wrote :

The gtk look and feel is ok, but it's really slower on my machine. And
anyway the labels in the UML editor are placed in a different position
that the text contained

Revision history for this message
In , Mark J. Wielaard (3y9m2vcw-ll9d-fkzsxrqg) wrote :

changeset: 1167:7175ea5857e4
user: Mark Wielaard <email address hidden>
date: Fri Nov 07 13:47:41 2008 +0100
files: ChangeLog HACKING Makefile.am patches/icedtea-6761856-freetypescaler.patch
description:
* patches/icedtea-6761856-freetypescaler.patch: New patch.
        * Makefile.am (ICEDTEA_PATCHES): Add new patch.
        * HACKING: Document new patch.

Revision history for this message
Marek Slama (mslama-email) wrote :
Revision history for this message
Flávio Martins (flavioxmartins) wrote :

Ok, a patch was commited to the repo.
Maybe backport that patch, or merge with IcedTea to get it, I don't
know what would be the right policy here.

Revision history for this message
Flávio Martins (flavioxmartins) wrote :
Changed in openjdk-6:
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
Sebastian Urban (surban) wrote :

Will this be fixed in Hardy and Intrepid? This does not only affect NetBeans but every other Java Swing program. Is there are workaround?

Matthias Klose (doko)
Changed in openjdk-6:
importance: Undecided → Low
status: New → Triaged
importance: Undecided → Low
status: New → Triaged
Changed in netbeans:
status: New → Invalid
status: New → Invalid
status: New → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openjdk-6 - 6b13~pre1-0ubuntu1

---------------
openjdk-6 (6b13~pre1-0ubuntu1) jaunty; urgency=low

  * New code drop (b13).
    - In the langtools area, besides a few miscellaneous bug fixes (6760834,
      6725036, 6657499), all the langtools regression tests now pass out of
      the box (6728697, 6707027) and if using the most recent version of
      jtreg, the langtools regression tests can be run in the much faster
      "same vm" mode of jtreg, enabled with the -s option (6749967, 6748541,
      6748546, 6748601, 6759775, 6759795, 6759796, 6759996, 6760805, 6760930).
    - Gervill update, including applying a patch from IcedTea (6758986,
      6748247, 6748251).
    - Publishing a few dozen additional existing regression tests as open
      source (6601457, 6759433, 6740185).
    - JMX and monitoring fixes (6651382, 6616825, 6756202, 6754672).
    - Man page updates (6757036, 6392810, 6504867, 6326773).
    - Assorted other fixes (6746055, 6621697, 6756569, 6356642, 6761678).
  * Update IcedTea build infrastructure (20081111).
    - Fix freeze in midi app, LP: #275672.
    - Fixes in the IcedTeaPlugin: LP: #282570, LP: #282570, LP: #285729,
      LP: #291377, LP: #37330, LP: #239533.
    - Fix vertical text metrics with freetype scaler. LP: #289784.
  * Build-depend on ecj-gcj instead of ecj on architectures using
    gij/gcj as the bootstrap system.

 -- Matthias Klose <email address hidden> Tue, 11 Nov 2008 12:39:16 +0100

Changed in openjdk-6:
status: Fix Committed → Fix Released
Revision history for this message
Michael Nagel (nailor) wrote :

i reported a duplicate (line spacing too big in editor and log)

so for me it is not fixed yet... how could i determine if i have installed the proposed fix?

Revision history for this message
dms489 (dmsmith-dms489) wrote :

I have tried (from my amateur status) to implement all suggestions here, but the Netbeans IDE font spacing is still too big. I did the whole Ubuntu installation in the last couple of days. I can't agree that this is low priority. Netbeans is currently unusable for serious development. Is there an answer to Michael's question - is the a package I missd during the installation?

Revision history for this message
Chris Lasher (chris.lasher) wrote :

Can we please have this patch backported to Intrepid? It's been available for two months.

Revision history for this message
Mark Rowan (mark-tamias) wrote :

Seconded; a backport would be very much appreciated.

Revision history for this message
Sebastian Urban (surban) wrote :

Can we get a backport to Hardy, please?

Revision history for this message
getaceres (getaceres) wrote :

I've installed the openjdk 1.6b14 from PPA and the bug is still there. I get a huge space around text in Netbeans.

Revision history for this message
Carlos Ramos (carragom) wrote :

Using Intrepid x86_64, bug is still happening, any plans for a backport ?

Package: openjdk-6-jdk
Architecture: amd64
Version: 6b12-0ubuntu6

Revision history for this message
Ori Avtalion (salty-horse) wrote :

Using Jaunty amd64 I still see the problem.

openjdk-6-jre-headless 6b14-0ubuntu16
sun-java6-bin 6-12-0ubuntu1

See the attached screenshot

Revision history for this message
João Pinto (joaopinto) wrote :

The bug is not fixed.

Changed in openjdk-6:
status: Fix Released → Confirmed
Changed in openjdk:
status: Unknown → Fix Released
Revision history for this message
gerstrong (gerstrong) wrote :

No, it still isn't.

Matthias Klose (doko)
Changed in ttf-indic-fonts (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package openjdk-6 - 6b14-1.4.1-0ubuntu7

---------------
openjdk-6 (6b14-1.4.1-0ubuntu7) jaunty; urgency=low

  * Don't use some indian fonts with diverging font metrics for the
    latin-1.UTF-8 encoding. LP: #289784.
  * Disable running the testsuite for this build (no code changes compared
    to the previous upload).

 -- Matthias Klose <email address hidden> Tue, 14 Apr 2009 11:46:25 +0200

Changed in openjdk-6 (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

sequence.allfonts.UTF-8=latin-1,wqy-zenhei,japanese-vlgothic,japanese-kochi,japanese-sazanami,korean-un,korean-baekmuk,bengali,oriya,telugu,gujarati,hindi,punjabi,tamil

Run the attached test program, with and without LANG set to see the difference. Removing all of gujarati,hindi,punjabi,tamil does fix the problem. why did we add the sequence.allfonts.UTF-8 sequence at all?

is there something to fix in these fonts?

Revision history for this message
Michael Nagel (nailor) wrote :

@Matthias Klose: is this stuff about indic fonts really related to this bug? i dont see the relation yet...

Revision history for this message
Anivar Aravind (anivar) wrote :

I think it is an Rendering engine issue. Netbeans seems to have taken code from an Old Version of ICU .

Revision history for this message
Martijn van Iersel (martijn-vaniersel) wrote :

I don't think this is fixed. At least I still see this problem in openjdk-6 (6b14-1.4.1-0ubuntu7)

Michael Nagel (nailor)
Changed in ttf-indic-fonts (Ubuntu):
status: Confirmed → Invalid
Changed in ttf-indic-fonts (Ubuntu Hardy):
status: New → Invalid
Changed in ttf-indic-fonts (Ubuntu Intrepid):
status: New → Invalid
Revision history for this message
Matthias Klose (doko) wrote :

Michael, don't touch things if you don't care about them.

Changed in ttf-indic-fonts (Ubuntu):
status: Invalid → Confirmed
Changed in ttf-indic-fonts (Ubuntu Hardy):
status: Invalid → Confirmed
Changed in ttf-indic-fonts (Ubuntu Intrepid):
status: Invalid → Confirmed
Revision history for this message
Anivar Aravind (anivar) wrote :

Matthias,

This bug is not related to ttf-indic-fonts

It must be related to rendering engine used in OpenJDK. Can anyone
check the rendering engine
ttf-indic-fonts work well with current versions of pango, QT & ICU
without any problems. so it must be an issue with rendering engine
used in netbeans

Revision history for this message
Carlos Ramos (carragom) wrote :

I found a solution to this bug here
  https://bugs.launchpad.net/ubuntu/+source/openjdk-6/+bug/255983
just need to edit
  /etc/java-6-openjdk/fontconfig.properties
and change the line
  sequence.allfonts.UTF-8=latin-1,wqy-zenhei,japanese-vlgothic,japanese-kochi,japanese-sazanami,korean-un,korean-baekmuk,bengali,oriya,telugu
to
  sequence.allfonts.UTF-8=latin-1,wqy-zenhei,japanese-vlgothic,japanese-kochi,japanese-sazanami,korean-un,korean-baekmuk

This worked for me in Jaunty x86_64.

Revision history for this message
Michele Renda (mic-renda) wrote :

It really fix my problem. Thank you Carlos Ramos.

Revision history for this message
ZelinskiyIS (ivze) wrote :

Using jaunty 9.04 x86. After installing Netbeans, experienced the same issue: free space under text in different situations. The program code looked bad, if opened in NetBeans editor.

The workaround, suggested by Carlos Ramos, has worked for me! (My first language is Russian, so deleting these fonts from the list did not affect me)

Nevertheless, the bug stays unfixed...

Revision history for this message
pe3k (qyx) wrote :

The same here - suggestion made by Carlos Ramos fixed this problem for me - using Jaunty x86_64. Otherwise using openjdk after clean install makes it almost unusable (in my case with ImageJ). Bug isn't fixed.

Revision history for this message
Alex Valavanis (valavanisalex) wrote :

Intrepid Ibex reached end-of-life on 30 April 2010 so I am closing the
report. The bug has been fixed in newer releases of Ubuntu.

Changed in openjdk-6 (Ubuntu Intrepid):
status: Triaged → Invalid
Revision history for this message
Alex Valavanis (valavanisalex) wrote :

Intrepid Ibex reached end-of-life on 30 April 2010 so I am closing the
report. The bug is still marked as confirmed in later versions of Ubuntu.

Changed in ttf-indic-fonts (Ubuntu Intrepid):
status: Confirmed → Invalid
Changed in openjdk:
importance: Unknown → Medium
Revision history for this message
Rolf Leggewie (r0lf) wrote :

Hardy has seen the end of its life and is no longer receiving any updates. Marking the Hardy task for this ticket as "Won't Fix".

Changed in openjdk-6 (Ubuntu Hardy):
status: Triaged → Won't Fix
Rolf Leggewie (r0lf)
Changed in ttf-indic-fonts (Ubuntu Hardy):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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