2 * fontconfig/src/fcmatch.c
4 * Copyright © 2000 Keith Packard
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the author(s) not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. The authors make no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
28 FcCompareNumber (const FcValue *value1, const FcValue *value2, FcValue *bestValue)
32 switch ((int) value1->type) {
34 v1 = (double) value1->u.i;
42 switch ((int) value2->type) {
44 v2 = (double) value2->u.i;
55 *bestValue = FcValueCanonicalize (value2);
60 FcCompareString (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
62 *bestValue = FcValueCanonicalize (v2);
63 return (double) FcStrCmpIgnoreCase (FcValueString(v1), FcValueString(v2)) != 0;
67 FcCompareFamily (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
69 /* rely on the guarantee in FcPatternObjectAddWithBinding that
70 * families are always FcTypeString. */
71 const FcChar8* v1_string = FcValueString(v1);
72 const FcChar8* v2_string = FcValueString(v2);
74 *bestValue = FcValueCanonicalize (v2);
76 if (FcToLower(*v1_string) != FcToLower(*v2_string) &&
77 *v1_string != ' ' && *v2_string != ' ')
80 return (double) FcStrCmpIgnoreBlanksAndCase (v1_string, v2_string) != 0;
84 FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
86 const FcChar8 *v1_string = FcValueString (v1);
87 const FcChar8 *v2_string = FcValueString (v2);
91 *bestValue = FcValueCanonicalize (v2);
93 if (FcToLower (*v1_string) != FcToLower (*v2_string) &&
94 *v1_string != ' ' && *v2_string != ' ')
97 n = FcStrMatchIgnoreCaseAndDelims (v1_string, v2_string, (const FcChar8 *)" -");
98 len = strlen ((const char *)v1_string);
100 return (double)(len - n) / (double)len;
104 FcCompareLang (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
107 FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2);
109 switch ((int) value1.type) {
111 switch ((int) value2.type) {
113 result = FcLangSetCompare (value1.u.l, value2.u.l);
116 result = FcLangSetHasLang (value1.u.l,
124 switch ((int) value2.type) {
126 result = FcLangSetHasLang (value2.u.l, value1.u.s);
129 result = FcLangCompare (value1.u.s,
139 *bestValue = FcValueCanonicalize (v2);
143 case FcLangDifferentCountry:
145 case FcLangDifferentLang:
152 FcCompareBool (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
154 if (v2->type != FcTypeBool || v1->type != FcTypeBool)
157 if (v2->u.b != FcDontCare)
158 *bestValue = FcValueCanonicalize (v2);
160 *bestValue = FcValueCanonicalize (v1);
162 return (double) ((v2->u.b ^ v1->u.b) == 1);
166 FcCompareCharSet (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
168 *bestValue = FcValueCanonicalize (v2); /* TODO Improve. */
169 return (double) FcCharSetSubtractCount (FcValueCharSet(v1), FcValueCharSet(v2));
173 FcCompareRange (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
175 FcValue value1 = FcValueCanonicalize (v1);
176 FcValue value2 = FcValueCanonicalize (v2);
177 double b1, e1, b2, e2, d;
179 switch ((int) value1.type) {
181 b1 = e1 = value1.u.i;
184 b1 = e1 = value1.u.d;
187 b1 = value1.u.r->begin;
188 e1 = value1.u.r->end;
193 switch ((int) value2.type) {
195 b2 = e2 = value2.u.i;
198 b2 = e2 = value2.u.d;
201 b2 = value2.u.r->begin;
202 e2 = value2.u.r->end;
213 d = (FC_MAX (b1, b2) + FC_MIN (e1, e2)) * .5;
215 bestValue->type = FcTypeDouble;
218 /* If the ranges overlap, it's a match, otherwise return closest distance. */
219 if (e1 < b2 || e2 < b1)
220 return FC_MIN (fabs (b2 - e1), fabs (b1 - e2));
226 FcCompareSize (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
228 FcValue value1 = FcValueCanonicalize (v1);
229 FcValue value2 = FcValueCanonicalize (v2);
230 double b1, e1, b2, e2;
232 switch ((int) value1.type) {
234 b1 = e1 = value1.u.i;
237 b1 = e1 = value1.u.d;
241 b1 = value1.u.r->begin;
242 e1 = value1.u.r->end;
247 switch ((int) value2.type) {
249 b2 = e2 = value2.u.i;
252 b2 = e2 = value2.u.d;
255 b2 = value2.u.r->begin;
256 e2 = value2.u.r->end;
262 bestValue->type = FcTypeDouble;
263 bestValue->u.d = (b1 + e1) * .5;
265 /* If the ranges overlap, it's a match, otherwise return closest distance. */
266 if (e1 < b2 || e2 < b1)
267 return FC_MIN (fabs (b2 - e1), fabs (b1 - e2));
268 if (b2 != e2 && b1 == e2) /* Semi-closed interval. */
275 FcCompareFilename (const FcValue *v1, const FcValue *v2, FcValue *bestValue)
277 const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2);
278 *bestValue = FcValueCanonicalize (v2);
279 if (FcStrCmp (s1, s2) == 0)
281 else if (FcStrCmpIgnoreCase (s1, s2) == 0)
283 else if (FcStrGlobMatch (s1, s2))
290 /* Define priorities to -1 for objects that don't have a compare function. */
292 #define PRI_NULL(n) \
293 PRI_ ## n ## _STRONG = -1, \
294 PRI_ ## n ## _WEAK = -1,
296 #define PRI_FcCompareFamily(n) PRI1(n)
297 #define PRI_FcCompareString(n) PRI1(n)
298 #define PRI_FcCompareNumber(n) PRI1(n)
299 #define PRI_FcCompareBool(n) PRI1(n)
300 #define PRI_FcCompareFilename(n) PRI1(n)
301 #define PRI_FcCompareCharSet(n) PRI1(n)
302 #define PRI_FcCompareLang(n) PRI1(n)
303 #define PRI_FcComparePostScript(n) PRI1(n)
304 #define PRI_FcCompareRange(n) PRI1(n)
305 #define PRI_FcCompareSize(n) PRI1(n)
307 #define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
309 typedef enum _FcMatcherPriorityDummy {
311 } FcMatcherPriorityDummy;
316 /* Canonical match priority order. */
321 PRI_ ## n ## _STRONG = PRI_ ## n, \
322 PRI_ ## n ## _WEAK = PRI_ ## n
324 typedef enum _FcMatcherPriority {
333 PRI_POSTSCRIPT_NAME_STRONG,
336 PRI_POSTSCRIPT_NAME_WEAK,
355 typedef struct _FcMatcher {
357 double (*compare) (const FcValue *v1, const FcValue *v2, FcValue *bestValue);
362 * Order is significant, it defines the precedence of
363 * each value, earlier values are more significant than
366 #define FC_OBJECT(NAME, Type, Cmp) { FC_##NAME##_OBJECT, Cmp, PRI_##NAME##_STRONG, PRI_##NAME##_WEAK },
367 static const FcMatcher _FcMatchers [] = {
368 { FC_INVALID_OBJECT, NULL, -1, -1 },
373 static const FcMatcher*
374 FcObjectToMatcher (FcObject object,
380 case FC_FAMILYLANG_OBJECT:
381 case FC_STYLELANG_OBJECT:
382 case FC_FULLNAMELANG_OBJECT:
383 object = FC_LANG_OBJECT;
387 if (object > FC_MAX_BASE_OBJECT ||
388 !_FcMatchers[object].compare ||
389 _FcMatchers[object].strong == -1 ||
390 _FcMatchers[object].weak == -1)
393 return _FcMatchers + object;
397 FcCompareValueList (FcObject object,
398 const FcMatcher *match,
399 FcValueListPtr v1orig, /* pattern */
400 FcValueListPtr v2orig, /* target */
406 FcValueListPtr v1, v2;
407 double v, best, bestStrong, bestWeak;
413 *bestValue = FcValueCanonicalize(&v2orig->value);
423 for (v1 = v1orig; v1; v1 = FcValueListNext(v1))
425 for (v2 = v2orig, k = 0; v2; v2 = FcValueListNext(v2), k++)
428 v = (match->compare) (&v1->value, &v2->value, &matchValue);
431 *result = FcResultTypeMismatch;
438 *bestValue = matchValue;
442 if (v1->binding == FcValueBindingStrong)
455 if (FcDebug () & FC_DBG_MATCHV)
457 printf (" %s: %g ", FcObjectName (object), best);
458 FcValueListPrint (v1orig);
460 FcValueListPrint (v2orig);
465 int weak = match->weak;
466 int strong = match->strong;
468 value[strong] += best;
471 value[weak] += bestWeak;
472 value[strong] += bestStrong;
482 * Return a value indicating the distance between the two lists of
487 FcCompare (FcPattern *pat,
494 for (i = 0; i < PRI_END; i++)
499 while (i1 < pat->num && i2 < fnt->num)
501 FcPatternElt *elt_i1 = &FcPatternElts(pat)[i1];
502 FcPatternElt *elt_i2 = &FcPatternElts(fnt)[i2];
504 i = FcObjectCompare(elt_i1->object, elt_i2->object);
511 const FcMatcher *match = FcObjectToMatcher (elt_i1->object, FcFalse);
512 if (!FcCompareValueList (elt_i1->object, match,
513 FcPatternEltValues(elt_i1),
514 FcPatternEltValues(elt_i2),
515 NULL, value, NULL, result))
525 FcFontRenderPrepare (FcConfig *config,
531 FcPatternElt *fe, *pe;
534 FcBool variable = FcFalse;
537 assert (pat != NULL);
538 assert (font != NULL);
540 FcPatternObjectGetBool (font, FC_VARIABLE_OBJECT, 0, &variable);
541 assert (variable != FcDontCare);
543 FcStrBufInit (&variations, NULL, 0);
545 new = FcPatternCreate ();
548 for (i = 0; i < font->num; i++)
550 fe = &FcPatternElts(font)[i];
551 if (fe->object == FC_FAMILYLANG_OBJECT ||
552 fe->object == FC_STYLELANG_OBJECT ||
553 fe->object == FC_FULLNAMELANG_OBJECT)
555 /* ignore those objects. we need to deal with them
559 if (fe->object == FC_FAMILY_OBJECT ||
560 fe->object == FC_STYLE_OBJECT ||
561 fe->object == FC_FULLNAME_OBJECT)
563 FcPatternElt *fel, *pel;
565 FC_ASSERT_STATIC ((FC_FAMILY_OBJECT + 1) == FC_FAMILYLANG_OBJECT);
566 FC_ASSERT_STATIC ((FC_STYLE_OBJECT + 1) == FC_STYLELANG_OBJECT);
567 FC_ASSERT_STATIC ((FC_FULLNAME_OBJECT + 1) == FC_FULLNAMELANG_OBJECT);
569 fel = FcPatternObjectFindElt (font, fe->object + 1);
570 pel = FcPatternObjectFindElt (pat, fe->object + 1);
574 /* The font has name languages, and pattern asks for specific language(s).
575 * Match on language and and prefer that result.
576 * Note: Currently the code only give priority to first matching language.
579 FcValueListPtr l1, l2, ln = NULL, ll = NULL;
580 const FcMatcher *match = FcObjectToMatcher (pel->object, FcTrue);
582 if (!FcCompareValueList (pel->object, match,
583 FcPatternEltValues (pel),
584 FcPatternEltValues (fel), NULL, NULL, &n, &result))
586 FcPatternDestroy (new);
590 for (j = 0, l1 = FcPatternEltValues (fe), l2 = FcPatternEltValues (fel);
591 l1 != NULL || l2 != NULL;
592 j++, l1 = l1 ? FcValueListNext (l1) : NULL, l2 = l2 ? FcValueListNext (l2) : NULL)
597 ln = FcValueListPrepend (ln,
598 FcValueCanonicalize (&l1->value),
599 FcValueBindingStrong);
601 ll = FcValueListPrepend (ll,
602 FcValueCanonicalize (&l2->value),
603 FcValueBindingStrong);
608 ln = FcValueListAppend (ln,
609 FcValueCanonicalize (&l1->value),
610 FcValueBindingStrong);
612 ll = FcValueListAppend (ll,
613 FcValueCanonicalize (&l2->value),
614 FcValueBindingStrong);
617 FcPatternObjectListAdd (new, fe->object, ln, FcFalse);
618 FcPatternObjectListAdd (new, fel->object, ll, FcFalse);
624 /* Pattern doesn't ask for specific language. Copy all for name and
626 FcValueListPtr l1, l2;
628 l1 = FcValueListDuplicate (FcPatternEltValues (fe));
629 l2 = FcValueListDuplicate (FcPatternEltValues (fel));
630 FcPatternObjectListAdd (new, fe->object, l1, FcFalse);
631 FcPatternObjectListAdd (new, fel->object, l2, FcFalse);
637 pe = FcPatternObjectFindElt (pat, fe->object);
640 const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse);
641 if (!FcCompareValueList (pe->object, match,
642 FcPatternEltValues(pe),
643 FcPatternEltValues(fe), &v, NULL, NULL, &result))
645 FcPatternDestroy (new);
648 FcPatternObjectAdd (new, fe->object, v, FcFalse);
650 /* Set font-variations settings for standard axes in variable fonts. */
652 FcPatternEltValues(fe)->value.type == FcTypeRange &&
653 (fe->object == FC_WEIGHT_OBJECT ||
654 fe->object == FC_WIDTH_OBJECT ||
655 fe->object == FC_SIZE_OBJECT))
659 const char *tag = " ";
660 assert (v.type == FcTypeDouble);
663 FcStrBufChar (&variations, ',');
666 case FC_WEIGHT_OBJECT:
668 num = FcWeightToOpenType (num);
671 case FC_WIDTH_OBJECT:
679 sprintf ((char *) temp, "%4s=%g", tag, num);
680 FcStrBufString (&variations, temp);
685 if (FcRefIsConst (&font->ref) && fe->object == FC_FILE_OBJECT)
687 FcValueListPtr l = FcPatternEltValues (fe);
688 FcChar8 *dir, *alias;
690 while (l->value.type != FcTypeString)
691 l = FcValueListNext (l);
694 dir = FcStrDirname (FcValueString (&l->value));
696 config = FcConfigGetCurrent ();
697 if (config && FcHashTableFind (config->alias_table, dir, (void **) &alias))
699 FcChar8 *base = FcStrBasename (FcValueString (&l->value));
700 FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
705 v.type = FcTypeString;
707 FcPatternObjectAddWithBinding (new, fe->object,
708 FcValueCanonicalize (&v),
718 FcPatternObjectListAdd (new, fe->object,
719 FcValueListDuplicate (FcPatternEltValues (fe)),
724 for (i = 0; i < pat->num; i++)
726 pe = &FcPatternElts(pat)[i];
727 fe = FcPatternObjectFindElt (font, pe->object);
729 pe->object != FC_FAMILYLANG_OBJECT &&
730 pe->object != FC_STYLELANG_OBJECT &&
731 pe->object != FC_FULLNAMELANG_OBJECT)
733 FcPatternObjectListAdd (new, pe->object,
734 FcValueListDuplicate (FcPatternEltValues(pe)),
739 if (variable && variations.len)
741 FcChar8 *vars = NULL;
742 if (FcPatternObjectGetString (new, FC_FONT_VARIATIONS_OBJECT, 0, &vars) == FcResultMatch)
744 FcStrBufChar (&variations, ',');
745 FcStrBufString (&variations, vars);
746 FcPatternObjectDel (new, FC_FONT_VARIATIONS_OBJECT);
749 FcPatternObjectAddString (new, FC_FONT_VARIATIONS_OBJECT, FcStrBufDoneStatic (&variations));
750 FcStrBufDestroy (&variations);
753 FcConfigSubstituteWithPat (config, new, pat, FcMatchFont);
758 FcFontSetMatchInternal (FcFontSet **sets,
763 double score[PRI_END], bestscore[PRI_END];
770 for (i = 0; i < PRI_END; i++)
773 if (FcDebug () & FC_DBG_MATCH)
778 for (set = 0; set < nsets; set++)
783 for (f = 0; f < s->nfont; f++)
785 if (FcDebug () & FC_DBG_MATCHV)
787 printf ("Font %d ", f);
788 FcPatternPrint (s->fonts[f]);
790 if (!FcCompare (p, s->fonts[f], score, result))
792 if (FcDebug () & FC_DBG_MATCHV)
795 for (i = 0; i < PRI_END; i++)
797 printf (" %g", score[i]);
801 for (i = 0; i < PRI_END; i++)
803 if (best && bestscore[i] < score[i])
805 if (!best || score[i] < bestscore[i])
807 for (i = 0; i < PRI_END; i++)
808 bestscore[i] = score[i];
815 if (FcDebug () & FC_DBG_MATCH)
817 printf ("Best score");
818 for (i = 0; i < PRI_END; i++)
819 printf (" %g", bestscore[i]);
821 FcPatternPrint (best);
823 if (FcDebug () & FC_DBG_MATCH2)
825 char *env = getenv ("FC_DBG_MATCH_FILTER");
826 FcObjectSet *os = NULL;
834 ss = s = strdup (env);
835 os = FcObjectSetCreate ();
841 if (!(p = strchr (s, ',')))
844 len = strlen (s) + 1;
850 x = malloc (sizeof (char) * len);
851 strncpy (x, s, len - 1);
853 if (FcObjectFromName (x) > 0)
854 FcObjectSetAdd (os, x);
860 FcPatternPrint2 (p, best, os);
862 FcObjectSetDestroy (os);
864 /* assuming that 'result' is initialized with FcResultNoMatch
865 * outside this function */
867 *result = FcResultMatch;
873 FcFontSetMatch (FcConfig *config,
881 assert (sets != NULL);
883 assert (result != NULL);
885 *result = FcResultNoMatch;
889 config = FcConfigGetCurrent ();
893 best = FcFontSetMatchInternal (sets, nsets, p, result);
895 return FcFontRenderPrepare (config, p, best);
901 FcFontMatch (FcConfig *config,
910 assert (result != NULL);
912 *result = FcResultNoMatch;
916 config = FcConfigGetCurrent ();
921 if (config->fonts[FcSetSystem])
922 sets[nsets++] = config->fonts[FcSetSystem];
923 if (config->fonts[FcSetApplication])
924 sets[nsets++] = config->fonts[FcSetApplication];
926 best = FcFontSetMatchInternal (sets, nsets, p, result);
928 return FcFontRenderPrepare (config, p, best);
933 typedef struct _FcSortNode {
935 double score[PRI_END];
939 FcSortCompare (const void *aa, const void *ab)
941 FcSortNode *a = *(FcSortNode **) aa;
942 FcSortNode *b = *(FcSortNode **) ab;
943 double *as = &a->score[0];
944 double *bs = &b->score[0];
945 double ad = 0, bd = 0;
949 while (i-- && (ad = *as++) == (bd = *bs++))
951 return ad < bd ? -1 : ad > bd ? 1 : 0;
955 FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **csp, FcBool trim)
957 FcBool ret = FcFalse;
964 cs = FcCharSetCreate ();
969 for (i = 0; i < nnode; i++)
971 FcSortNode *node = *n++;
972 FcBool adds_chars = FcFalse;
975 * Only fetch node charset if we'd need it
981 if (FcPatternGetCharSet (node->pattern, FC_CHARSET, 0, &ncs) !=
985 if (!FcCharSetMerge (cs, ncs, &adds_chars))
990 * If this font isn't a subset of the previous fonts,
993 if (!i || !trim || adds_chars)
995 FcPatternReference (node->pattern);
996 if (FcDebug () & FC_DBG_MATCHV)
999 FcPatternPrint (node->pattern);
1001 if (!FcFontSetAdd (fs, node->pattern))
1003 FcPatternDestroy (node->pattern);
1018 FcCharSetDestroy (cs);
1024 FcFontSetSortDestroy (FcFontSet *fs)
1026 FcFontSetDestroy (fs);
1030 FcFontSetSort (FcConfig *config FC_UNUSED,
1041 FcSortNode **nodeps, **nodep;
1048 FcBool *patternLangSat;
1049 FcValue patternLang;
1051 assert (sets != NULL);
1053 assert (result != NULL);
1055 /* There are some implementation that relying on the result of
1056 * "result" to check if the return value of FcFontSetSort
1058 * So we should initialize it to the conservative way since
1059 * this function doesn't return NULL anymore.
1062 *result = FcResultNoMatch;
1064 if (FcDebug () & FC_DBG_MATCH)
1070 for (set = 0; set < nsets; set++)
1078 return FcFontSetCreate ();
1080 for (nPatternLang = 0;
1081 FcPatternGet (p, FC_LANG, nPatternLang, &patternLang) == FcResultMatch;
1086 nodes = malloc (nnodes * sizeof (FcSortNode) +
1087 nnodes * sizeof (FcSortNode *) +
1088 nPatternLang * sizeof (FcBool));
1091 nodeps = (FcSortNode **) (nodes + nnodes);
1092 patternLangSat = (FcBool *) (nodeps + nnodes);
1096 for (set = 0; set < nsets; set++)
1101 for (f = 0; f < s->nfont; f++)
1103 if (FcDebug () & FC_DBG_MATCHV)
1105 printf ("Font %d ", f);
1106 FcPatternPrint (s->fonts[f]);
1108 new->pattern = s->fonts[f];
1109 if (!FcCompare (p, new->pattern, new->score, result))
1111 if (FcDebug () & FC_DBG_MATCHV)
1114 for (i = 0; i < PRI_END; i++)
1116 printf (" %g", new->score[i]);
1126 nnodes = new - nodes;
1128 qsort (nodeps, nnodes, sizeof (FcSortNode *),
1131 for (i = 0; i < nPatternLang; i++)
1132 patternLangSat[i] = FcFalse;
1134 for (f = 0; f < nnodes; f++)
1136 FcBool satisfies = FcFalse;
1138 * If this node matches any language, go check
1139 * which ones and satisfy those entries
1141 if (nodeps[f]->score[PRI_LANG] < 2000)
1143 for (i = 0; i < nPatternLang; i++)
1147 if (!patternLangSat[i] &&
1148 FcPatternGet (p, FC_LANG, i, &patternLang) == FcResultMatch &&
1149 FcPatternGet (nodeps[f]->pattern, FC_LANG, 0, &nodeLang) == FcResultMatch)
1152 double compare = FcCompareLang (&patternLang, &nodeLang, &matchValue);
1153 if (compare >= 0 && compare < 2)
1155 if (FcDebug () & FC_DBG_MATCHV)
1160 if (FcPatternGetString (nodeps[f]->pattern, FC_FAMILY, 0, &family) == FcResultMatch &&
1161 FcPatternGetString (nodeps[f]->pattern, FC_STYLE, 0, &style) == FcResultMatch)
1162 printf ("Font %s:%s matches language %d\n", family, style, i);
1164 patternLangSat[i] = FcTrue;
1173 nodeps[f]->score[PRI_LANG] = 10000.0;
1178 * Re-sort once the language issues have been settled
1180 qsort (nodeps, nnodes, sizeof (FcSortNode *),
1183 ret = FcFontSetCreate ();
1187 if (!FcSortWalk (nodeps, nnodes, ret, csp, trim))
1192 if (FcDebug() & FC_DBG_MATCH)
1194 printf ("First font ");
1195 FcPatternPrint (ret->fonts[0]);
1198 *result = FcResultMatch;
1203 FcFontSetDestroy (ret);
1211 FcFontSort (FcConfig *config,
1221 assert (result != NULL);
1223 *result = FcResultNoMatch;
1227 config = FcConfigGetCurrent ();
1232 if (config->fonts[FcSetSystem])
1233 sets[nsets++] = config->fonts[FcSetSystem];
1234 if (config->fonts[FcSetApplication])
1235 sets[nsets++] = config->fonts[FcSetApplication];
1236 return FcFontSetSort (config, sets, nsets, p, trim, csp, result);
1239 #include "fcaliastail.h"