This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194676 - Bad font rendering
Summary: Bad font rendering
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: 7.0
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-25 00:15 UTC by yuriy_lalym
Modified: 2012-10-30 14:46 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NetBeans vs KWrite (141.99 KB, image/png)
2011-01-25 00:22 UTC, yuriy_lalym
Details
Font Monaco (92.92 KB, image/png)
2011-01-25 00:38 UTC, yuriy_lalym
Details
Font Lucida Sans Typewriter (48.71 KB, image/png)
2011-01-25 00:41 UTC, yuriy_lalym
Details
Regular editor rendering (40.54 KB, image/png)
2011-01-27 09:35 UTC, Miloslav Metelka
Details
Editor rendering without applying rendering hints in DocumentView (21.28 KB, image/png)
2011-01-27 09:36 UTC, Miloslav Metelka
Details
At the left Netbeans, on the right KWord (132.34 KB, image/png)
2011-01-27 22:05 UTC, yuriy_lalym
Details
Below NetBeans on top Kwrite (31.63 KB, image/png)
2011-01-27 22:24 UTC, yuriy_lalym
Details
NetBeans, KWrite, LibreOffice (From top to down). Font: consolas (in NetBeans size 15) (491.40 KB, image/png)
2011-01-30 00:04 UTC, yuriy_lalym
Details
Liberation Mono face (38.54 KB, image/png)
2011-01-30 09:20 UTC, yuriy_lalym
Details
and size 12 (74.06 KB, image/png)
2011-01-30 09:32 UTC, yuriy_lalym
Details
Lucida Sans Typewriter on Mac (68.74 KB, image/jpeg)
2011-02-04 21:27 UTC, cabbey
Details
Sample swing app for extra hints (1.95 KB, text/plain)
2011-02-16 12:54 UTC, Miloslav Metelka
Details
There is a riddle a difference from ms windows (186.91 KB, image/png)
2011-02-18 01:12 UTC, yuriy_lalym
Details
-J-Dorg.netbeans.editor.aa.extra.hints=true with JDK-1.7 - quite good combination (352.39 KB, image/png)
2011-03-05 22:08 UTC, yuriy_lalym
Details
R U N FA I LED (exi t val ue 1, t ot al ti m e: 233m s) (6.74 KB, image/png)
2011-12-20 20:32 UTC, yuriy_lalym
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yuriy_lalym 2011-01-25 00:15:46 UTC
The font very thin also isn't present any smoothing (antialiasing).
Comment 1 yuriy_lalym 2011-01-25 00:22:41 UTC
Created attachment 105325 [details]
NetBeans vs KWrite

NetNeans is launched with options
-J-Dawt.useSystemAAFontSettings=lcd --laf GTK

Font - Liberation Mono 15

///

KWrite
Font - Liberation Mono 12

~/.fonts.conf

<?xml version='1.0'?>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="pattern">
  <edit mode="assign" name="autohint">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="lcdfilter">
   <const>lcddefault</const>
  </edit>
 </match>
 <match target="font">
  <test compare="more" name="weight">
   <const>medium</const>
  </test>
  <edit mode="assign" name="hintstyle">
   <const>hintmedium</const>
  </edit>
 </match>
 <dir>~/.fonts</dir>
</fontconfig>
Comment 2 yuriy_lalym 2011-01-25 00:38:07 UTC
Created attachment 105326 [details]
Font Monaco
Comment 3 yuriy_lalym 2011-01-25 00:41:16 UTC
Created attachment 105327 [details]
Font Lucida Sans Typewriter
Comment 4 Miloslav Metelka 2011-01-27 09:34:45 UTC
The text is definitely antialiased (I attach noaa editor text once applying of rendering hints in DocumentView to the Graphics would be switched off).
We could experiment with various rendering hints to see whether it would make any effect:
http://download.oracle.com/javase/tutorial/2d/advanced/quality.html
 But generally the rendering in KWrite is different - looks more like a bold font though their bold is even a bit "bolder" ;-)
