Windows: Load fonts.conf that ships w/ Tux Paint
Plus more comments & FIXMEs!
This commit is contained in:
parent
96b91b9fba
commit
653f1a20c5
2 changed files with 33 additions and 10 deletions
|
|
@ -34,11 +34,15 @@ https://tuxpaint.org/
|
||||||
+ WIP Checking for fonts in any locations specified by "<dir>"
|
+ WIP Checking for fonts in any locations specified by "<dir>"
|
||||||
entries found in system-wide and user-level FontConfig config files.
|
entries found in system-wide and user-level FontConfig config files.
|
||||||
This allows more fonts, and user-specific fonts, to be found & loaded.
|
This allows more fonts, and user-specific fonts, to be found & loaded.
|
||||||
- TODO - Looks in $FONTCONFIG_PATH/fonts.conf on macOS/iOS,
|
- It looks for:
|
||||||
`/boot/system/settings/fonts/fonts.conf` on Haiku, otherwise
|
- FIXME: <system fonts.conf> (Windows)
|
||||||
the Un*x-specific `/etc/fonts/fonts.conf` and
|
- `./etc/fonts/fonts.conf` (ships with Tux Paint) (Windows)
|
||||||
`~/.config/fontconfig/fonts.conf`. Should look in the correct
|
- `$FONTCONFIG_PATH/fonts.conf` (macOS/iOS, Linux/Unix)
|
||||||
places on other platforms.
|
- or `/etc/fonts/fonts.conf` (Linux/Unix)
|
||||||
|
- `$XDG_CONFIG_HOME/fontconfig/fonts.conf` (Linux/Unix)
|
||||||
|
- or `$HOME/.config/fontconfig/fonts.conf`
|
||||||
|
- `/boot/system/settings/fonts/fonts.conf` (Haiku)
|
||||||
|
- FIXME: ??? (ships with Tux Paint) (macOS)
|
||||||
- Note: This adds a build dependency on `libxml-2.0`.
|
- Note: This adds a build dependency on `libxml-2.0`.
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
h/t Mark Kim & Luc Schrijvers
|
h/t Mark Kim & Luc Schrijvers
|
||||||
|
|
|
||||||
29
src/fonts.c
29
src/fonts.c
|
|
@ -1103,24 +1103,34 @@ char * * malloc_fontconfig_config_paths(int num_to_malloc, int * num_actually_ma
|
||||||
/* See what dirs fontconfig configuration files point to,
|
/* See what dirs fontconfig configuration files point to,
|
||||||
and try loading fonts from those locations */
|
and try loading fonts from those locations */
|
||||||
|
|
||||||
/* FIXME: We do not currently understand "<dir prefix=...>" -bjk 2025.02.22 */
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
/* Apple: Look for fonts.conf in $FONTCONFIG_PATH */
|
|
||||||
fontconfig_config_paths = malloc_fontconfig_config_paths(1, &num_fontconfig_config_paths);
|
fontconfig_config_paths = malloc_fontconfig_config_paths(1, &num_fontconfig_config_paths);
|
||||||
if (fontconfig_config_paths != NULL)
|
if (fontconfig_config_paths != NULL)
|
||||||
{
|
{
|
||||||
|
/* Apple: Look for fonts.conf in $FONTCONFIG_PATH */
|
||||||
fontconfig_config_paths[0] = malloc(1024);
|
fontconfig_config_paths[0] = malloc(1024);
|
||||||
snprintf(fontconfig_config_paths[0], 1024, "%s/fonts.conf", getenv("FONTCONFIG_PATH"));
|
snprintf(fontconfig_config_paths[0], 1024, "%s/fonts.conf", getenv("FONTCONFIG_PATH"));
|
||||||
|
|
||||||
|
/* FIXME: Apple: Look for the fonts.conf that we ship with Tux Paint for macOS */
|
||||||
}
|
}
|
||||||
#elif defined(__HAIKU__)
|
#elif defined(__HAIKU__)
|
||||||
/* Haiku: Look for fonts.conf in a known system directory */
|
|
||||||
fontconfig_config_paths = malloc_fontconfig_config_paths(1, &num_fontconfig_config_paths);
|
fontconfig_config_paths = malloc_fontconfig_config_paths(1, &num_fontconfig_config_paths);
|
||||||
if (fontconfig_config_paths != NULL)
|
if (fontconfig_config_paths != NULL)
|
||||||
{
|
{
|
||||||
|
/* Haiku: Look for fonts.conf in a known system directory */
|
||||||
fontconfig_config_paths[0] = malloc(1024);
|
fontconfig_config_paths[0] = malloc(1024);
|
||||||
snprintf(fontconfig_config_paths[0], 1024, "/boot/system/settings/fonts/fonts.conf");
|
snprintf(fontconfig_config_paths[0], 1024, "/boot/system/settings/fonts/fonts.conf");
|
||||||
}
|
}
|
||||||
|
#elif defined(WIN32)
|
||||||
|
fontconfig_config_paths = malloc_fontconfig_config_paths(1 /* FIXME */, &num_fontconfig_config_paths);
|
||||||
|
if (fontconfig_config_paths != NULL)
|
||||||
|
{
|
||||||
|
/* FIXME: Windows: Look for fonts.conf ??? in some system directory/ies ??? */
|
||||||
|
|
||||||
|
/* Windows: Look for the fonts.conf that we ship with Tux Paint for Windows */
|
||||||
|
fontconfig_config_paths[0 /* FIXME */] = malloc(1024);
|
||||||
|
snprintf(fontconfig_config_paths[0 /* FIXME */], 1024, "etc/fonts/fonts.conf");
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Others [e.g. Linux]: Look for fonts.conf in $FONTCONFIG_PATH (fallback to "/etc/fonts")
|
/* Others [e.g. Linux]: Look for fonts.conf in $FONTCONFIG_PATH (fallback to "/etc/fonts")
|
||||||
and $XDG_CONFIG_HOME (fallback to "$HOME/.config") */
|
and $XDG_CONFIG_HOME (fallback to "$HOME/.config") */
|
||||||
|
|
@ -1167,7 +1177,7 @@ char * * malloc_fontconfig_config_paths(int num_to_malloc, int * num_actually_ma
|
||||||
if (config_home != NULL)
|
if (config_home != NULL)
|
||||||
{
|
{
|
||||||
fontconfig_config_paths[1] = malloc(1024);
|
fontconfig_config_paths[1] = malloc(1024);
|
||||||
snprintf(fontconfig_config_paths[1], 1024, "%s/.config/fontconfig/fonts.conf", config_home);
|
snprintf(fontconfig_config_paths[1], 1024, "%s/fontconfig/fonts.conf", config_home);
|
||||||
free(config_home);
|
free(config_home);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1215,6 +1225,15 @@ char * * malloc_fontconfig_config_paths(int num_to_malloc, int * num_actually_ma
|
||||||
xmlChar * path;
|
xmlChar * path;
|
||||||
char * path_str;
|
char * path_str;
|
||||||
|
|
||||||
|
/* FIXME: We do not currently understand "<dir prefix=...>" -bjk 2025.02.22
|
||||||
|
(prefix may be one of "cwd"/"default", "xdg", or "relative";
|
||||||
|
see https://www.freedesktop.org/software/fontconfig/fontconfig-user.html */
|
||||||
|
|
||||||
|
/* Note: As we already look for both system and user fonts on Windows,
|
||||||
|
we'll just ignore "WINDOWSUSERFONTDIR" and "WINDOWSFONTDIR" magic paths;
|
||||||
|
also ignoring "APPSHAREFONTDIR" and "CUSTOMFONTDIR".
|
||||||
|
See https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/src/fcxml.c */
|
||||||
|
|
||||||
path = xmlNodeGetContent(cur);
|
path = xmlNodeGetContent(cur);
|
||||||
|
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue