Re: [Tuxpaint-devel] Windows & Android (& others?) FontConfig `fonts.conf` parsing
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
From: Bill K. <nb...@so...> - 2025-02-22 21:41:46
|
On Sat, Feb 22, 2025 at 12:04:51PM -0800, Bill Kendrick wrote: <snip> PS - I just added support for the "prefix" attribute of the "<dir>" tags in the "fonts.conf" FontConfig files. If it's `<dir prefix="xdg">PATH</dir>`, the PATH provided will be prefixed with either "$XDG_DATA_HOME", or if that isn't set, then (like we do with the Trash feature) prefixed with "$HOME/.local/share/". And if it's `<dir prefix="relative">PATH</dir>`, then the PATH provided will be prefixed with the path of the directory _containing_ the "fonts.conf" that's currently being read. (See https://www.freedesktop.org/software/fontconfig/fontconfig-user.html) As I mentioned before, I am NOT parsing any of the 'magic string' paths that FontConfig seems to allow inside the `<dir>...</dir>` tags, such as "WINDOWSUSERFONTDIR" or "CUSTOMFONTDIR". I don't even really see where they're documented, I just see them (1) in our own "fonts.conf" that gets supplied with the Windows build, and (2) in the FontConfig code (see https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/src/fcxml.c) and at least one comment in a tickets or forums somewhere, which is how I stumbled across the link to "fcxml.c". So for the moment, please continue including this in Tux Paint's "load_user_fonts()" function (which I guess should have really been named "load user and system fonts" :-) ) ... #ifdef WIN32 /* Windows: Look for fonts in the system font dir (as defined by Windows registry) */ homedirdir = GetSystemFontDir(); loadfonts(screen, texture, renderer, homedirdir); /* Windows: Look for fonts in the user font dir (as defined by Windows registry) */ homedirdir = GetUserFontDir(); if (homedirdir != NULL){ loadfonts(screen, texture, renderer, homedirdir); } free(homedirdir); ... And I think for _now_, we're all set, for Windows at least...? I'll attempt to summon Mark to see whether anything else needs to be done on the macOS side. :) -bill! |