[Development] Font rendering on X11/Wayland: New FreeType API to toggle LCD filters and stem darkening on a per-font basis, would love a review

Nikolaus Waxweiler madigens at gmail.com
Sun Nov 20 14:50:38 CET 2016


> Anyway, on the API front. Forcing to autohinter is probably not acceptable. So 
> we could enable stem darkening where native available, but then we need to 
> know if what engine a face is using, or better yet specifically if the engine 
> used right now on this face did stem darkening.

I was just thinking. Can Qt mix font rendering modes on a face-by-face
basis? Even without FT_Face_Option(), you can query the font driver  for
a face and the autohinter for stem darkening as described in [1]. If
FT_Property_Get returns an error for the property, the driver has no
means of darkening stems at all. Note that this is a font
driver/autohinter wide setting, affecting all faces that pass through them.

So, how about something like this: for each face that should be
rendered, first query the driver (or the autohinter if it's to be used)
if it supports stem darkening. If so, turn it on while rendering the
face and use linear alpha blending and gamma correction (maybe with a
factor of 1.8 like Adobe recommends). If there is no stem darkening
support, blend naively. Or: also blend correctly, but use a lower gamma
correction factor (e.g. 1.4 like GDI uses iirc).

As it stands, this would only enable correct rendering for .otf and if
the autohinter is involved. Support for more font drivers could then be
done from within FreeType without source modifications in Qt.

[1]:
https://www.freetype.org/freetype2/docs/reference/ft2-cff_driver.html#no-stem-darkening(cff)
-- Use FT_Property_Get instead, obviously.



More information about the Development mailing list