config->substPattern = 0;
config->substFont = 0;
+ config->substScan = 0;
config->maxObjects = 0;
for (set = FcSetSystem; set <= FcSetApplication; set++)
config->fonts[set] = 0;
- config->caches = NULL;
-
config->rescanTime = time(0);
config->rescanInterval = 30;
return newest;
}
-FcFileTime
-FcConfigModifiedTime (FcConfig *config)
-{
- if (!config)
- {
- FcFileTime v = { 0, FcFalse };
- config = FcConfigGetCurrent ();
- if (!config)
- return v;
- }
- return FcConfigNewestFile (config->configFiles);
-}
-
FcBool
FcConfigUptoDate (FcConfig *config)
{
- FcFileTime config_time, font_time;
+ FcFileTime config_time, config_dir_time, font_time;
time_t now = time(0);
if (!config)
{
return FcFalse;
}
config_time = FcConfigNewestFile (config->configFiles);
+ config_dir_time = FcConfigNewestFile (config->configDirs);
font_time = FcConfigNewestFile (config->fontDirs);
if ((config_time.set && config_time.time - config->rescanTime > 0) ||
+ (config_dir_time.set && (config_dir_time.time - config->rescanTime) > 0) ||
(font_time.set && (font_time.time - config->rescanTime) > 0))
{
- return FcFalse;
+ /* We need to check for potential clock problems here (OLPC ticket #6046) */
+ if ((config_time.set && (config_time.time - now) > 0) ||
+ (config_dir_time.set && (config_dir_time.time - now) > 0) ||
+ (font_time.set && (font_time.time - now) > 0))
+ {
+ fprintf (stderr,
+ "Fontconfig warning: Directory/file mtime in the future. New fonts may not be detected\n");
+ config->rescanTime = now;
+ return FcTrue;
+ }
+ else
+ return FcFalse;
}
config->rescanTime = now;
return FcTrue;
FcConfigDestroy (FcConfig *config)
{
FcSetName set;
- FcCacheList *cl, *cl_next;
if (config == _fcConfig)
_fcConfig = 0;
FcSubstDestroy (config->substPattern);
FcSubstDestroy (config->substFont);
+ FcSubstDestroy (config->substScan);
for (set = FcSetSystem; set <= FcSetApplication; set++)
if (config->fonts[set])
FcFontSetDestroy (config->fonts[set]);
- for (cl = config->caches; cl; cl = cl_next)
- {
- cl_next = cl->next;
- FcDirCacheUnload (cl->cache);
- free (cl);
- }
-
free (config);
FcMemFree (FC_MEM_CONFIG, sizeof (FcConfig));
}
*/
FcBool
-FcConfigAddCache (FcConfig *config, FcCache *cache)
+FcConfigAddCache (FcConfig *config, FcCache *cache,
+ FcSetName set, FcStrSet *dirSet)
{
- FcCacheList *cl = malloc (sizeof (FcCacheList));
FcFontSet *fs;
intptr_t *dirs;
int i;
- /*
- * Add to cache list
- */
- if (!cl)
- return FcFalse;
- cl->cache = cache;
- cl->next = config->caches;
- config->caches = cl;
-
/*
* Add fonts
*/
fs = FcCacheSet (cache);
if (fs)
{
+ int nref = 0;
+
for (i = 0; i < fs->nfont; i++)
{
FcPattern *font = FcFontSetFont (fs, i);
if (!FcConfigAcceptFont (config, font))
continue;
- FcFontSetAdd (config->fonts[FcSetSystem], font);
+ nref++;
+ 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);
- }
-
- FcStrListDone (dirlist);
-
+ if (!FcConfigAddDirList (config, FcSetSystem, config->fontDirs))
+ return FcFalse;
if (FcDebug () & FC_DBG_FONTSET)
FcFontSetPrint (fonts);
-
return FcTrue;
-bail:
- return FcFalse;
}
FcBool
FcConfigSetCurrent (FcConfig *config)
{
+ if (config == _fcConfig)
+ return FcTrue;
+
if (!config->fonts)
if (!FcConfigBuildFonts (config))
return FcFalse;
}
int
-FcConfigGetRescanInverval (FcConfig *config)
+FcConfigGetRescanInterval (FcConfig *config)
{
if (!config)
{
}
FcBool
-FcConfigSetRescanInverval (FcConfig *config, int rescanInterval)
+FcConfigSetRescanInterval (FcConfig *config, int rescanInterval)
{
if (!config)
{
return FcTrue;
}
+/*
+ * A couple of typos escaped into the library
+ */
+int
+FcConfigGetRescanInverval (FcConfig *config)
+{
+ return FcConfigGetRescanInterval (config);
+}
+
+FcBool
+FcConfigSetRescanInverval (FcConfig *config, int rescanInterval)
+{
+ return FcConfigSetRescanInterval (config, rescanInterval);
+}
+
+
FcBool
FcConfigAddEdit (FcConfig *config,
FcTest *test,
ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
break;
case FcOpNotContains:
- ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
+ ret = FcStrStrIgnoreCase (left.u.s, right.u.s) == 0;
break;
default:
break;
return FcConfigSubstituteWithPat (config, p, 0, kind);
}
-#if defined (_WIN32) && (defined (PIC) || defined (DLL_EXPORT))
+#if defined (_WIN32)
+
+# define WIN32_LEAN_AND_MEAN
+# define WIN32_EXTRA_LEAN
+# include <windows.h>
static FcChar8 fontconfig_path[1000] = "";
+# if (defined (PIC) || defined (DLL_EXPORT))
+
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
return TRUE;
}
+# endif /* !PIC */
+
#undef FONTCONFIG_PATH
#define FONTCONFIG_PATH fontconfig_path
-#else /* !(_WIN32 && PIC) */
-
-#endif /* !(_WIN32 && PIC) */
+#endif /* !_WIN32 */
#ifndef FONTCONFIG_FILE
#define FONTCONFIG_FILE "fonts.conf"
}
}
+#ifdef _WIN32
+ if (fontconfig_path[0] == '\0')
+ {
+ char *p;
+ if(!GetModuleFileName(NULL, fontconfig_path, sizeof(fontconfig_path)))
+ goto bail1;
+ p = strrchr (fontconfig_path, '\\');
+ if (p) *p = '\0';
+ strcat (fontconfig_path, "\\fonts");
+ }
+#endif
dir = (FcChar8 *) FONTCONFIG_PATH;
path[i] = malloc (strlen ((char *) dir) + 1);
if (!path[i])
FcConfigFilename (const FcChar8 *url)
{
FcChar8 *file, *dir, **path, **p;
-
+
if (!url || !*url)
{
url = (FcChar8 *) getenv ("FONTCONFIG_FILE");
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;
}
return FcFalse;
return FcTrue;
}
+#define __fccfg__
+#include "fcaliastail.h"
+#undef __fccfg__