Closed Bug 11168 Opened 21 years ago Closed 20 years ago

[PP] Inconsistent/ugly TrueType font underlining on different platforms


(Core :: Layout, defect, P3)






(Reporter: dr, Assigned: dbaron)




(Whiteboard: fixed attached -- fix being checked in)


(5 files)

Underlined links in the font "Trebuchet MS," which is used on mozillaZine,
appear way too high up, almost as if intended as strike-through lines. This is
likely a symptom in other TrueType fonts as well. I am using RH6 default xfree
and xfs (w/truetype), but I don't believe those to be the problem since NC4.5
renders these links properly.
Assignee: troy → kipp
this may be a specific instance of a more generic bug having to do with
underlining fonts. see bug 11101 for what is possibly another case of the same

also unsure whether this is a linux/unix/xfree/x-specific bug (does it work ok
under windows, mac?...) in layout, or whether it would be better off in
Target Milestone: M11
Whiteboard: [MAKINGTEST]
Summary: ugly link underlining in trebuchet font → Ugly TrueType font underlining on Linux(*nix?)/X
Changing summary for a more accurate description :)

BTW, now might be a good opportunity to mention that not everybody has "verdana"
on their system, which seems to be the standard font for the apprunner ui... Is
there any proposed solution to either settle on a standard URW font or
distribute a font with the final browser product?...
arrgh, sorry. there may be a bugzilla bug -- the browser stalled when i hit
submit, and i thought the submission wasn't processed.
Target Milestone: M11 → M12
Actually, it looks like the underlines are too low on windoze as well. There is
some funky code in there that makes up the underline offset and its not clear
what it's doing...
Target Milestone: M12 → M15
OS: Linux → All
Hardware: PC → All
Summary: Ugly TrueType font underlining on Linux(*nix?)/X → [DOGFOOD] [PP] Inconsistent/ugly TrueType font underlining on different platforms
Again, changing the summary and platforms according to kipp's last comment, and
marking for platform parity and eating our own dogfood... Just curious why this
has been pushed back to M15 as well?...
Pushed out because it shouldn't interfere with beta.
Can I get a copy of the offending font? My PC's at home don't have it :-(

I can't reproduce the sheer uglyness of your attachments without out :-)
Trebuchet MS (as well as Verdana and a bunch of others) are all Microsoft "web
core fonts" which you can find at Unfortunately, they're
only compressed as mac stuffit or pc self-installers, but if you can grab the
.ttf files out of them somehow (and run a truetype font server on your linux
box) that should work for you just fine...

The only thing that comes to mind is, perhaps the font server isn't behaving
well... but I doubt that since it renders underlines in the same fonts in Nav4
just fine :)
I believe the underline is drawn by Mozilla, not the font server.  I don't know
if that was true in 4.x.

Actually, NN 4.x has serious problems dealing with correctly served (xfsft) TT
fonts (as opposed to TT fonts served by xfstt, which I believe have some metrics
Summary: [DOGFOOD] [PP] Inconsistent/ugly TrueType font underlining on different platforms → [PP] Inconsistent/ugly TrueType font underlining on different platforms
[DOGFOOD] designation removed.
Is there actually a problem here on Win?  I've never seen it, although kipp
commented about underlines being too low.  Or is this just a Linux bug?
Wow, we really need to get our story straight.

Okay, here's the problem I noticed originally: The font underlining on the linux
platform in the Trebuchet MS and Verdana typefaces was way too high up, almost
as high as the line in strike-through text. Kipp then mentioned that underlines
seemed too low on Windows, so I changed the summary to "inconsistent across
different platforms" rather than specific to linux.

I don't have access to a Linux box at this moment, so I can't comment. On Win32
I have noticed the underlining is a tiny bit low (which makes menu items
uncomfortably wide from a UI perspective) and the same on Solaris, when it
manages to build ;-)

If somebody has access to a Linux box, put the MS "core web fonts" I mentioned
on it, and run apprunner. If it comes out looking like the first two screenshots
attached to this bug (note: NOT the third, because that's with helvetica
substituted for trebuchet) then it is still broken. And M17 isn't the right
milestone for this bug. If it comes out looking okay (screenshots baby!) then
resolve it as fixed.

