src/fccfg.c | 86 +++++++++++++++++++++++++++++------------------------------- src/fcdir.c | 4 +- src/fcint.h | 3 +- 3 files changed, 46 insertions(+), 47 deletions(-) New commits: diff-tree 97c3d5b692c7a45dc1d923fe04b6f2e011583d2d (from b190ad9da46ff2e8a9ede0afcb59a6c59641515b) Author: Keith Packard <keithp@xxxxxxxxxxxxxxx> Date: Fri Sep 15 00:23:40 2006 -0700 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, FcCa continue; nref++; - FcFontSetAdd (config->fonts[FcSetSystem], font); + FcFontSetAdd (config->fonts[set], font); } FcDirCacheReference (cache, nref); } @@ -278,12 +279,37 @@ FcConfigAddCache (FcConfig *config, FcCa { 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 *con const FcChar8 *dir) { FcFontSet *set; - FcStrSet *subdirs; - FcStrList *sublist; - FcChar8 *subdir; + FcStrSet *dirs; if (!config) { @@ -1809,8 +1812,9 @@ FcConfigAppFontAddDir (FcConfig *con if (!config) return FcFalse; } - subdirs = FcStrSetCreate (); - if (!subdirs) + + dirs = FcStrSetCreate (); + if (!dirs) return FcFalse; set = FcConfigGetFonts (config, FcSetApplication); @@ -1819,26 +1823,20 @@ FcConfigAppFontAddDir (FcConfig *con 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 _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig