[webkit-dev] Font kerning/advancement issues

Refstrup, Jacob Grundtvig jacob.refstrup at hp.com
Wed Jul 22 16:32:02 PDT 2009


I'm using Qt[4.5.0]/WebKit[trunk] on Linux and I'm running into a kerning/advancement problem.

I need to produce rasters for printing [1] at 600dpi; but the results don't look too good [2]. I suspect this is due fonts being selected at 96dpi (the coordinate space in which WebKit operates) and then later being scaled up. If you change the WebCore::cssPixelsPerInch constant to 600.0 and do a few other little tweaks you get a nice looking result [3].

My problem is I need to both display pages on screen and print them so I can't just go and change this constant to 600.0 'cos then my screen fonts would look all bad.

I tried printing [1] with a number of different WebKit based browsers:-
- Safari on Mac prints out beautifully
- Safari on Windows has kerning issues if font smoothing is set to "Windows Standard"
- Chrome (Windows) has kerning issues.

One way of solving this problem will be to dynamically change WebCore::cssPixelsPerInch but I'm not keen on that as that's bound to have some bad consequences. Another option is to deal with this in WebCore::Font (so probably in FontQt.cpp) and have it select the font based on the physical dpi (600) rather then the layout dpi (96) and then scale any metrics returned.

I suspect that it work on Mac 'cos the font-engine there is smart enough to select the font at the physical dpi but return metrics in logical dpi.

Other ideas for how to solve this?

Kind regards,
- Jacob

[1] http://refstrupalvear.net/webkit/qt/kerning/dpidemo.html
[2] http://refstrupalvear.net/webkit/qt/kerning/webkit-print-96dpi.png
[3] http://refstrupalvear.net/webkit/qt/kerning/webkit-print-600dpi.png

More information about the webkit-dev mailing list