Ooh yeah.
Perhaps this bug should be only for the problem of underlines being too high
(Linux), and the bug for too low (less serious) should be separate?
Target Milestone: M17 → M12
The fix for this is painfully simple.  It's one character: "-".  I'm changing
the milestone to M12 and I'll attach the fix.

cc:ing erik, since he owns the code (I think - I didn't actually check cvs blame
or anything).
Whiteboard: [MAKINGTEST] → fix attached [MAKINGTEST]
BTW, the reason this wasn't much more obvious (when the code was written, I
guess) was that it only affected TrueType/Postscript fonts since other fonts
don't have built-in underline offset information.
I just realized - one other reason this might not have been noticed is that
either xfstt or xfsft is returning the negative of what it should be.  Someone
who is using xfstt should check that this patch works OK.  (Both people who
claim to have seen it use xfsft, which comes with RH 6.0.)  If the two font
servers are returning negatives of each other, then you'll just need to use an
absolute value (or negative thereof).

(However, it also could be that xfstt doesn't return the info at all, and
therefore the other code path is used...)
Whiteboard: fix attached [MAKINGTEST] → fix attached
Kipp, did you see this bug when you got the fonts installed?  (Since you have
xfstt, that'll answer my question in my previous comment.)
OK... I switched my font server to xfstt, and it xfstt doesn't return underline
offset information (by using the printf in the code right below my fix).  That's
why this bug shows up only with xfsft.  This also means the fix shouldn't have
any effect on xfstt.

I don't have any postscript fonts with AFM's (I assume that's what you mean by
"afm fonts"), so I can't check those.  Pavlov, you wrote the comment about "afm
fonts" - did you ever test them with underlines, or did you find out from
someone else that the code was being used for afm fonts?

Anyway - I think this fix should be checked in soon unless someone has PS fonts
with AFM's and sees a problem...

I'll attach a revised patch with the comment corrected!
If you search for XA_UNDERLINE_POSITION in;cd=2
, it's clear that the UnderlineOffset should be returned as a positive number
(and it's not an xfsft bug).  (I think in Windows it should be returned as a
negative number, since there's no minus sign in the Windows code).  Mozilla
seems to be using it as though it should be negative.  (Unless the bug is really
somewhere else - i.e., the font rendering code...)
To answer my previous parenthetical comment, nsTextFrame::PaintTextDecorations
clearly assumes that the underline offset is negative, since it subtracts
(lowers) it from the vertical position of the top of the underline.  And,
furthermore, it's XP code.
Assignee: kipp → pavlov
taking bug since kipp doesn't work here anymore
Mass-moving non-PDT+ bugs to M13
By the way, I'm not even positive this is a truetype bug at all... I get the
same problem on Solaris (these systems do not have truetype, to my knowledge)
with text styled through CSS as sans-serif, italic. This may be a problem with
standard URW fonts then, also. If somebody applies the fix attached, I could
verify it quickly and have this bug be a distant memory far before M13 rolls
around... Any takers?
It's a problem with any fonts that claim to have metrics for underline offset
info (which many do not).

Pavlov, could this be checked in?  It's one character...
Whiteboard: fix attached → fixed attached -- fix being checked in
looks good to me
Assignee: pavlov → dbaron
Assigning to self, since I just checked in the fix (2000-01-11 18:24PST).
Closed: 20 years ago
Resolution: --- → FIXED
BTW, does anyone else see any problems with the underline metrics guessing code
on other platforms?  It's certainly fine on Unix.  Kipp made some vague comments
about it on windows, but I would guess that Windows is using metrics from the

But marking fixed (see previous comment), since the main point of this bug is
fixed, and it's not clear if there are any other bugs.  (There's only a comment
from Kipp that he thought the underline on Windows was too low.  However, the
underline metrics for the particular font involved (Trebuchet) are low, which is
why they looked so bad when reversed in sign.)
Works fine in the Feb 01 build. Marking verified fixed.
You need to log in before you can comment on or make changes to this bug.