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.
This commit is contained in:
Keith Packard 2006-09-15 00:23:40 -07:00
parent b190ad9da4
commit 97c3d5b692
3 changed files with 46 additions and 47 deletions

View File

@ -227,7 +227,8 @@ FcConfigDestroy (FcConfig *config)
*/ */
FcBool FcBool
FcConfigAddCache (FcConfig *config, FcCache *cache) FcConfigAddCache (FcConfig *config, FcCache *cache,
FcSetName set, FcStrSet *dirSet)
{ {
FcFontSet *fs; FcFontSet *fs;
intptr_t *dirs; intptr_t *dirs;
@ -263,7 +264,7 @@ FcConfigAddCache (FcConfig *config, FcCache *cache)
continue; continue;
nref++; nref++;
FcFontSetAdd (config->fonts[FcSetSystem], font); FcFontSetAdd (config->fonts[set], font);
} }
FcDirCacheReference (cache, nref); FcDirCacheReference (cache, nref);
} }
@ -278,12 +279,37 @@ FcConfigAddCache (FcConfig *config, FcCache *cache)
{ {
FcChar8 *dir = FcOffsetToPtr (dirs, dirs[i], FcChar8); FcChar8 *dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
if (FcConfigAcceptFilename (config, dir)) if (FcConfigAcceptFilename (config, dir))
FcConfigAddFontDir (config, dir); FcStrSetAddFilename (dirSet, dir);
} }
} }
return FcTrue; 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 * Scan the current list of directories in the configuration
* and build the set of available fonts. * and build the set of available fonts.
@ -293,9 +319,6 @@ FcBool
FcConfigBuildFonts (FcConfig *config) FcConfigBuildFonts (FcConfig *config)
{ {
FcFontSet *fonts; FcFontSet *fonts;
FcStrList *dirlist;
FcChar8 *dir;
FcCache *cache;
if (!config) if (!config)
{ {
@ -306,33 +329,15 @@ FcConfigBuildFonts (FcConfig *config)
fonts = FcFontSetCreate (); fonts = FcFontSetCreate ();
if (!fonts) if (!fonts)
goto bail; return FcFalse;
FcConfigSetFonts (config, fonts, FcSetSystem); FcConfigSetFonts (config, fonts, FcSetSystem);
dirlist = FcStrListCreate (config->fontDirs); if (!FcConfigAddDirList (config, FcSetSystem, config->fontDirs))
if (!dirlist) return FcFalse;
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 (FcDebug () & FC_DBG_FONTSET) if (FcDebug () & FC_DBG_FONTSET)
FcFontSetPrint (fonts); FcFontSetPrint (fonts);
return FcTrue; return FcTrue;
bail:
return FcFalse;
} }
FcBool FcBool
@ -1799,9 +1804,7 @@ FcConfigAppFontAddDir (FcConfig *config,
const FcChar8 *dir) const FcChar8 *dir)
{ {
FcFontSet *set; FcFontSet *set;
FcStrSet *subdirs; FcStrSet *dirs;
FcStrList *sublist;
FcChar8 *subdir;
if (!config) if (!config)
{ {
@ -1809,8 +1812,9 @@ FcConfigAppFontAddDir (FcConfig *config,
if (!config) if (!config)
return FcFalse; return FcFalse;
} }
subdirs = FcStrSetCreate ();
if (!subdirs) dirs = FcStrSetCreate ();
if (!dirs)
return FcFalse; return FcFalse;
set = FcConfigGetFonts (config, FcSetApplication); set = FcConfigGetFonts (config, FcSetApplication);
@ -1819,26 +1823,20 @@ FcConfigAppFontAddDir (FcConfig *config,
set = FcFontSetCreate (); set = FcFontSetCreate ();
if (!set) if (!set)
{ {
FcStrSetDestroy (subdirs); FcStrSetDestroy (dirs);
return FcFalse; return FcFalse;
} }
FcConfigSetFonts (config, set, FcSetApplication); 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; return FcFalse;
} }
if ((sublist = FcStrListCreate (subdirs))) FcStrSetDestroy (dirs);
{
while ((subdir = FcStrListNext (sublist)))
{
FcConfigAppFontAddDir (config, subdir);
}
FcStrListDone (sublist);
}
FcStrSetDestroy (subdirs);
return FcTrue; return FcTrue;
} }

View File

@ -273,7 +273,7 @@ FcDirScanConfig (FcFontSet *set,
FcBool force, FcBool force,
FcConfig *config) FcConfig *config)
{ {
return FcFalse; /* XXX fixme */ return FcFalse; /* XXX deprecated */
} }
FcBool FcBool
@ -284,7 +284,7 @@ FcDirScan (FcFontSet *set,
const FcChar8 *dir, const FcChar8 *dir,
FcBool force) FcBool force)
{ {
return FcDirScanConfig (set, dirs, blanks, dir, force, NULL); return FcFalse; /* XXX deprecated */
} }
FcBool FcBool

View File

@ -584,7 +584,8 @@ FcPrivate FcFileTime
FcConfigModifiedTime (FcConfig *config); FcConfigModifiedTime (FcConfig *config);
FcPrivate FcBool FcPrivate FcBool
FcConfigAddCache (FcConfig *config, FcCache *cache); FcConfigAddCache (FcConfig *config, FcCache *cache,
FcSetName set, FcStrSet *dirSet);
/* fcserialize.c */ /* fcserialize.c */
FcPrivate intptr_t FcPrivate intptr_t