Bug 23981 - cairo doesn't respect TrueType gasp tables (and fonts look ugly as a result)
cairo doesn't respect TrueType gasp tables (and fonts look ugly as a result)
Status: NEW
Product: cairo
Classification: Unclassified
Component: freetype font backend
1.9.3
Other All
: medium normal
Assigned To: David Turner
cairo-bugs mailing list
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-16 20:07 UTC by Nicholas Miell
Modified: 2011-06-25 10:32 UTC (History)
3 users (show)

See Also:


Attachments
Verdana Bold 15 pt, rendered correctly (25.30 KB, image/png)
2011-06-25 10:27 UTC, Nicholas Miell
Details
Verdana Bold 15 pt, rendered incorrectly (45.14 KB, image/png)
2011-06-25 10:32 UTC, Nicholas Miell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Miell 2009-09-16 20:07:52 UTC
TrueType fonts have a table called 'gasp' (Grid-fitting And Scan-conversion Procedure) which contains a list of font size ranges and some attributes that control how they should be rendered.

One such attribute is whether or not glyphs at specific sizes should be antialiased.

FreeType does not automatically apply the settings from the gasp table, instead the FreeType user must query the gasp table using FT_Get_Gasp() and then alter their behavior based on that result.

If this is not done, some fonts will be misrendered.

One such font is Verdana Bold. The hinting programs in Verdana Bold assume that sizes 9-16 will not be antialiased (as specified in the gasp table), thus when they query the global antialiasing boolean while being run on size 9-16 glyphs, the resulting hinting is incorrect and the K, N, V and W glyphs (among others) are misrendered.

See http://www.freetype.org/freetype2/docs/reference/ft2-gasp_table.html for more information. (Note that the gasp table also controls whether or not the bytecode should be interpreted at all, which probably also results in rendering errors, but I haven't noticed any.)
Comment 1 James Cloos 2009-09-17 06:47:13 UTC
Whether to honour the gasp suggestion and disable either antialiasing or
the bytecode interpreter at any given sizes should not be cairo's choice
but rather should be specified in the fontconfig settings, so that users
can choose for themselves what they prefer.

OTOH, on doze this suggestion makes some sense.
Comment 2 Behdad Esfahbod 2009-09-17 08:46:31 UTC
I'd rather FreeType do these by default, unless overriden by the user...
Comment 3 Nicholas Miell 2009-09-17 12:57:07 UTC
(In reply to comment #1)
> Whether to honour the gasp suggestion and disable either antialiasing or
> the bytecode interpreter at any given sizes should not be cairo's choice
> but rather should be specified in the fontconfig settings, so that users
> can choose for themselves what they prefer.
> 
> OTOH, on doze this suggestion makes some sense.
> 

The gasp table isn't a suggestion, it's a requirement. Fonts render incorrectly if the gasp table isn't followed.

As an end user, I would prefer my fonts to render correctly instead of incorrectly.

If you're suggesting that I should configure this manually in some fontconfig XML file for each font individually, I'm going to state right here that you are completely wrong.
Comment 4 Ben Laenen 2009-12-05 03:56:46 UTC
(In reply to comment #3)
> As an end user, I would prefer my fonts to render correctly instead of
> incorrectly.

In any case there should be a way to override the font's gasp table. I personally favour seeing the few badly antialiased glyphs than seeing them all as bitmapped.
Comment 5 Nicholas Miell 2009-12-05 10:38:53 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > As an end user, I would prefer my fonts to render correctly instead of
> > incorrectly.
> 
> In any case there should be a way to override the font's gasp table. I
> personally favour seeing the few badly antialiased glyphs than seeing them all
> as bitmapped.
> 

Antialiasing the font anyway but lying to the bytecode about whether the AA is being performed might be an interesting exercise. That can't be done at the cairo level, though.
Comment 6 Nicholas Miell 2011-06-25 10:27:52 UTC
Created attachment 48403 [details]
Verdana Bold 15 pt, rendered correctly
Comment 7 Nicholas Miell 2011-06-25 10:32:02 UTC
Created attachment 48404 [details]
Verdana Bold 15 pt, rendered incorrectly

Pay attention to the extra-fat N, V and W glyphs, as well as the subtle changes to the K, %, and many others.