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 191571 - Underscore character not rendered properly for certain fonts
Summary: Underscore character not rendered properly for certain fonts
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: -S1S-
Hardware: PC Linux
: P2 normal with 1 vote (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-02 18:49 UTC by Miloslav Metelka
Modified: 2011-09-16 07:49 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screenshot with DejaVu Sans font-size 13 (43.45 KB, image/png)
2010-11-16 11:00 UTC, tufan
Details
screenshot with DejaVu Sans font-size 12 (38.55 KB, image/png)
2010-11-16 11:00 UTC, tufan
Details
Screenshot of DejaVu Sans 12 with underscores visible (11.32 KB, image/png)
2010-11-16 21:01 UTC, Miloslav Metelka
Details
messages.log for nightly-201107190600 (26.17 KB, text/x-log)
2011-07-20 10:25 UTC, pevik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miloslav Metelka 2010-11-02 18:49:33 UTC
NetBeans IDE Dev 101013; Mac OS X 10.5.8
When using Monospaced-plain-12 the underscore character is only partially rendered when moving cursor down among lines.
Comment 1 Miloslav Metelka 2010-11-02 19:10:52 UTC
The problem is that TextLayout.draw() used for rendering requires ascent to be added to y coordinate.
However for certain fonts e.g. Monospaced 12 Plain the ascent is fractional:

Font: java.awt.Font[family=Monospaced,name=Monospaced,style=plain,size=12]
Size2D: 12.0, Line-height=12.0, ascent=9.046875, descent=2.953125, leading=0.0
Char-width=7.0, underlineOffset=0.6666667
FontMetrics (for comparison): fm-line-height=12, fm-ascent=9, fm-descent=3

The rendering system (although generally supporting float measurements) does not handle the situation well and the underscore gets rendered incorrectly roughly one pixel down than it should be.

I have added floor-ing of the ascent so that it should render well.

http://hg.netbeans.org/jet-main/rev/e82e77b46e47
Comment 2 Miloslav Metelka 2010-11-02 19:12:52 UTC
The problem is that TextLayout.draw() used for rendering requires ascent to be added to y coordinate.
However for certain fonts e.g. Monospaced 12 Plain the ascent is fractional:

Font: java.awt.Font[family=Monospaced,name=Monospaced,style=plain,size=12]
Size2D: 12.0, Line-height=12.0, ascent=9.046875, descent=2.953125, leading=0.0
Char-width=7.0, underlineOffset=0.6666667
FontMetrics (for comparison): fm-line-height=12, fm-ascent=9, fm-descent=3

The rendering system (although generally supporting float measurements) does not handle the situation well and the underscore gets rendered incorrectly roughly one pixel down than it should be.

I have added floor-ing of the ascent so that it should render well.

http://hg.netbeans.org/jet-main/rev/e82e77b46e47
Comment 3 tufan 2010-11-03 15:02:20 UTC
(In reply to comment #2)
> I have added floor-ing of the ascent so that it should render well.

...still have the problem with various Fonts on Ubuntu 10.04. The fix didn't work for me.
Comment 4 Miloslav Metelka 2010-11-03 15:12:12 UTC
Can you be more precise and specify problematic font and describing the steps to reproduce?
Also you may run with 
  -J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE
in netbeans.cfg and mention the output (similar to what I've provided) so that it's clear what's the ascent size etc. Thanks.
Comment 5 tufan 2010-11-04 10:03:37 UTC
(In reply to comment #4)
> Can you be more precise and specify problematic font and describing the steps
> to reproduce?

ok. sorry. fonts I tried out and which do not render underscores at all : 

DejaVu Sans (All variations)
DejaVu Serif (All variations)
Dialog
Monospaced
SansSerif
Serif

It seems, line height is 1-2px lower than the font-height in these cases. To reproduce; just change the default font for all languages in Tools -> Options -> Fonts & Colors menu. 

> Also you may run with 
>   -J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE

this did not help.

As I mentioned in my previous comment; I work on Ubuntu 10.04 with the actual dev-build (currently #2497)

> ... and mention the output (similar to what I've provided) so that
> it's clear what's the ascent size etc. Thanks.

sorry, I couldn't understand this step?
Comment 6 Miloslav Metelka 2010-11-10 13:01:16 UTC
tufan did you try on a recent dev build?
I have re-tested several fonts (DejaVu Sans, Dialog and Monospaced) in various sizes (10, 12, 14 and 18) on my Ubuntu 10.04 and there was no problem with underscore rendering.
If you can still reproduce please specify an exact font and possibly attach a screenshot.

Regarding
  -J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE
in netbeans.cfg
it only outputs an additional information regarding view hierarchy's font usage to the console. It won't alter behavior of the IDE.
Comment 7 tufan 2010-11-16 11:00:17 UTC
Created attachment 103002 [details]
screenshot with DejaVu Sans font-size 13
Comment 8 tufan 2010-11-16 11:00:41 UTC
Created attachment 103003 [details]
screenshot with DejaVu Sans font-size 12
Comment 9 tufan 2010-11-16 11:02:38 UTC
(In reply to comment #6)
> tufan did you try on a recent dev build?

yes, I'm currently working with the most recent dev-build. 

> I have re-tested several fonts (DejaVu Sans, Dialog and Monospaced) in various
> sizes (10, 12, 14 and 18) on my Ubuntu 10.04 and there was no problem with
> underscore rendering.
> If you can still reproduce please specify an exact font and possibly attach a
> screenshot.

attached 2 screenshots, which illustrate the rendering with DejaVu Sans 12 and 13. If fontsize=14 is choosen, rendering seems to be correct.
Comment 10 Miloslav Metelka 2010-11-16 21:00:12 UTC
I've tested on Ubuntu 10.04 with DejaVu Sans 12 and it seems correct (screenshot attached). However it came to my mind that your particular case could happen if there would be a mixture of several fonts and DejaVu would be non-default font. I've entered issue 192035. Let me fix it first and then we will verify whether it fixes your case or not.
 In the meantime could you please check whether Tools->Options->Fonts&Colors->Syntax->Default is DejaVu Sans 12? Or could you send me zipped content of your $userdir/config/Editors?
Comment 11 Miloslav Metelka 2010-11-16 21:01:38 UTC
Created attachment 103021 [details]
Screenshot of DejaVu Sans 12 with underscores visible
Comment 12 pevik 2011-06-28 11:53:09 UTC
Hi there, I suffer the same problem as tufan on both netbeans 7.0 and netbeans netbeans-dev-201106260600 from nightly/latest. I have also tried both to run with -J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE added to bin/netbeans startup script.

$ java -version 
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.7) (6b18-1.8.7-4)
OpenJDK 64-Bit Server VM (build 16.0-b13, mixed mode)

OS: Debian GNU/Linux testing/unstable.
Comment 13 Miloslav Metelka 2011-06-30 13:30:44 UTC
pevik, could you please attach your messages.log (when you were running with -J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE)?
Thanks.
Comment 14 Miloslav Metelka 2011-07-11 13:09:06 UTC
Could you please try to reproduce the problem on a newest dev build from http://bits.netbeans.org/download/trunk/nightly/latest/
(I would like to know whether issue #197534 fixed this problem or not). Thanks.
Comment 15 pevik 2011-07-20 10:25:46 UTC
Created attachment 109527 [details]
messages.log for nightly-201107190600

(In reply to comment #13)
> pevik, could you please attach your messages.log (when you were running with
> -J-Dorg.netbeans.modules.editor.lib2.view.DocumentView.level=FINE)?
> Thanks.
Attaching log for lastest dev (netbeans-trunk-nightly-201107190600-ml-php-linux.sh). Problem still occurres :(.
Comment 16 pevik 2011-09-16 07:49:57 UTC
Seems to be fixed in devel versions (201109120600, 201109120600) as well as in 7.0. Sound strange, because the only thing I changed was started it once with JRE from Sun/Oracle (1.6.0_26) and since then it's working with OpenJDK (1.6.0_23) as well.