Revert changes made to FcConfigAppFontAddDir() recently
In 32ac7c75e8
the behavior of
FcConfigAppFontAddFile/Dir() were changed to return false
if not fonts were found. While this is welldefined and useful
for AddFile(), it's quite problematic for AddDir(). For example,
if the directory is empty, is that a failure or success? Worse,
the false value from AddDir() was being propagated all the way
to FcInit() returning false now. This only happened upon memory
allocation failure before, and some clients assert that FcInit()
is successful.
With this change, AddDir() is reverted back to what it was.
AddFont() change (which was actually in fcdir.c) from the original
commit is left in.
This commit is contained in:
parent
a8096dfa59
commit
46ec6a52d4
|
@ -232,7 +232,7 @@ the current configuration is used.
|
||||||
@DESC@
|
@DESC@
|
||||||
Scans the specified directory for fonts, adding each one found to the
|
Scans the specified directory for fonts, adding each one found to the
|
||||||
application-specific set of fonts. Returns FcFalse
|
application-specific set of fonts. Returns FcFalse
|
||||||
if the fonts cannot be added (due to allocation failure or no fonts found).
|
if the fonts cannot be added (due to allocation failure).
|
||||||
Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
|
Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
|
||||||
the current configuration is used.
|
the current configuration is used.
|
||||||
@@
|
@@
|
||||||
|
|
29
src/fccfg.c
29
src/fccfg.c
|
@ -368,13 +368,10 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
|
||||||
FcStrList *dirlist;
|
FcStrList *dirlist;
|
||||||
FcChar8 *dir;
|
FcChar8 *dir;
|
||||||
FcCache *cache;
|
FcCache *cache;
|
||||||
FcBool ret = FcFalse;
|
|
||||||
|
|
||||||
dirlist = FcStrListCreate (dirSet);
|
dirlist = FcStrListCreate (dirSet);
|
||||||
if (!dirlist)
|
if (!dirlist)
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
if (FcStrListGetLength (dirlist) == 0)
|
|
||||||
ret = FcTrue;
|
|
||||||
|
|
||||||
while ((dir = FcStrListNext (dirlist)))
|
while ((dir = FcStrListNext (dirlist)))
|
||||||
{
|
{
|
||||||
|
@ -385,10 +382,9 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
|
||||||
continue;
|
continue;
|
||||||
FcConfigAddCache (config, cache, set, dirSet);
|
FcConfigAddCache (config, cache, set, dirSet);
|
||||||
FcDirCacheUnload (cache);
|
FcDirCacheUnload (cache);
|
||||||
ret = FcTrue;
|
|
||||||
}
|
}
|
||||||
FcStrListDone (dirlist);
|
FcStrListDone (dirlist);
|
||||||
return ret;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2201,7 +2197,6 @@ FcConfigAppFontAddFile (FcConfig *config,
|
||||||
FcStrSet *subdirs;
|
FcStrSet *subdirs;
|
||||||
FcStrList *sublist;
|
FcStrList *sublist;
|
||||||
FcChar8 *subdir;
|
FcChar8 *subdir;
|
||||||
FcBool ret = FcFalse;
|
|
||||||
|
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
|
@ -2231,19 +2226,16 @@ FcConfigAppFontAddFile (FcConfig *config,
|
||||||
FcStrSetDestroy (subdirs);
|
FcStrSetDestroy (subdirs);
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
if (subdirs->num == 0)
|
if ((sublist = FcStrListCreate (subdirs)))
|
||||||
ret = FcTrue;
|
|
||||||
else if ((sublist = FcStrListCreate (subdirs)))
|
|
||||||
{
|
{
|
||||||
while ((subdir = FcStrListNext (sublist)))
|
while ((subdir = FcStrListNext (sublist)))
|
||||||
{
|
{
|
||||||
if (FcConfigAppFontAddDir (config, subdir))
|
FcConfigAppFontAddDir (config, subdir);
|
||||||
ret = FcTrue;
|
|
||||||
}
|
}
|
||||||
FcStrListDone (sublist);
|
FcStrListDone (sublist);
|
||||||
}
|
}
|
||||||
FcStrSetDestroy (subdirs);
|
FcStrSetDestroy (subdirs);
|
||||||
return ret;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FcBool
|
FcBool
|
||||||
|
@ -2252,7 +2244,6 @@ FcConfigAppFontAddDir (FcConfig *config,
|
||||||
{
|
{
|
||||||
FcFontSet *set;
|
FcFontSet *set;
|
||||||
FcStrSet *dirs;
|
FcStrSet *dirs;
|
||||||
FcBool ret = FcTrue;
|
|
||||||
|
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
|
@ -2271,8 +2262,8 @@ FcConfigAppFontAddDir (FcConfig *config,
|
||||||
set = FcFontSetCreate ();
|
set = FcFontSetCreate ();
|
||||||
if (!set)
|
if (!set)
|
||||||
{
|
{
|
||||||
ret = FcFalse;
|
FcStrSetDestroy (dirs);
|
||||||
goto bail;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
FcConfigSetFonts (config, set, FcSetApplication);
|
FcConfigSetFonts (config, set, FcSetApplication);
|
||||||
}
|
}
|
||||||
|
@ -2280,10 +2271,12 @@ FcConfigAppFontAddDir (FcConfig *config,
|
||||||
FcStrSetAddFilename (dirs, dir);
|
FcStrSetAddFilename (dirs, dir);
|
||||||
|
|
||||||
if (!FcConfigAddDirList (config, FcSetApplication, dirs))
|
if (!FcConfigAddDirList (config, FcSetApplication, dirs))
|
||||||
ret = FcFalse;
|
{
|
||||||
bail:
|
FcStrSetDestroy (dirs);
|
||||||
|
return FcFalse;
|
||||||
|
}
|
||||||
FcStrSetDestroy (dirs);
|
FcStrSetDestroy (dirs);
|
||||||
return ret;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1176,9 +1176,6 @@ FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
|
||||||
FcPrivate FcChar8 *
|
FcPrivate FcChar8 *
|
||||||
FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
|
FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
|
||||||
|
|
||||||
FcPrivate int
|
|
||||||
FcStrListGetLength (const FcStrList *list);
|
|
||||||
|
|
||||||
/* fcobjs.c */
|
/* fcobjs.c */
|
||||||
|
|
||||||
FcPrivate void
|
FcPrivate void
|
||||||
|
|
|
@ -1347,14 +1347,6 @@ FcStrListDone (FcStrList *list)
|
||||||
free (list);
|
free (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
FcStrListGetLength (const FcStrList *list)
|
|
||||||
{
|
|
||||||
if (!list)
|
|
||||||
return 0;
|
|
||||||
return list->set->num;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __fcstr__
|
#define __fcstr__
|
||||||
#include "fcaliastail.h"
|
#include "fcaliastail.h"
|
||||||
#undef __fcstr__
|
#undef __fcstr__
|
||||||
|
|
Loading…
Reference in New Issue