*/
FcBool
-FcConfigAddCache (FcConfig *config, FcCache *cache)
+FcConfigAddCache (FcConfig *config, FcCache *cache,
+ FcSetName set, FcStrSet *dirSet)
{
FcFontSet *fs;
intptr_t *dirs;
continue;
nref++;
- FcFontSetAdd (config->fonts[FcSetSystem], font);
+ FcFontSetAdd (config->fonts[set], font);
}
FcDirCacheReference (cache, nref);
}
{
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.
FcConfigBuildFonts (FcConfig *config)
{
FcFontSet *fonts;
- FcStrList *dirlist;
- FcChar8 *dir;
- FcCache *cache;
if (!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
const FcChar8 *dir)
{
FcFontSet *set;
- FcStrSet *subdirs;
- FcStrList *sublist;
- FcChar8 *subdir;
+ FcStrSet *dirs;
if (!config)
{
if (!config)
return FcFalse;
}
- subdirs = FcStrSetCreate ();
- if (!subdirs)
+
+ dirs = FcStrSetCreate ();
+ if (!dirs)
return FcFalse;
set = FcConfigGetFonts (config, FcSetApplication);
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;
}