ScreenFontSettings

Introduction

This pages lists the dynamic font settings used by several software components in free desktops like GNOME.

This page is the result of some investigation when trying to introduce the new Freetype LCD filtering in the software stack. It is a bit GNOME biased, please complete with information from other desktops.

The purpose is to see what components need to be modified when introducing a new configuration parameter, like the type of lcd filtering.

GNOME dynamically changeable parameters

These are the settings that can be changed using the Fonts tab of the gnome-appearance-properties tool of gnome-control-center:

Xrm settings

These are the settings libXft introduced to specify font options using the Xrm database. Other libraries like Cairo also read some of these settings.

These values are all string from the point of view of the Xrm database. Constants are converted to ints using fontconfig FcNameConstant. This means the set of possible string constants matches the ones from fontconfig, which are described below.

Settings read by both Cairo and libXft:

Xft.antialias:  (bool)// FC_ANTIALIAS Whether glyphs can be antialiased
Xft.dpi:        (double)// FC_DPI  Target dots per inch
Xft.hinting:    (bool)// FC_HINTING  Whether the rasterizer should use hinting
Xft.hintstyle:  (int) // FC_HINT_STYLE Automatic hinting style
Xft.rgba:       (int) // FC_RGBA unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry
Xft.lcdfilter   (int) // FC_LCD_FILTER type of lcd filter to use

Settings specific to libXft:

Xft.scale (double) // FC_SCALE
Xft.render (bool) // XFT_RENDER
Xft.embolden (bool) // FC_EMBOLDEN true if emboldening needed
Xft.autohint (bool) // FC_AUTOHINT Use autohinter instead of normal hinter
Xft.minspace (bool) // FC_MINSPACE use minimum line spacing
Xft.maxglyphmemory (int) // XFT_MAX_GLYPH_MEMORY 

These ones seem to be unused?
Xft.core (bool) //  XFT_CORE
Xft.xlft (string) // XFT_XLFD

TODO: is there more?

Fontconfig related settings

#define FC_ANTIALIAS        "antialias"         /* Bool (depends) */
#define FC_DPI              "dpi"               /* double */
#define FC_HINTING          "hinting"           /* Bool (true) */
#define FC_HINT_STYLE       "hintstyle"         /* Int */
    /* hinting style */
    #define FC_HINT_NONE        0
    #define FC_HINT_SLIGHT      1
    #define FC_HINT_MEDIUM      2
    #define FC_HINT_FULL        3
    { (FcChar8 *) "hintnone",       "hintstyle",   FC_HINT_NONE },
    { (FcChar8 *) "hintslight",     "hintstyle",   FC_HINT_SLIGHT },
    { (FcChar8 *) "hintmedium",     "hintstyle",   FC_HINT_MEDIUM },
    { (FcChar8 *) "hintfull",       "hintstyle",   FC_HINT_FULL },
#define FC_RGBA             "rgba"              /* Int */
    #define FC_RGBA_UNKNOWN     0
    #define FC_RGBA_RGB         1
    #define FC_RGBA_BGR         2
    #define FC_RGBA_VRGB        3
    #define FC_RGBA_VBGR        4
    #define FC_RGBA_NONE        5
    { (FcChar8 *) "unknown",        "rgba",         FC_RGBA_UNKNOWN },
    { (FcChar8 *) "rgb",            "rgba",         FC_RGBA_RGB, },
    { (FcChar8 *) "bgr",            "rgba",         FC_RGBA_BGR, },
    { (FcChar8 *) "vrgb",           "rgba",         FC_RGBA_VRGB },
    { (FcChar8 *) "vbgr",           "rgba",         FC_RGBA_VBGR },
    { (FcChar8 *) "none",           "rgba",         FC_RGBA_NONE },
#define FC_LCD_FILTER       "lcdfilter"         /* Int */
    #define FC_LCD_NONE         0
    #define FC_LCD_DEFAULT      1
    #define FC_LCD_LIGHT        2
    #define FC_LCD_LEGACY       3
    { (FcChar8 *) "lcdnone",        "lcdfilter",    FC_LCD_NONE },
    { (FcChar8 *) "lcddefault",     "lcdfilter",    FC_LCD_DEFAULT },
    { (FcChar8 *) "lcdlight",       "lcdfilter",    FC_LCD_LIGHT },
    { (FcChar8 *) "lcdlegacy",      "lcdfilter",    FC_LCD_LEGACY },

gnome-settings-daemon related settings

gnome-settings-daemon bridges together three configuration spaces:

gconf options

/desktop/gnome/font_rendering/antialiasing
    none, grayscale, rgba
/desktop/gnome/font_rendering/dpi

/desktop/gnome/font_rendering/hinting
    none, slight, medium, full
/desktop/gnome/font_rendering/rgba_order
    rgb, bgr, vrgb, vbgr

XSETTINGS registry

New specification to overcome some shortcomings of the Xrm Database. See http://standards.freedesktop.org/xsettings-spec/xsettings-spec-0.5.html

The registry is located at http://freedesktop.org/wiki/Specifications/XSettingsRegistry.

Interesting parameters: Xft/Antialias, Xft/Hinting, Xft/HintStyle, Xft/RGBA, Xft/DPI

Gtk+

Gtk+ interacts with the XSETTINGS database and maps these settings to gobject properties of a configuration object. The widgets are redrawn when one of this setting change, to implement live configuration update.

See http://svn.gnome.org/viewvc/gtk%252B/trunk/gdk/x11/gdksettings.c?view=markup

     62   "Xft/Antialias\0"           "gtk-xft-antialias\0"
     66   "Xft/DPI\0"                 "gtk-xft-dpi\0"
     63   "Xft/Hinting\0"             "gtk-xft-hinting\0"
     64   "Xft/HintStyle\0"           "gtk-xft-hintstyle\0"
     65   "Xft/RGBA\0"                "gtk-xft-rgba\0"

Tasks

Implementing the lcd filtering type through the stack

Standardization:

Implementation:

Hoisting the autohinter parameter to Xrm / XSETTING, for GNOME configurability and on-the-fly change

The current autohinter setting is only modifiable through fontconfig. Some people have expressed a need to change this setting dynamically through the font configuration panel.

https://bugs.launchpad.net/ubuntu/+source/fontconfig/+bug/22251

TODO: Discuss if this makes sense to make this a dynamic option instead of the current situation.

Standardization:

Implementation: