Bug 16715 - [Gtk] Uneven glyph spacing with subpixel antialiasing
Summary: [Gtk] Uneven glyph spacing with subpixel antialiasing
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL: data:text/html,<div style="font-famil...
Keywords: Gtk
Depends on:
Reported: 2008-01-02 17:33 PST by Sylvain Pasche
Modified: 2008-01-11 18:23 PST (History)
1 user (show)

See Also:

screenshot showing verdana font (2.24 KB, image/png)
2008-01-02 17:33 PST, Sylvain Pasche
no flags Details
comparison webkit gecko (5.92 KB, image/png)
2008-01-04 04:08 PST, Sylvain Pasche
no flags Details
demonstrative hack (not for checkin) (828 bytes, patch)
2008-01-04 04:23 PST, Sylvain Pasche
no flags Details | Formatted Diff | Diff
Using font options from gdk screen (1.99 KB, patch)
2008-01-11 17:18 PST, Sylvain Pasche
alp: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pasche 2008-01-02 17:33:21 PST
I saw this initially on the gnome.org website when using the Gtk port. I have installed the msttcorefonts on the system, so I guess the Verdana.ttf font from there is used. I'll attach a screenshot.
Comment 1 Sylvain Pasche 2008-01-02 17:33:54 PST
Created attachment 18246 [details]
screenshot showing verdana font
Comment 2 Sylvain Pasche 2008-01-02 17:35:39 PST
On the screenshot, you can see that the "i" character is no centered between the "s" and the "m" for instance. The gap between the "p" and the "l" seems to large too.
Comment 3 Sylvain Pasche 2008-01-04 03:32:24 PST
Ok, this is not specific to Verdana font (but most visible with it at 14px).

Happens only when you have subpixel smoothing active (under GNOME in System > Preferences > Appearance > Fonts > Subpixel smoothing (LCD) ).
Comment 4 Sylvain Pasche 2008-01-04 04:08:23 PST
Created attachment 18261 [details]
comparison webkit gecko

Testcase: data:text/html,<div style="font-family: verdana;font-size: 14px">simply participating</div>

Webkit on top, gecko 1.9 on bottom
Comment 5 Sylvain Pasche 2008-01-04 04:23:42 PST
Created attachment 18262 [details]
demonstrative hack (not for checkin)

The attached patch fixes the issue (but will break in other situations).
Comment 6 Sylvain Pasche 2008-01-04 04:40:03 PST
Some explanations:

The scaled font needs a font_options_t object when it is created in FontPlatformData::FontPlatformData. The parameter in this font_options_t object should match the settings of the destination surface, like antialiasing, hinting and others.

For retrieving these settings, we need a surface (which can be obtained from the cairo_t object). The trouble is that we do not have the cairo_t object available yet when the scaled font is created. If we had it at this time, we could build the font_options object like:

    cairo_surface_t* target = cairo_get_target(cr);
    cairo_font_options_t* options = cairo_font_options_create();
    cairo_surface_get_font_options(target, options);

Comment 7 Sylvain Pasche 2008-01-11 17:18:35 PST
Created attachment 18401 [details]
Using font options from gdk screen

I found this gdk method to fetch the font option from a gdk screen.
Comment 8 Alp Toker 2008-01-11 18:20:05 PST
Comment on attachment 18401 [details]
Using font options from gdk screen


I'm making two small changes before landing this:


2) null-check for gdk_screen_get_default() so we don't break headless operation.
Comment 9 Alp Toker 2008-01-11 18:23:16 PST
Landed in r29426.