diff --git a/src/fcint.h b/src/fcint.h index 80205c9..ea14811 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -969,6 +969,10 @@ FcValueListAppend (FcValueListPtr vallist, FcPrivate FcValueListPtr FcValueListDuplicate(FcValueListPtr orig); +FcPrivate FcValueListPtr +FcValueListDuplicateWithBinding(FcValueListPtr orig, + FcValueBinding binding); + FcPrivate FcPatternElt * FcPatternObjectFindElt (const FcPattern *p, FcObject object); diff --git a/src/fcmatch.c b/src/fcmatch.c index 46d08bc..f8c398f 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -356,6 +356,7 @@ FcCompareValueList (FcObject object, FcValueListPtr v1orig, /* pattern */ FcValueListPtr v2orig, /* target */ FcValue *bestValue, + FcValueBinding *bestBinding, double *value, int *n, FcResult *result) @@ -368,6 +369,8 @@ FcCompareValueList (FcObject object, { if (bestValue) *bestValue = FcValueCanonicalize(&v2orig->value); + if (bestBinding) + *bestBinding = FcValueBindingWeak; if (n) *n = 0; return FcTrue; @@ -392,6 +395,8 @@ FcCompareValueList (FcObject object, { if (bestValue) *bestValue = FcValueCanonicalize(&v2->value); + if (bestBinding) + *bestBinding = v1->binding; best = v; pos = k; } @@ -468,7 +473,7 @@ FcCompare (FcPattern *pat, if (!FcCompareValueList (elt_i1->object, match, FcPatternEltValues(elt_i1), FcPatternEltValues(elt_i2), - NULL, value, NULL, result)) + NULL, NULL, value, NULL, result)) return FcFalse; i1++; i2++; @@ -486,6 +491,7 @@ FcFontRenderPrepare (FcConfig *config, int i; FcPatternElt *fe, *pe; FcValue v; + FcValueBinding binding; FcResult result; assert (pat != NULL); @@ -497,6 +503,21 @@ FcFontRenderPrepare (FcConfig *config, for (i = 0; i < font->num; i++) { fe = &FcPatternElts(font)[i]; + pe = FcPatternObjectFindElt (pat, fe->object); + + binding = FcValueBindingWeak; + if (pe) + { + const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse); + if (!FcCompareValueList (pe->object, match, + FcPatternEltValues(pe), + FcPatternEltValues(fe), &v, &binding, NULL, NULL, &result)) + { + FcPatternDestroy (new); + return NULL; + } + } + if (fe->object == FC_FAMILYLANG_OBJECT || fe->object == FC_STYLELANG_OBJECT || fe->object == FC_FULLNAMELANG_OBJECT) @@ -530,7 +551,7 @@ FcFontRenderPrepare (FcConfig *config, if (!FcCompareValueList (pel->object, match, FcPatternEltValues (pel), - FcPatternEltValues (fel), NULL, NULL, &n, &result)) + FcPatternEltValues (fel), NULL, NULL, NULL, &n, &result)) { FcPatternDestroy (new); return NULL; @@ -545,22 +566,22 @@ FcFontRenderPrepare (FcConfig *config, if (l1) ln = FcValueListPrepend (ln, FcValueCanonicalize (&l1->value), - FcValueBindingStrong); + binding); if (l2) ll = FcValueListPrepend (ll, FcValueCanonicalize (&l2->value), - FcValueBindingStrong); + binding); } else { if (l1) ln = FcValueListAppend (ln, FcValueCanonicalize (&l1->value), - FcValueBindingStrong); + binding); if (l2) ll = FcValueListAppend (ll, FcValueCanonicalize (&l2->value), - FcValueBindingStrong); + binding); } } FcPatternObjectListAdd (new, fe->object, ln, FcFalse); @@ -574,8 +595,8 @@ FcFontRenderPrepare (FcConfig *config, * lang. */ FcValueListPtr l1, l2; - l1 = FcValueListDuplicate (FcPatternEltValues (fe)); - l2 = FcValueListDuplicate (FcPatternEltValues (fel)); + l1 = FcValueListDuplicateWithBinding (FcPatternEltValues (fe), binding); + l2 = FcValueListDuplicateWithBinding (FcPatternEltValues (fel), binding); FcPatternObjectListAdd (new, fe->object, l1, FcFalse); FcPatternObjectListAdd (new, fel->object, l2, FcFalse); @@ -583,23 +604,14 @@ FcFontRenderPrepare (FcConfig *config, } } - pe = FcPatternObjectFindElt (pat, fe->object); if (pe) { - const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse); - if (!FcCompareValueList (pe->object, match, - FcPatternEltValues(pe), - FcPatternEltValues(fe), &v, NULL, NULL, &result)) - { - FcPatternDestroy (new); - return NULL; - } - FcPatternObjectAdd (new, fe->object, v, FcFalse); + FcPatternObjectAddWithBinding (new, fe->object, v, binding, FcFalse); } else { FcPatternObjectListAdd (new, fe->object, - FcValueListDuplicate (FcPatternEltValues (fe)), + FcValueListDuplicateWithBinding (FcPatternEltValues (fe), binding), FcTrue); } } diff --git a/src/fcpat.c b/src/fcpat.c index 7e7d54a..c4681fa 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -243,6 +243,33 @@ FcValueListDuplicate(FcValueListPtr orig) return new; } +FcValueListPtr +FcValueListDuplicateWithBinding(FcValueListPtr orig, + FcValueBinding binding) +{ + FcValueListPtr new = NULL, l, t = NULL; + FcValue v; + + for (l = orig; l != NULL; l = FcValueListNext (l)) + { + if (!new) + { + t = new = FcValueListCreate(); + } + else + { + t->next = FcValueListCreate(); + t = FcValueListNext (t); + } + v = FcValueCanonicalize (&l->value); + t->value = FcValueSave (v); + t->binding = binding; + t->next = NULL; + } + + return new; +} + FcBool FcValueEqual (FcValue va, FcValue vb) {