Comment 5 Miloslav Metelka 2011-01-27 09:35:36 UTC
Created attachment 105395 [details]
Regular editor rendering
Comment 6 Miloslav Metelka 2011-01-27 09:36:19 UTC
Created attachment 105396 [details]
Editor rendering without applying rendering hints in DocumentView
Comment 7 yuriy_lalym 2011-01-27 22:05:06 UTC
Created attachment 105421 [details]
At the left Netbeans, on the right KWord

Font: Liberation mono 24, 22, 20, 18, 17 (from top to down for NetBeans).

Passage with 24 on 22 (20, 18) does very thin all horizontal dashes. Look at letters "B" and "r". 
Passage with 18 on 17 sharply changes a thickness and vertical dashes.

Compare with KWrite.
Comment 8 yuriy_lalym 2011-01-27 22:24:29 UTC
Created attachment 105422 [details]
Below NetBeans on top Kwrite

Below NetBeans on top Kwrite

return app.exec (); - it is combined ideally. The distance between lines at NetBeans is less and noticeably less.
Comment 9 yuriy_lalym 2011-01-30 00:04:23 UTC
Created attachment 105475 [details]
NetBeans, KWrite, LibreOffice (From top to down). Font: consolas (in NetBeans size 15)

In a word "Browser" letters "o" and "w" are written without a gap.
You use too aggressive hinting, and don't allow a method to reduce its level.
Comment 10 yuriy_lalym 2011-01-30 09:10:41 UTC
(In reply to comment #4)

>  But generally the rendering in KWrite is different - looks more like a bold
> font though their bold is even a bit "bolder" ;-)

1.
No, in KWrite "Liberation Mono" - looks like a true. 
http://www.dafont.com/liberation-mono.font
http://www.fontsquirrel.com/fonts/Liberation-Mono

2.
http://en.wikipedia.org/wiki/File:Font_Comparison_-_Liberation_Mono_to_Courier_New.svg

In NetBeans "Liberation Mono" and "Courier New" (size < 18) have an identical thickness.

3.
http://bugzilla-attachments-194676.netbeans.org/bugzilla/attachment.cgi?id=105421
Look attentively at distance between letters "k" and "R". The third and fourth line on top - they have almost faced.
Comment 11 yuriy_lalym 2011-01-30 09:20:28 UTC
Created attachment 105485 [details]
Liberation Mono face
Comment 12 yuriy_lalym 2011-01-30 09:32:04 UTC
Created attachment 105486 [details]
and size 12
Comment 13 cabbey 2011-02-04 21:27:12 UTC
Created attachment 105664 [details]
Lucida Sans Typewriter on Mac

