* PERFORMANCE OF THIS SOFTWARE.
*/
+#include "fcint.h"
#include <string.h>
#include <ctype.h>
-#include "fcint.h"
#include <stdio.h>
static double
matchObjectPtrsInit = FcTrue;
}
-static FcBool
-FcCompareValueList (FcObjectPtr o,
- FcValueListPtr v1orig, /* pattern */
- FcValueListPtr v2orig, /* target */
- FcValue *bestValue,
- double *value,
- FcResult *result)
+static FcMatcher*
+FcObjectPtrToMatcher (FcObjectPtr o)
{
- FcValueListPtr v1, v2;
- FcValueList *v1_ptrU, *v2_ptrU;
- double v, best, bestStrong, bestWeak;
- int i;
- int j;
- const char *object = FcObjectPtrU(o);
+ int i;
+ const char *object = FcObjectPtrU(o);
- /*
- * Locate the possible matching entry by examining the
- * first few characters in object
- */
i = -1;
switch (object[0]) {
case 'f':
i = MATCH_OUTLINE; break;
}
+ if (i < 0)
+ return 0;
+
if (!matchObjectPtrsInit)
FcMatchObjectPtrsInit();
- if (_FcMatchers[i].objectPtr != o) i = -1;
- if (i == -1 ||
- FcStrCmpIgnoreCase ((FcChar8 *) _FcMatchers[i].object,
- (FcChar8 *) object) != 0)
+ if (o != _FcMatchers[i].objectPtr)
+ return 0;
+
+ return _FcMatchers+i;
+}
+
+static FcBool
+FcCompareValueList (FcObjectPtr o,
+ FcValueListPtr v1orig, /* pattern */
+ FcValueListPtr v2orig, /* target */
+ FcValue *bestValue,
+ double *value,
+ FcResult *result)
+{
+ FcValueListPtr v1, v2;
+ FcValueList *v1_ptrU, *v2_ptrU;
+ double v, best, bestStrong, bestWeak;
+ int j;
+ const char *object = FcObjectPtrU(o);
+ FcMatcher *match = FcObjectPtrToMatcher(o);
+
+ if (!match)
{
if (bestValue)
*bestValue = FcValueCanonicalize(&FcValueListPtrU(v2orig)->value);
return FcTrue;
}
+
best = 1e99;
bestStrong = 1e99;
bestWeak = 1e99;
j = 0;
for (v1 = v1orig, v1_ptrU = FcValueListPtrU(v1); v1_ptrU;
- v1 = FcValueListPtrU(v1)->next, v1_ptrU = FcValueListPtrU(v1))
+ v1 = v1_ptrU->next, v1_ptrU = FcValueListPtrU(v1))
{
- for (v2 = v2orig, v2_ptrU = FcValueListPtrU(v2); FcValueListPtrU(v2);
- v2 = FcValueListPtrU(v2)->next)
+ for (v2 = v2orig, v2_ptrU = FcValueListPtrU(v2); v2_ptrU;
+ v2 = v2_ptrU->next, v2_ptrU = FcValueListPtrU(v2))
{
- v = (*_FcMatchers[i].compare) (&v1_ptrU->value,
- &v2_ptrU->value);
+ v = (match->compare) (&v1_ptrU->value, &v2_ptrU->value);
if (v < 0)
{
*result = FcResultTypeMismatch;
}
if (value)
{
- int weak = _FcMatchers[i].weak;
- int strong = _FcMatchers[i].strong;
+ int weak = match->weak;
+ int strong = match->strong;
if (weak == strong)
value[strong] += best;
else
FcValueCanonicalize(&FcValueListPtrU(pe->values)->value), FcTrue);
}
- if (FcPatternFindElt (font, FC_FILE))
- FcPatternTransferFullFname (new, font);
-
FcConfigSubstituteWithPat (config, new, pat, FcMatchFont);
return new;
}
{
config = FcConfigGetCurrent ();
if (!config)
- {
- *result = FcResultOutOfMemory;
return 0;
- }
}
for (set = 0; set < nsets; set++)
{
}
static FcBool
-FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool trim)
+FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool trim, FcBool build_cs)
{
FcCharSet *ncs;
FcSortNode *node;
*/
if (!trim || !*cs || !FcCharSetIsSubset (ncs, *cs))
{
- if (*cs)
- {
- ncs = FcCharSetUnion (ncs, *cs);
- if (!ncs)
- return FcFalse;
- FcCharSetDestroy (*cs);
- }
- else
- ncs = FcCharSetCopy (ncs);
- *cs = ncs;
+ if (trim || build_cs)
+ {
+ if (*cs)
+ {
+ ncs = FcCharSetUnion (ncs, *cs);
+ if (!ncs)
+ return FcFalse;
+ FcCharSetDestroy (*cs);
+ }
+ else
+ ncs = FcCharSetCopy (ncs);
+ *cs = ncs;
+ }
+
FcPatternReference (node->pattern);
if (FcDebug () & FC_DBG_MATCH)
{
cs = 0;
- if (!FcSortWalk (nodeps, nnodes, ret, &cs, trim))
+ if (!FcSortWalk (nodeps, nnodes, ret, &cs, trim, (csp!=0)))
goto bail2;
if (csp)
*csp = cs;
else
- FcCharSetDestroy (cs);
+ {
+ if (cs)
+ FcCharSetDestroy (cs);
+ }
free (nodes);