From 1ed98a0c87931ae93ea3d46f3d0367a99218679c Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Mon, 28 Nov 2005 10:54:11 +0000 Subject: [PATCH] Stephan Kulow reviewed by: plam Don't kill all fonts during match (oops!) --- ChangeLog | 23 +++++++++++++++++++++++ src/fcmatch.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a4cf76..7c402be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2005-11-28 Dirk Mueller + Stephan Kulow + reviewed by: plam + + * src/fcmatch.c (FcFontSetMatch): + + Don't kill all fonts during match (oops!) + + +2005-11-25 Dirk Mueller + Stephan Kulow + Michael Matz + reviewed by: plam + + * src/fcmatch.c (FcObjectPtrToMatcher, FcCompareValueList, + FcFontSetMatch): + + Rewrite FcFontSetMatch to a path-finding based algorithm, i.e. + inline FcCompare into FcFontSetMatch and reorder the + loops, adding a boolean array which blocks patterns from future + consideration if they're known to not be best on some past + criterion. + 2005-11-26 Dirk Mueller reviewed by: plam diff --git a/src/fcmatch.c b/src/fcmatch.c index 0af0c83..93e3860 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -534,11 +534,15 @@ FcFontSetMatch (FcConfig *config, } for (set = 0; set < nsets; set++) { + FcBool *matchBlocked; + int blockStart; + s = sets[set]; if (!s) continue; - char* matchBlocked = (char*)calloc(s->nfont, sizeof(FcBool)); + matchBlocked = (FcBool*)calloc(s->nfont, sizeof(FcBool)); + blockStart = 0; /* The old algorithm checked if each font beat 'best', * scanning all of the value lists for all of the pattern elts. */ @@ -575,19 +579,29 @@ FcFontSetMatch (FcConfig *config, if (!match) continue; - bestscore = 1e99; - - for (v1 = pat_elts[pat_elt].values, v1_ptrU = FcValueListPtrU(v1); v1_ptrU; v1 = FcValueListPtrU(v1)->next, v1_ptrU = FcValueListPtrU(v1), v1_offset++) { - - if (v1_ptrU->binding == FcValueBindingWeak + if ((v1_ptrU->binding == FcValueBindingWeak && scoring_index != match->weak) + || (v1_ptrU->binding == FcValueBindingStrong + && scoring_index != match->strong) + ) continue; + bestscore = 1e99; + + if (FcDebug () & FC_DBG_MATCHV) + { + int blocked_fonts = 0; + for (f = 0; f < s->nfont; f++) + blocked_fonts += matchBlocked[f] ? 1 : 0; + printf("Scoring Index %d, Value %d: %d(%d) fonts left\n", + scoring_index, v1_offset, s->nfont - blocked_fonts, s->nfont); + } + for (f = 0; f < s->nfont; f++) { int cand_elt; @@ -644,12 +658,13 @@ FcFontSetMatch (FcConfig *config, if (best) { int b; - for (b = 0; b < f; ++b) + for (b = blockStart; b < f; ++b) matchBlocked[b] = FcTrue; } bestscore = score; best = s->fonts[f]; + blockStart = f; } /* If f loses, then it's out too. */ @@ -659,10 +674,20 @@ FcFontSetMatch (FcConfig *config, /* Otherwise, f is equal to best on this element. * Carry on to next pattern element. */ } + if ((FcDebug () & FC_DBG_MATCHV) && best) + { + printf ("Best match (scoring index %d) candidate ", scoring_index); + FcPatternPrint (best); + } } } free (matchBlocked); } + if ((FcDebug () & FC_DBG_MATCH) && best) + { + printf ("Best match "); + FcPatternPrint (best); + } if (!best) { *result = FcResultNoMatch; -- 2.39.2