- int cand_elt;
- FcPatternElt *cand_elts;
-
- if (match_blocked[f + sets_offset[set]] == 1)
- continue;
-
- score = 1e99;
- cand_elts = FcPatternEltU(s->fonts[f]->elts);
-
- /* Look for the appropriate element in this candidate
- * pattern 'f' and evaluate its score wrt 'p'. */
- for (cand_elt = 0; cand_elt < s->fonts[f]->num; ++cand_elt)
- {
- if (cand_elts[cand_elt].object == pat_elts[scoring_index]->object)
- {
- FcValueListPtr v2;
- FcValueList *v2_ptrU;
-
- for (v2 = cand_elts[cand_elt].values, v2_ptrU = FcValueListPtrU(v2);
- v2_ptrU;
- v2 = v2_ptrU->next, v2_ptrU = FcValueListPtrU(v2))
- {
- double v = (matcher->compare)(&v1_ptrU->value, &v2_ptrU->value);
-
- if (v < 0)
- {
- *result = FcResultTypeMismatch;
- free (match_blocked);
- free (sets_offset);
- return 0;
- }
-
- /* I'm actually kind of surprised that
- * this isn't v + 100 * v1_offset. -PL */
- v = v * 100 + v1_offset;
- /* The old patch said score += v, which
- * seems to be wrong when you have
- * multiple matchers. This takes the
- * best score it can find for that font. */
- if (v < score)
- score = v;
- }
- }
- }
-
- /* We had no matching, just try the next one */
- if (score == 1e99)
- {
- match_blocked[f + sets_offset[set]] = 2;
- continue;
- }
- match_blocked[f + sets_offset[set]] = 0;
- /* If there's a previous champion, and current score
- * beats previous best score, on this element, then
- * knock out the previous champion and anything
- * else that we would have visited previous to f;
- * clearly anything previous to f would have been
- * less than f on this score. */
- if (!best || score < bestscore)
- {
- if (best)
- {
- int b;
- for (b = block_start; b < f + sets_offset[set]; ++b)
- if (!match_blocked[b])
- {
- match_blocked[b] = 1;
- --fonts_left;
- }
- }
-
- bestscore = score;
- best = s->fonts[f];
- /* This kills too many fonts, unfortunately. */
- /* block_start = f + sets_offset[set]; */
- }
-
- /* If f loses, then it's out too. */
- if (best && score > bestscore)
- {
- match_blocked[f + sets_offset[set]] = 1;
- --fonts_left;
- }
-
- /* If there is only 1 font left and the best is set,
- * then just return this font
- */
- if (fonts_left == 1 && best)
- goto end;
-
- /* Otherwise, f is equal to best on this element.
- * Carry on to next pattern element. */