Add ref counting to font config patterns so that FcFontSort return values
are persistant
This commit is contained in:
parent
06a48f2073
commit
6f6563edb5
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.15 2002/06/02 20:52:06 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.16 2002/06/03 08:31:15 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -585,6 +585,9 @@ FcPatternCreate (void);
|
||||||
FcPattern *
|
FcPattern *
|
||||||
FcPatternDuplicate (FcPattern *p);
|
FcPatternDuplicate (FcPattern *p);
|
||||||
|
|
||||||
|
void
|
||||||
|
FcPatternReference (FcPattern *p);
|
||||||
|
|
||||||
void
|
void
|
||||||
FcValueDestroy (FcValue v);
|
FcValueDestroy (FcValue v);
|
||||||
|
|
||||||
|
|
|
@ -109,10 +109,13 @@
|
||||||
|
|
||||||
if 'qual' is 'any', then the match succeeds if any value in the field matches.
|
if 'qual' is 'any', then the match succeeds if any value in the field matches.
|
||||||
if 'qual' is 'all', then the match succeeds only if all values match.
|
if 'qual' is 'all', then the match succeeds only if all values match.
|
||||||
|
if 'qual' is 'first', then the match succeeds only if the first value matches.
|
||||||
|
if 'qual' is 'not_first', then the match succeeds only if any value other than
|
||||||
|
the first matches.
|
||||||
-->
|
-->
|
||||||
<!ELEMENT test (%expr;)*>
|
<!ELEMENT test (%expr;)*>
|
||||||
<!ATTLIST test
|
<!ATTLIST test
|
||||||
qual (any|all) "any"
|
qual (any|all|first|not_first) "any"
|
||||||
name CDATA #REQUIRED
|
name CDATA #REQUIRED
|
||||||
compare (eq|not_eq|less|less_eq|more|more_eq) "eq">
|
compare (eq|not_eq|less|less_eq|more|more_eq) "eq">
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fccache.c,v 1.4 2002/03/01 01:00:54 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fccache.c,v 1.7 2002/05/21 17:06:22 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -594,9 +594,16 @@ FcFileCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *cache_file)
|
||||||
{
|
{
|
||||||
printf (" dir cache file \"%s\"\n", file);
|
printf (" dir cache file \"%s\"\n", file);
|
||||||
}
|
}
|
||||||
FcPatternAddString (font, FC_FILE, path);
|
if (!FcPatternAddString (font, FC_FILE, path))
|
||||||
if (!FcFontSetAdd (set, font))
|
{
|
||||||
|
FcPatternDestroy (font);
|
||||||
goto bail2;
|
goto bail2;
|
||||||
|
}
|
||||||
|
if (!FcFontSetAdd (set, font))
|
||||||
|
{
|
||||||
|
FcPatternDestroy (font);
|
||||||
|
goto bail2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path != path_buf)
|
if (path != path_buf)
|
||||||
|
|
|
@ -1129,6 +1129,10 @@ FcConfigSubstitute (FcConfig *config,
|
||||||
st[i].value = FcConfigMatchValueList (p, t, st[i].elt->values);
|
st[i].value = FcConfigMatchValueList (p, t, st[i].elt->values);
|
||||||
if (!st[i].value)
|
if (!st[i].value)
|
||||||
break;
|
break;
|
||||||
|
if (t->qual == FcQualFirst && st[i].value != st[i].elt->values)
|
||||||
|
break;
|
||||||
|
if (t->qual == FcQualNotFirst && st[i].value == st[i].elt->values)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fcdbg.c,v 1.2 2002/02/18 22:29:28 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fcdbg.c,v 1.3 2002/06/02 21:07:56 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -215,6 +215,12 @@ FcTestPrint (FcTest *test)
|
||||||
case FcQualAll:
|
case FcQualAll:
|
||||||
printf ("all ");
|
printf ("all ");
|
||||||
break;
|
break;
|
||||||
|
case FcQualFirst:
|
||||||
|
printf ("first ");
|
||||||
|
break;
|
||||||
|
case FcQualNotFirst:
|
||||||
|
printf ("not_first ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
printf ("%s ", test->field);
|
printf ("%s ", test->field);
|
||||||
FcOpPrint (test->op);
|
FcOpPrint (test->op);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fcdir.c,v 1.2 2002/02/15 06:01:28 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fcdir.c,v 1.5 2002/05/21 17:06:22 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -71,7 +71,8 @@ FcFileScan (FcFontSet *set,
|
||||||
{
|
{
|
||||||
font = FcNameParse (name);
|
font = FcNameParse (name);
|
||||||
if (font)
|
if (font)
|
||||||
FcPatternAddString (font, FC_FILE, file);
|
if (!FcPatternAddString (font, FC_FILE, file))
|
||||||
|
ret = FcFalse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.12 2002/05/31 23:21:25 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.13 2002/06/03 08:31:15 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -94,13 +94,14 @@ typedef struct _FcValueList {
|
||||||
|
|
||||||
typedef struct _FcPatternElt {
|
typedef struct _FcPatternElt {
|
||||||
const char *object;
|
const char *object;
|
||||||
FcValueList *values;
|
FcValueList *values;
|
||||||
} FcPatternElt;
|
} FcPatternElt;
|
||||||
|
|
||||||
struct _FcPattern {
|
struct _FcPattern {
|
||||||
int num;
|
int num;
|
||||||
int size;
|
int size;
|
||||||
FcPatternElt *elts;
|
int ref;
|
||||||
|
FcPatternElt *elts;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum _FcOp {
|
typedef enum _FcOp {
|
||||||
|
@ -134,7 +135,7 @@ typedef struct _FcExpr {
|
||||||
} FcExpr;
|
} FcExpr;
|
||||||
|
|
||||||
typedef enum _FcQual {
|
typedef enum _FcQual {
|
||||||
FcQualAny, FcQualAll
|
FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
|
||||||
} FcQual;
|
} FcQual;
|
||||||
|
|
||||||
typedef struct _FcTest {
|
typedef struct _FcTest {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.4 2002/06/02 21:07:56 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.5 2002/06/03 08:31:15 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
|
|
@ -329,16 +329,30 @@ FcFontRenderPrepare (FcConfig *config,
|
||||||
pe = FcPatternFindElt (pat, fe->object);
|
pe = FcPatternFindElt (pat, fe->object);
|
||||||
if (pe)
|
if (pe)
|
||||||
{
|
{
|
||||||
|
int j;
|
||||||
|
double score[NUM_MATCHER];
|
||||||
|
|
||||||
|
for (j = 0; j < NUM_MATCHER; j++)
|
||||||
|
score[j] = 0;
|
||||||
if (!FcCompareValueList (pe->object, pe->values,
|
if (!FcCompareValueList (pe->object, pe->values,
|
||||||
fe->values, &v, 0, &result))
|
fe->values, &v, 0, &result))
|
||||||
{
|
{
|
||||||
FcPatternDestroy (new);
|
FcPatternDestroy (new);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
for (j = 0; j < NUM_MATCHER; j++)
|
||||||
|
if (score[j] >= 100.0)
|
||||||
|
{
|
||||||
|
FcValueList *pv;
|
||||||
|
|
||||||
|
for (pv = pe->values; pv; pv = pv->next)
|
||||||
|
FcPatternAdd (new, fe->object, pv->value, FcTrue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
v = fe->values->value;
|
v = fe->values->value;
|
||||||
FcPatternAdd (new, fe->object, v, FcTrue);
|
FcPatternAdd (new, fe->object, v, FcFalse);
|
||||||
}
|
}
|
||||||
for (i = 0; i < pat->num; i++)
|
for (i = 0; i < pat->num; i++)
|
||||||
{
|
{
|
||||||
|
@ -502,8 +516,12 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool tri
|
||||||
else
|
else
|
||||||
ncs = FcCharSetCopy (ncs);
|
ncs = FcCharSetCopy (ncs);
|
||||||
*cs = ncs;
|
*cs = ncs;
|
||||||
|
FcPatternReference (node->pattern);
|
||||||
if (!FcFontSetAdd (fs, node->pattern))
|
if (!FcFontSetAdd (fs, node->pattern))
|
||||||
|
{
|
||||||
|
FcPatternDestroy (node->pattern);
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +531,6 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool tri
|
||||||
void
|
void
|
||||||
FcFontSetSortDestroy (FcFontSet *fs)
|
FcFontSetSortDestroy (FcFontSet *fs)
|
||||||
{
|
{
|
||||||
fs->nfont = 0;
|
|
||||||
FcFontSetDestroy (fs);
|
FcFontSetDestroy (fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.6 2002/06/02 21:07:57 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.7 2002/06/03 08:31:15 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -143,6 +143,7 @@ static const FcConstant _FcBaseConstants[] = {
|
||||||
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
|
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
|
||||||
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
|
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
|
||||||
|
|
||||||
|
{ (FcChar8 *) "none", "rgba", FC_RGBA_NONE },
|
||||||
{ (FcChar8 *) "rgb", "rgba", FC_RGBA_RGB, },
|
{ (FcChar8 *) "rgb", "rgba", FC_RGBA_RGB, },
|
||||||
{ (FcChar8 *) "bgr", "rgba", FC_RGBA_BGR, },
|
{ (FcChar8 *) "bgr", "rgba", FC_RGBA_BGR, },
|
||||||
{ (FcChar8 *) "vrgb", "rgba", FC_RGBA_VRGB },
|
{ (FcChar8 *) "vrgb", "rgba", FC_RGBA_VRGB },
|
||||||
|
|
12
src/fcpat.c
12
src/fcpat.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.6 2002/05/31 23:21:25 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.7 2002/06/03 08:31:15 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -38,6 +38,7 @@ FcPatternCreate (void)
|
||||||
p->num = 0;
|
p->num = 0;
|
||||||
p->size = 0;
|
p->size = 0;
|
||||||
p->elts = 0;
|
p->elts = 0;
|
||||||
|
p->ref = 1;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +232,9 @@ FcPatternDestroy (FcPattern *p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (--p->ref > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < p->num; i++)
|
for (i = 0; i < p->num; i++)
|
||||||
FcValueListDestroy (p->elts[i].values);
|
FcValueListDestroy (p->elts[i].values);
|
||||||
|
|
||||||
|
@ -706,6 +710,12 @@ bail0:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FcPatternReference (FcPattern *p)
|
||||||
|
{
|
||||||
|
p->ref++;
|
||||||
|
}
|
||||||
|
|
||||||
FcPattern *
|
FcPattern *
|
||||||
FcPatternVaBuild (FcPattern *orig, va_list va)
|
FcPatternVaBuild (FcPattern *orig, va_list va)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1316,6 +1316,10 @@ FcParseTest (FcConfigParse *parse)
|
||||||
qual = FcQualAny;
|
qual = FcQualAny;
|
||||||
else if (!strcmp ((char *) qual_string, "all"))
|
else if (!strcmp ((char *) qual_string, "all"))
|
||||||
qual = FcQualAll;
|
qual = FcQualAll;
|
||||||
|
else if (!strcmp ((char *) qual_string, "first"))
|
||||||
|
qual = FcQualFirst;
|
||||||
|
else if (!strcmp ((char *) qual_string, "not_first"))
|
||||||
|
qual = FcQualNotFirst;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FcConfigMessage (parse, FcSevereWarning, "invalid test qual \"%s\"", qual_string);
|
FcConfigMessage (parse, FcSevereWarning, "invalid test qual \"%s\"", qual_string);
|
||||||
|
|
Loading…
Reference in New Issue