Eyes Above The Waves

Robert O'Callahan. Christian. Repatriate Kiwi. Hacker.

Monday 24 September 2007

Textalicious

Some of the last major pieces of text work for Gecko 1.9/Firefox 3 are in place. Several days ago I landed a patch that sets text-rendering:optimizeLegibility for text inputs and XUL root elements (by default, it will inherit to the descendants of XUL root elements too). This means we automatically get high-quality mode (ligatures, kerning etc) for text in XUL documents (e.g., XUL application UI) and text inputs.

Today I landed another patch to compute accurate glyph bounds for all text in high-quality mode. This means dynamic changes to such text should redraw correctly even for fonts with glyphs that extend outrageously far outside the font ascent, descent, etc. Here's a demo ... this textarea requests Zapfino and DejaVu Sans; so it will work best on Macs, which have Zapfino preinstalled, but there should also be an "fi" ligature on Linux systems that have a recent version of DejaVu Sans installed. (I'm not sure what fonts to request for Windows, please advise!) Try selecting and editing around a ligature. Of course you will need a Firefox trunk build as of a few hours ago. If you have Zapfino, for a good time try entering "Zapfino" :-). It might not work in feeds or other contexts that sanitize content.



Ideally, we would enable accurate glyph bounds for all text, not just high-quality text, because without those bounds there can be repaint bugs even in "normal" text (e.g., the tail of italic j in many fonts extends beyond the left edge of the character cell). What we're doing here is a compromise so that we don't eat the performance cost of getting glyph extents for all text. (See my Glyph Bounds Problem post for more details.) However, at some point we should do some measurements to see exactly what the performance cost of turning it on always would be.

Similarly, we should also measure the performance cost of turning on high-quality text rendering always.


Update Added Segoe Script to the textarea for Vista users.

Comments

dria
This is exceedingly cool. Playing with the text above, however, I noticed a couple of things. First, if you type Zapfino, for example, on three successive lines, the top part of the ligature of the F (that extends up into the line above) doesn't get rendered. Also, if you type a bunch of stuff then backspace over it, not every part of each letter gets erased -- I'm not sure if it's the extra ligature bits that are getting left behind or not, but it might be the case.
dria
I just realized that i may not, in fact, have the correct version of Firefox. If this stuff hasn't been fixed on the latest nightly (as of about half an hour ago), then feel free to delete my comment :)
shaver
It's like a painting, right there with my caret. *swoon*
alex.r.
I don't have Zapfino installed but with DejaVu Sans the partial glyph selection is impressive.
On Windows, just about any of the default variable width font (Tahoma, Srial...) have an fi ligature but it doesn't seem to get substituted when I use it in a text box.
Vladimir Vukicevic
Try "Segoe Script" for Windows, at least for Vista.
Robert O'Callahan
dria: it sounds like you have an old build.
I'll add Segoe Script to the demo.
Robin
I hadn�t seen Zapfino�s trailing-e/fullstop combo before :) Great to see this sort of ligature support becoming a reality!
Asrail
With Deja Vu,
'ft' sometimes got the ligatures, sometimes doesn't (try varying the size).
Is that normal?
Robert O'Callahan
Asrail: I don't know. Could be a Pango issue.
Jesse Ruderman
When I loaded this blog entry in a background tab, Firefox crashed. I saw the same assertions as in bug 397007.
Jesse Ruderman
Safari 2 uses Zapfino's ligatures in the textarea, but Safari trunk doesn't. Odd to see Safari and Gecko moving in opposite directions.
Robert O'Callahan
They deliberately avoid ligatures etc for performance.