Wednesday Mar 16, 2011

Fixed-width Font Widened on Bold

So here is a screenshot of a JDK source file I am working on now, in NetBeans:

It seems there is an extra space before the "// ok" comment on line 52 which makes the comments non-aligned. So I removed it. But then when I read the diff, it shows:

@@ -49,7 +49,7 @@
      \* Constructs an AS-REQ message.
      \*/
                                                 // Can be null? has default?
-    public KrbAsReq(EncryptionKey pakey,        // ok
+    public KrbAsReq(EncryptionKey pakey,       // ok
                       KDCOptions options,       // ok, new KDCOptions()
                       PrincipalName cname,      // NO and must have realm
                       PrincipalName sname,      // ok, krgtgt@CREALM
Bad, so they were aligned, but after my change, they are not.

I am really confused by this. Is there anything wrong with the hg repository? or the diff command? or my console? Or, is there a hidden TAB character? I checked and checked but nothing seems wrong.

Finally I have to count the spaces one by one. Good heavens! It turns out that the font used in NetBeans — Lucida Sans Typewriter — has different widths between normal and bold typefaces.

Isn't this ridiculous? A fixed-width font's width should be fixed whenever it's shown in normal, or bold, or italic. I believe all modern IDEs use these styles to show different types of source tokens.

Anyway, I changed the font to the simple "monospaced" and everything looks normal now. Maybe the Lucida Sans Typewriter font is not fixed-width at all, it just looks like one.

About

This blog has a comments managing system that requires me to approve each comment manually. Please do not re-post and I will reply it (if I have an answer) when I get pinged.

Search

Top Tags
Categories
Archives
« March 2011 »
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
15
17
19
20
22
23
24
25
26
27
28
29
30
31
  
       
Today