* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
+ * documentation, and that the name of the author(s) not be used in
* advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
+ * specific, written prior permission. The authors make no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
if (!config)
goto bail0;
FcMemAlloc (FC_MEM_CONFIG, sizeof (FcConfig));
-
+
config->configDirs = FcStrSetCreate ();
if (!config->configDirs)
goto bail1;
-
+
config->configFiles = FcStrSetCreate ();
if (!config->configFiles)
goto bail2;
-
+
config->fontDirs = FcStrSetCreate ();
if (!config->fontDirs)
goto bail3;
-
+
config->acceptGlobs = FcStrSetCreate ();
if (!config->acceptGlobs)
goto bail4;
config->acceptPatterns = FcFontSetCreate ();
if (!config->acceptPatterns)
goto bail6;
-
+
config->rejectPatterns = FcFontSetCreate ();
if (!config->rejectPatterns)
goto bail7;
config->cacheDirs = FcStrSetCreate ();
if (!config->cacheDirs)
goto bail8;
-
+
config->blanks = 0;
config->substPattern = 0;
config->fonts[set] = 0;
config->rescanTime = time(0);
- config->rescanInterval = 30;
+ config->rescanInterval = 30;
+
+ config->expr_pool = NULL;
config->ref = 1;
-
+
return config;
bail8:
if (list)
{
while ((file = FcStrListNext (list)))
- if (FcStat ((char *) file, &statb) == 0)
+ if (FcStat (file, &statb) == 0)
if (!newest.set || statb.st_mtime - newest.time > 0)
{
newest.set = FcTrue;
FcSubstDestroy (FcSubst *s)
{
FcSubst *n;
-
+
while (s)
{
n = s->next;
}
}
+FcExpr *
+FcConfigAllocExpr (FcConfig *config)
+{
+ if (!config->expr_pool || config->expr_pool->next == config->expr_pool->end)
+ {
+ FcExprPage *new_page;
+
+ new_page = malloc (sizeof (FcExprPage));
+ if (!new_page)
+ return 0;
+ FcMemAlloc (FC_MEM_EXPR, sizeof (FcExprPage));
+
+ new_page->next_page = config->expr_pool;
+ new_page->next = new_page->exprs;
+ config->expr_pool = new_page;
+ }
+
+ return config->expr_pool->next++;
+}
+
FcConfig *
FcConfigReference (FcConfig *config)
{
FcConfigDestroy (FcConfig *config)
{
FcSetName set;
+ FcExprPage *page;
if (--config->ref > 0)
return;
if (config->fonts[set])
FcFontSetDestroy (config->fonts[set]);
+ page = config->expr_pool;
+ while (page)
+ {
+ FcExprPage *next = page->next_page;
+ FcMemFree (FC_MEM_EXPR, sizeof (FcExprPage));
+ free (page);
+ page = next;
+ }
+
free (config);
FcMemFree (FC_MEM_CONFIG, sizeof (FcConfig));
}
*/
FcBool
-FcConfigAddCache (FcConfig *config, FcCache *cache,
+FcConfigAddCache (FcConfig *config, FcCache *cache,
FcSetName set, FcStrSet *dirSet)
{
FcFontSet *fs;
FcStrList *dirlist;
FcChar8 *dir;
FcCache *cache;
-
+
dirlist = FcStrListCreate (dirSet);
if (!dirlist)
return FcFalse;
fonts = FcFontSetCreate ();
if (!fonts)
return FcFalse;
-
+
FcConfigSetFonts (config, fonts, FcSetSystem);
-
+
if (!FcConfigAddDirList (config, FcSetSystem, config->fontDirs))
return FcFalse;
if (FcDebug () & FC_DBG_FONTSET)
FcConfigAddDir (FcConfig *config,
const FcChar8 *d)
{
- return (FcConfigAddConfigDir (config, d) &&
+ return (FcConfigAddConfigDir (config, d) &&
FcConfigAddFontDir (config, d));
}
}
return FcStrListCreate (config->cacheDirs);
}
-
+
FcBool
FcConfigAddConfigFile (FcConfig *config,
const FcChar8 *f)
{
FcBool ret;
FcChar8 *file = FcConfigFilename (f);
-
+
if (!file)
return FcFalse;
-
+
ret = FcStrSetAdd (config->configFiles, file);
FcStrFree (file);
return ret;
FcChar32 blank)
{
FcBlanks *b, *freeme = 0;
-
+
b = config->blanks;
if (!b)
{
return FcConfigSetRescanInterval (config, rescanInterval);
}
-
+
FcBool
FcConfigAddEdit (FcConfig *config,
FcTest *test,
FcValue left = FcValueCanonicalize(left_o);
FcValue right = FcValueCanonicalize(right_o);
FcBool ret = FcFalse;
-
+
left = FcConfigPromote (left, right);
right = FcConfigPromote (right, left);
- if (left.type == right.type)
+ if (left.type == right.type)
{
switch (left.type) {
case FcTypeInteger:
case FcOpNotContains:
ret = left.u.d != right.u.d;
break;
- case FcOpLess:
+ case FcOpLess:
ret = left.u.d < right.u.d;
break;
- case FcOpLessEqual:
+ case FcOpLessEqual:
ret = left.u.d <= right.u.d;
break;
- case FcOpMore:
+ case FcOpMore:
ret = left.u.d > right.u.d;
break;
- case FcOpMoreEqual:
+ case FcOpMoreEqual:
ret = left.u.d >= right.u.d;
break;
default:
break;
case FcTypeBool:
switch (op) {
- case FcOpEqual:
+ case FcOpEqual:
case FcOpContains:
case FcOpListing:
ret = left.u.b == right.u.b;
break;
case FcTypeString:
switch (op) {
- case FcOpEqual:
+ case FcOpEqual:
case FcOpListing:
ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
break;
FcResult r;
FcMatrix *m;
FcChar8 *str;
-
+
switch (e->op) {
case FcOpInteger:
v.type = FcTypeInteger;
break;
case FcOpString:
v.type = FcTypeString;
- v.u.s = FcStrStaticName(e->u.sval);
+ v.u.s = e->u.sval;
+ v = FcValueSave (v);
break;
case FcOpMatrix:
v.type = FcTypeMatrix;
v.u.c = e->u.cval;
v = FcValueSave (v);
break;
+ case FcOpLangSet:
+ v.type = FcTypeLangSet;
+ v.u.l = e->u.lval;
+ v = FcValueSave (v);
+ break;
case FcOpBool:
v.type = FcTypeBool;
v.u.b = e->u.bval;
switch (vl.type) {
case FcTypeDouble:
switch (e->op) {
- case FcOpPlus:
+ case FcOpPlus:
v.type = FcTypeDouble;
- v.u.d = vl.u.d + vr.u.d;
+ v.u.d = vl.u.d + vr.u.d;
break;
case FcOpMinus:
v.type = FcTypeDouble;
- v.u.d = vl.u.d - vr.u.d;
+ v.u.d = vl.u.d - vr.u.d;
break;
case FcOpTimes:
v.type = FcTypeDouble;
- v.u.d = vl.u.d * vr.u.d;
+ v.u.d = vl.u.d * vr.u.d;
break;
case FcOpDivide:
v.type = FcTypeDouble;
- v.u.d = vl.u.d / vr.u.d;
+ v.u.d = vl.u.d / vr.u.d;
break;
default:
- v.type = FcTypeVoid;
+ v.type = FcTypeVoid;
break;
}
if (v.type == FcTypeDouble &&
v.u.b = vl.u.b && vr.u.b;
break;
default:
- v.type = FcTypeVoid;
+ v.type = FcTypeVoid;
break;
}
break;
str = FcStrPlus (vl.u.s, vr.u.s);
v.u.s = FcStrStaticName (str);
FcStrFree (str);
-
+
if (!v.u.s)
v.type = FcTypeVoid;
break;
break;
}
break;
+ case FcTypeCharSet:
+ switch (e->op) {
+ case FcOpPlus:
+ v.type = FcTypeCharSet;
+ v.u.c = FcCharSetUnion (vl.u.c, vr.u.c);
+ if (!v.u.c)
+ v.type = FcTypeVoid;
+ break;
+ case FcOpMinus:
+ v.type = FcTypeCharSet;
+ v.u.c = FcCharSetSubtract (vl.u.c, vr.u.c);
+ if (!v.u.c)
+ v.type = FcTypeVoid;
+ break;
+ default:
+ v.type = FcTypeVoid;
+ break;
+ }
+ break;
+ case FcTypeLangSet:
+ switch (e->op) {
+ case FcOpPlus:
+ v.type = FcTypeLangSet;
+ v.u.l = FcLangSetUnion (vl.u.l, vr.u.l);
+ if (!v.u.l)
+ v.type = FcTypeVoid;
+ break;
+ case FcOpMinus:
+ v.type = FcTypeLangSet;
+ v.u.l = FcLangSetSubtract (vl.u.l, vr.u.l);
+ if (!v.u.l)
+ v.type = FcTypeVoid;
+ break;
+ default:
+ v.type = FcTypeVoid;
+ break;
+ }
+ break;
default:
v.type = FcTypeVoid;
break;
FcExpr *e = t->expr;
FcValue value;
FcValueList *v;
-
+
while (e)
{
/* Compute the value of the match expression */
FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
{
FcValueList *l;
-
+
if (!e)
return 0;
l = (FcValueList *) malloc (sizeof (FcValueList));
{
FcValueListPtr *prev, last, v;
FcValueBinding sameBinding;
-
+
if (position)
sameBinding = position->binding;
else
if (position)
prev = &position->next;
else
- for (prev = head; *prev != NULL;
+ for (prev = head; *prev != NULL;
prev = &(*prev)->next)
;
}
{
if (position)
{
- for (prev = head; *prev != NULL;
+ for (prev = head; *prev != NULL;
prev = &(*prev)->next)
{
if (*prev == position)
FcValueListPrint (*head);
printf ("\n");
}
-
+
if (new)
{
last = new;
while (last->next != NULL)
last = last->next;
-
+
last->next = *prev;
*prev = new;
}
-
+
if (FcDebug () & FC_DBG_EDIT)
{
printf ("%s list after ", append ? "Append" : "Prepend");
FcValueListPrint (*head);
printf ("\n");
}
-
+
return FcTrue;
}
if (list)
{
FcPatternElt *e = FcPatternObjectInsertElt (p, object);
-
+
if (!e)
return;
FcConfigAdd (&e->values, 0, append, list);
if ((t->kind == FcMatchFont || kind == FcMatchPattern) &&
t->object == e->object)
{
- /*
+ /*
* KLUDGE - the pattern may have been reallocated or
* things may have been inserted or deleted above
* this element by other edits. Go back and find
{
FcValueList *thisValue = st[i].value;
FcValueList *nextValue = thisValue;
-
+
/*
* Append the new list of values after the current value
*/
}
else
fontconfig_path[0] = '\0';
-
+
break;
}
FcChar8 *path;
if (!dir)
- dir = (FcChar8 *) "";
- path = malloc (strlen ((char *) dir) + 1 + strlen ((char *) file) + 1);
- if (!path)
- return 0;
+ dir = (const FcChar8 *) "";
- strcpy ((char *) path, (const char *) dir);
- /* make sure there's a single separator */
-#ifdef _WIN32
- if ((!path[0] || (path[strlen((char *) path)-1] != '/' &&
- path[strlen((char *) path)-1] != '\\')) &&
- !(file[0] == '/' ||
- file[0] == '\\' ||
- (isalpha (file[0]) && file[1] == ':' && (file[2] == '/' || file[2] == '\\'))))
- strcat ((char *) path, "\\");
-#else
- if ((!path[0] || path[strlen((char *) path)-1] != '/') && file[0] != '/')
- strcat ((char *) path, "/");
-#endif
- strcat ((char *) path, (char *) file);
-
- FcMemAlloc (FC_MEM_STRING, strlen ((char *) path) + 1);
+ path = FcStrPathPlus (dir, file, NULL);
if (access ((char *) path, R_OK) == 0)
return path;
-
+
FcStrFree (path);
return 0;
}
if (env)
{
e = env;
- while (*e)
+ while (*e)
{
colon = (FcChar8 *) strchr ((char *) e, FC_SEARCH_PATH_SEPARATOR);
if (!colon)
i++;
}
}
-
+
#ifdef _WIN32
if (fontconfig_path[0] == '\0')
{
subdirs = FcStrSetCreate ();
if (!subdirs)
return FcFalse;
-
+
set = FcConfigGetFonts (config, FcSetApplication);
if (!set)
{
{
FcFontSet *set;
FcStrSet *dirs;
-
+
if (!config)
{
config = FcConfigGetCurrent ();
dirs = FcStrSetCreate ();
if (!dirs)
return FcFalse;
-
+
set = FcConfigGetFonts (config, FcSetApplication);
if (!set)
{
}
FcConfigSetFonts (config, set, FcSetApplication);
}
-
+
FcStrSetAddFilename (dirs, dir);
-
+
if (!FcConfigAddDirList (config, FcSetApplication, dirs))
{
FcStrSetDestroy (dirs);
{
FcChar8 c;
- while ((c = *glob++))
+ while ((c = *glob++))
{
switch (c) {
case '*':
const FcPattern *font)
{
int i;
-
+
for (i = 0; i < patterns->nfont; i++)
if (FcListPatternMatchAny (patterns->fonts[i], font))
return FcTrue;