This is not limited to Linux, the same font on os/x renders even worse.
Comment 14 Miloslav Metelka 2011-02-16 12:53:39 UTC
To cabbey #13: that's a separate issue. Please add to netbeans.conf:
-J-Dapple.awt.graphics.UseQuartz=false
(see http://blogs.sun.com/tor/entry/lcd_sub_pixel_rendering )

I've added some extra debugging info regarding AA attributes of FontRenderContext which shows that AA is on. Available with
-J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE
in netbeans.conf.

I've made a simple swing program that shows that on my Ubuntu 10.10 it helps to add the following hints in order to get bolder Liberation Mono font:

        myHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        myHints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

However imho it does not look very well at least on my system. Anyway if you want to turn on the extra hints please add the following to netbeans.conf:

-J-Dorg.netbeans.editor.aa.extra.hints=true

We could also try to override the default AffineTransform of FontRenderContext but I'll do some more research before trying that.

http://hg.netbeans.org/jet-main/rev/5203cdaabebc
Comment 15 Miloslav Metelka 2011-02-16 12:54:36 UTC
Created attachment 106063 [details]
Sample swing app for extra hints
Comment 16 yuriy_lalym 2011-02-18 01:07:04 UTC
(In reply to comment #14)
With an option "-J-Dorg.netbeans.editor.aa.extra.hints=true" is even worse.
Comment 17 yuriy_lalym 2011-02-18 01:12:43 UTC
Created attachment 106132 [details]
There is a riddle a difference from ms windows

Font (everywhere) Liberation Mono 15
Comment 18 yuriy_lalym 2011-02-18 01:37:56 UTC
(In reply to comment #17)

The same version Netbeans and Java - and fonts are drawn on a miscellaneous. It as a riddle. And drawing of a font by system in Linux is better than at Microsoft. Well if nevertheless this problem proceeds from Java - then probably and remains.
Comment 19 yuriy_lalym 2011-02-18 07:12:23 UTC
(In reply to comment #18)

Essence of problem not in that in Netbeans for Windows of letter have a large thickness, and in that in "Netbeans for Windows" of letter correspond to the system tuning (letters are displayed exactly as well as in Notepad or Notepad++ or Kate for Windows).

In Windows 7 it is possible to change tuning of "Clear Type". I can influence, that letters were displayed by hair-lines. And in all applications, including Netbeas, letters will be displayed identically - thinly.

In Linux the function getDesktopProperty("awt.font.desktophints") takes properties from desktop, but obviously not from my desktop.
Comment 20 Miloslav Metelka 2011-02-21 16:10:51 UTC
I think I can't do more with this so I'm closing the issue. Java renders the font thin due to truetype hinting appropriate for the given font size (KWrite for some reason doesn't) and NB can hardly improve the situation - thus I mark it as invalid.
 Anyway Yuriy if you find e.g. any rendering hints combination that would improve the rendering I'm willing to change the code for -J-Dorg.netbeans.editor.aa.extra.hints=true
to support that.
Comment 21 yuriy_lalym 2011-03-05 22:08:52 UTC
Created attachment 106755 [details]
-J-Dorg.netbeans.editor.aa.extra.hints=true with JDK-1.7 - quite good combination 

With JDK-1.7

At the left: -J-Dawt.useSystemAAFontSettings=on

On the right: -J-Dorg.netbeans.editor.aa.extra.hints=true

Above font Consolas 15. Letters "ow" - (ot the right) don't stick together.

Below font Liberation Mono 15. On the right letters "x" and "w" are drawn more accurately. On the right distance between letters uniform (at the left the last letter "r" as though is torn off from a word).

At least against a dark background, the text on the right looks better.
Comment 22 rnyberg 2011-04-18 11:30:56 UTC
I'd say this is pretty far from resolved and invalid: http://dl.dropbox.com/u/2188345/netbeans_font_problem.png
Comment 23 Milutin Kristofic 2011-09-19 11:07:07 UTC
Rnyberg, your link is not working. Back to resolved-invalid state.
Comment 24 yuriy_lalym 2011-12-17 15:30:31 UTC
Eclipse the same a java based application. But letters in eclipse are drawn according to system adjustments. Java - doesn't concern a problem.
Comment 25 yuriy_lalym 2011-12-20 20:32:35 UTC
Created attachment 114371 [details]
R U N  FA I LED (exi t  val ue  1,  t ot al  ti m e:  233m s)

SolStudio 12.3
Comment 26 Miloslav Metelka 2012-10-30 14:21:12 UTC
(In reply to comment #25)
> Created attachment 114371 [details]
> R U N  FA I LED (exi t  val ue  1,  t ot al  ti m e:  233m s)
> 
> SolStudio 12.3

I guess that's an output window which is not NB editor based.
Comment 27 Miloslav Metelka 2012-10-30 14:46:48 UTC
(In reply to comment #24)
> Eclipse the same a java based application. But letters in eclipse are drawn
> according to system adjustments. Java - doesn't concern a problem.

Please see http://wiki.netbeans.org/FaqFontRendering
"The difference between Eclipse and NetBeans font appearance follows from the fact that Eclipse uses swt which uses native font rendering while Swing does not."

I think that there are no more things that I can improve in terms of this issue (of course I'll continue to fix individual issues in the view hierarchy and improve it overall) so I close the issue. The font rendering in java-swing apps will probably continue to be a bit different than in other apps but I can hardly influence that.