Add an user font directory for Win32 to the default font path

Patch from @takase1121

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/144
This commit is contained in:
Akira TAGOH 2022-01-17 16:19:22 +09:00
parent 9a6ad6f1c5
commit 55eb1ef89b
3 changed files with 12 additions and 2 deletions

View File

@ -486,7 +486,7 @@ AC_ARG_WITH(default-fonts,
case "$default_fonts" in
yes)
if test "$os_win32" = "yes"; then
default_fonts="WINDOWSFONTDIR"
default_fonts="WINDOWSFONTDIR,WINDOWSUSERFONTDIR"
elif test "$os_darwin" = "yes"; then
default_fonts="/System/Library/Fonts,/Library/Fonts,~/Library/Fonts,/System/Library/Assets/com_apple_MobileAsset_Font3,/System/Library/Assets/com_apple_MobileAsset_Font4"
else

View File

@ -208,7 +208,7 @@ prefix = get_option('prefix')
fonts_conf = configuration_data()
if host_machine.system() == 'windows'
fc_fonts_path = ['WINDOWSFONTDIR']
fc_fonts_path = ['WINDOWSFONTDIR', 'WINDOWSUSERFONTDIR']
fc_cachedir = 'LOCAL_APPDATA_FONTCONFIG_CACHE'
else
if host_machine.system() == 'darwin'

View File

@ -1370,6 +1370,16 @@ _get_real_paths_from_prefix(FcConfigParse *parse, const FcChar8 *path, const FcC
if (p) *p = '\0';
strcat ((char *) path, "\\..\\share\\fonts");
}
else if (strcmp ((const char *) path, "WINDOWSUSERFONTDIR") == 0)
{
path = buffer;
if (!(pSHGetFolderPathA && SUCCEEDED(pSHGetFolderPathA(NULL, /* CSIDL_LOCAL_APPDATA */ 28, NULL, 0, (char *) buffer))))
{
FcConfigMessage(parse, FcSevereError, "SHGetFolderPathA failed");
return NULL;
}
strcat((char *) path, "\\Microsoft\\Windows\\Fonts");
}
else if (strcmp ((const char *) path, "WINDOWSFONTDIR") == 0)
{
int rc;