From: Keith Packard Date: Fri, 15 Sep 2006 07:23:40 +0000 (-0700) Subject: Reimplement FcConfigAppFontAddDir; function was lost in 2.4.0. X-Git-Tag: 2.4.1~1 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=97c3d5b692c7a45dc1d923fe04b6f2e011583d2d;p=fontconfig.git Reimplement FcConfigAppFontAddDir; function was lost in 2.4.0. With the cache restructuring of 2.4.0, the ability to add application-specific font files and directories was accidentally lost. Reimplement this using by sharing the logic used to load configured font directories. --- diff --git a/src/fccfg.c b/src/fccfg.c index 01d381c..635fdea 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -227,7 +227,8 @@ FcConfigDestroy (FcConfig *config) */ FcBool -FcConfigAddCache (FcConfig *config, FcCache *cache) +FcConfigAddCache (FcConfig *config, FcCache *cache, + FcSetName set, FcStrSet *dirSet) { FcFontSet *fs; intptr_t *dirs; @@ -263,7 +264,7 @@ FcConfigAddCache (FcConfig *config, FcCache *cache) continue; nref++; - FcFontSetAdd (config->fonts[FcSetSystem], font); + FcFontSetAdd (config->fonts[set], font); } FcDirCacheReference (cache, nref); } @@ -278,12 +279,37 @@ FcConfigAddCache (FcConfig *config, FcCache *cache) { FcChar8 *dir = FcOffsetToPtr (dirs, dirs[i], FcChar8); if (FcConfigAcceptFilename (config, dir)) - FcConfigAddFontDir (config, dir); + FcStrSetAddFilename (dirSet, dir); } } return FcTrue; } +static FcBool +FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet) +{ + FcStrList *dirlist; + FcChar8 *dir; + FcCache *cache; + + dirlist = FcStrListCreate (dirSet); + if (!dirlist) + return FcFalse; + + while ((dir = FcStrListNext (dirlist))) + { + if (FcDebug () & FC_DBG_FONTSET) + printf ("adding fonts from%s\n", dir); + cache = FcDirCacheRead (dir, FcFalse, config); + if (!cache) + continue; + FcConfigAddCache (config, cache, set, dirSet); + FcDirCacheUnload (cache); + } + FcStrListDone (dirlist); + return FcTrue; +} + /* * Scan the current list of directories in the configuration * and build the set of available fonts. @@ -293,9 +319,6 @@ FcBool FcConfigBuildFonts (FcConfig *config) { FcFontSet *fonts; - FcStrList *dirlist; - FcChar8 *dir; - FcCache *cache; if (!config) { @@ -306,33 +329,15 @@ FcConfigBuildFonts (FcConfig *config) fonts = FcFontSetCreate (); if (!fonts) - goto bail; + return FcFalse; FcConfigSetFonts (config, fonts, FcSetSystem); - dirlist = FcStrListCreate (config->fontDirs); - if (!dirlist) - goto bail; - - while ((dir = FcStrListNext (dirlist))) - { - if (FcDebug () & FC_DBG_FONTSET) - printf ("adding fonts from%s\n", dir); - cache = FcDirCacheRead (dir, FcFalse, config); - if (!cache) - continue; - FcConfigAddCache (config, cache); - FcDirCacheUnload (cache); - } - - FcStrListDone (dirlist); - + if (!FcConfigAddDirList (config, FcSetSystem, config->fontDirs)) + return FcFalse; if (FcDebug () & FC_DBG_FONTSET) FcFontSetPrint (fonts); - return FcTrue; -bail: - return FcFalse; } FcBool @@ -1799,9 +1804,7 @@ FcConfigAppFontAddDir (FcConfig *config, const FcChar8 *dir) { FcFontSet *set; - FcStrSet *subdirs; - FcStrList *sublist; - FcChar8 *subdir; + FcStrSet *dirs; if (!config) { @@ -1809,8 +1812,9 @@ FcConfigAppFontAddDir (FcConfig *config, if (!config) return FcFalse; } - subdirs = FcStrSetCreate (); - if (!subdirs) + + dirs = FcStrSetCreate (); + if (!dirs) return FcFalse; set = FcConfigGetFonts (config, FcSetApplication); @@ -1819,26 +1823,20 @@ FcConfigAppFontAddDir (FcConfig *config, set = FcFontSetCreate (); if (!set) { - FcStrSetDestroy (subdirs); + FcStrSetDestroy (dirs); return FcFalse; } FcConfigSetFonts (config, set, FcSetApplication); } - if (!FcDirScanConfig (set, subdirs, config->blanks, dir, FcFalse, config)) + FcStrSetAddFilename (dirs, dir); + + if (!FcConfigAddDirList (config, FcSetApplication, dirs)) { - FcStrSetDestroy (subdirs); + FcStrSetDestroy (dirs); return FcFalse; } - if ((sublist = FcStrListCreate (subdirs))) - { - while ((subdir = FcStrListNext (sublist))) - { - FcConfigAppFontAddDir (config, subdir); - } - FcStrListDone (sublist); - } - FcStrSetDestroy (subdirs); + FcStrSetDestroy (dirs); return FcTrue; } diff --git a/src/fcdir.c b/src/fcdir.c index bb5cfc9..d082992 100644 --- a/src/fcdir.c +++ b/src/fcdir.c @@ -273,7 +273,7 @@ FcDirScanConfig (FcFontSet *set, FcBool force, FcConfig *config) { - return FcFalse; /* XXX fixme */ + return FcFalse; /* XXX deprecated */ } FcBool @@ -284,7 +284,7 @@ FcDirScan (FcFontSet *set, const FcChar8 *dir, FcBool force) { - return FcDirScanConfig (set, dirs, blanks, dir, force, NULL); + return FcFalse; /* XXX deprecated */ } FcBool diff --git a/src/fcint.h b/src/fcint.h index afa37d2..60563cb 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -584,7 +584,8 @@ FcPrivate FcFileTime FcConfigModifiedTime (FcConfig *config); FcPrivate FcBool -FcConfigAddCache (FcConfig *config, FcCache *cache); +FcConfigAddCache (FcConfig *config, FcCache *cache, + FcSetName set, FcStrSet *dirSet); /* fcserialize.c */ FcPrivate intptr_t