Next: (heks-linux gif), Previous: (heks-linux fastfetch), Up: API
Renders ~/.config/fontconfig/fonts.conf: how text is drawn, rather than which text is drawn. The palettes, the fonts and the sizes are decided elsewhere; this file decides whether a glyph is smoothed, hinted, emboldened, and whether it is allowed to break into coloured fringes.
The rules below are the ones a Mac’s text rendering is recognised by. macOS has always smoothed glyphs in grey - it never split a stem into red, green and blue subpixels - and it hinted lightly, so shapes keep their design instead of being snapped to the pixel grid. A Linux desktop usually does the opposite: full hinting and RGB subpixel rendering, which is sharper at small sizes and looks nothing like a Mac.
It is a fontconfig rule rather than a GTK setting because fontconfig is the one layer every surface here has in common: the bar, the launcher, the notifications, the terminals, the editor and the browsers all ask fontconfig how to draw a glyph. A GTK-only setting would leave half the desktop rendering differently.
The rules assign rather than prefer. A program that wants subpixel
rendering has already put its own antialiasing flags in the pattern it
asks fontconfig to match, so an edit in the default weak mode
would be skipped as a duplicate of what the program asked for;
assign overrides it.
Default value:
#t
Default value:
"/root/.config/fontconfig"
Default value:
"fonts.conf"
Default value:
12
Default value:
#f
Default value:
"hintslight"
Default value:
#t
Default value:
"lcdnone"
Default value:
"none"
Return the fontconfig configuration as an SXML element.
There is no xmlns attribute on the root: fontconfig reads the
file against its own DTD and rejects a namespace declaration as an
invalid attribute - a warning on every font match, for a file that only
fontconfig ever reads.
The tree is what a test asserts on - which hints are set, and that the
grayscale rule is written in assign mode - while
fontconfig-config-xml is how it reaches fonts.conf.
(sxml->xml (fontconfig-config))
Render fonts.conf as a string.
The XML declaration and the DOCTYPE are written by hand: fontconfig’s own files carry both, SXML has a node for only the first, and a file that looks like every other fontconfig file is a file somebody can compare against /etc/fonts/fonts.conf without wondering what produced it.
Return the font-drawing rules as a list of fontconfig edit
elements.
Every rule is optional: a machine that wants subpixel rendering sets fontconfig-rgba-order to rgb and gets the same file without the grayscale rule, rather than a second configuration somewhere else.
(length (fontconfig-edits))
Return the match rules that carry fontconfig-edits.
One rule covers every size. A second one, only when fontconfig-embolden? is on, gates the faking on fontconfig-embolden-threshold - which is why the edits are returned separately: the same rule can then be used at two sizes.
Write the font rendering rules to
~/.config/fontconfig/fonts.conf.
Local overrides are read from
$XDG_CONFIG_HOME/heks-linux/fontconfig-settings.scm first, so a
machine that wants subpixel rendering - or no antialiasing at all - can
say so in its own file instead of forking this one. Fontconfig reads
the file when a program starts; already-running applications keep the
rendering they started with.
Next: (heks-linux gif), Previous: (heks-linux fastfetch), Up: API