aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fcmatch.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-02-07 10:17:56 +0100
committermarha <marha@users.sourceforge.net>2013-02-07 10:17:56 +0100
commit956c20498738c242726b5a42ed28db8572a90bed (patch)
treebf663b89417d0d9d7b37575eb0260d5a10af0e12 /fontconfig/src/fcmatch.c
parent76c527be60066b647468ad66f8e4d7dd18fa1769 (diff)
downloadvcxsrv-956c20498738c242726b5a42ed28db8572a90bed.tar.gz
vcxsrv-956c20498738c242726b5a42ed28db8572a90bed.tar.bz2
vcxsrv-956c20498738c242726b5a42ed28db8572a90bed.zip
mesa fontconfig git update 7 Feb 2013
fontconfig commit 96220a5ed9d1d761b14a7ac516ac6786c132f280 mesa commit 9ba1e23647c09290c98cc7133fb73dd1df1da8ab
Diffstat (limited to 'fontconfig/src/fcmatch.c')
-rw-r--r--fontconfig/src/fcmatch.c184
1 files changed, 86 insertions, 98 deletions
diff --git a/fontconfig/src/fcmatch.c b/fontconfig/src/fcmatch.c
index fc891cb50..fa8800a04 100644
--- a/fontconfig/src/fcmatch.c
+++ b/fontconfig/src/fcmatch.c
@@ -186,10 +186,61 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
return 4.0;
}
+#define PRI_NULL(n) \
+ PRI_ ## n ## _STRONG = -1, \
+ PRI_ ## n ## _WEAK = -1,
+#define PRI1(n)
+#define PRI_FcCompareFamily(n) PRI1(n)
+#define PRI_FcCompareString(n) PRI1(n)
+#define PRI_FcCompareNumber(n) PRI1(n)
+#define PRI_FcCompareSize(n) PRI1(n)
+#define PRI_FcCompareBool(n) PRI1(n)
+#define PRI_FcCompareFilename(n) PRI1(n)
+#define PRI_FcCompareCharSet(n) PRI1(n)
+#define PRI_FcCompareLang(n) PRI1(n)
+
+#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
+
+typedef enum _FcMatcherPriorityDummy {
+#include "fcobjs.h"
+} FcMatcherPriorityDummy;
+
+#undef FC_OBJECT
+
+#undef PRI1
+#define PRI1(n) \
+ PRI_ ## n ## _STRONG, \
+ PRI_ ## n ## _WEAK
+
+typedef enum _FcMatcherPriority {
+ PRI1(HASH),
+ PRI1(FILE),
+ PRI1(FOUNDRY),
+ PRI1(CHARSET),
+ PRI_FAMILY_STRONG,
+ PRI_LANG_STRONG,
+ PRI_LANG_WEAK,
+ PRI_FAMILY_WEAK,
+ PRI1(SPACING),
+ PRI1(PIXEL_SIZE),
+ PRI1(STYLE),
+ PRI1(SLANT),
+ PRI1(WEIGHT),
+ PRI1(WIDTH),
+ PRI1(DECORATIVE),
+ PRI1(ANTIALIAS),
+ PRI1(RASTERIZER),
+ PRI1(OUTLINE),
+ PRI1(FONTVERSION),
+ PRI_END
+} FcMatcherPriority;
+
+#undef PRI1
+
typedef struct _FcMatcher {
- FcObject object;
- double (*compare) (FcValue *value1, FcValue *value2);
- int strong, weak;
+ FcObject object;
+ double (*compare) (FcValue *value1, FcValue *value2);
+ int strong, weak;
} FcMatcher;
/*
@@ -197,100 +248,33 @@ typedef struct _FcMatcher {
* each value, earlier values are more significant than
* later values
*/
+#define FC_OBJECT(NAME, Type, Cmp) { FC_##NAME##_OBJECT, Cmp, PRI_##NAME##_STRONG, PRI_##NAME##_WEAK },
static const FcMatcher _FcMatchers [] = {
- { FC_FILE_OBJECT, FcCompareFilename, 0, 0 },
-#define MATCH_FILE 0
- { FC_FOUNDRY_OBJECT, FcCompareString, 1, 1 },
-#define MATCH_FOUNDRY 1
- { FC_CHARSET_OBJECT, FcCompareCharSet, 2, 2 },
-#define MATCH_CHARSET 2
- { FC_FAMILY_OBJECT, FcCompareFamily, 3, 5 },
-#define MATCH_FAMILY 3
- { FC_LANG_OBJECT, FcCompareLang, 4, 4 },
-#define MATCH_LANG 4
-#define MATCH_LANG_INDEX 4
- { FC_SPACING_OBJECT, FcCompareNumber, 6, 6 },
-#define MATCH_SPACING 5
- { FC_PIXEL_SIZE_OBJECT, FcCompareSize, 7, 7 },
-#define MATCH_PIXEL_SIZE 6
- { FC_STYLE_OBJECT, FcCompareString, 8, 8 },
-#define MATCH_STYLE 7
- { FC_SLANT_OBJECT, FcCompareNumber, 9, 9 },
-#define MATCH_SLANT 8
- { FC_WEIGHT_OBJECT, FcCompareNumber, 10, 10 },
-#define MATCH_WEIGHT 9
- { FC_WIDTH_OBJECT, FcCompareNumber, 11, 11 },
-#define MATCH_WIDTH 10
- { FC_DECORATIVE_OBJECT, FcCompareBool, 12, 12 },
-#define MATCH_DECORATIVE 11
- { FC_ANTIALIAS_OBJECT, FcCompareBool, 13, 13 },
-#define MATCH_ANTIALIAS 12
- { FC_RASTERIZER_OBJECT, FcCompareString, 14, 14 },
-#define MATCH_RASTERIZER 13
- { FC_OUTLINE_OBJECT, FcCompareBool, 15, 15 },
-#define MATCH_OUTLINE 14
- { FC_FONTVERSION_OBJECT, FcCompareNumber, 16, 16 },
-#define MATCH_FONTVERSION 15
+ { FC_INVALID_OBJECT, NULL, -1, -1 },
+#include "fcobjs.h"
};
-
-#define NUM_MATCH_VALUES 17
+#undef FC_OBJECT
static const FcMatcher*
FcObjectToMatcher (FcObject object,
FcBool include_lang)
{
- int i;
-
- i = -1;
- switch (object) {
- case FC_FILE_OBJECT:
- i = MATCH_FILE; break;
- case FC_FOUNDRY_OBJECT:
- i = MATCH_FOUNDRY; break;
- case FC_FONTVERSION_OBJECT:
- i = MATCH_FONTVERSION; break;
- case FC_FAMILY_OBJECT:
- i = MATCH_FAMILY; break;
- case FC_CHARSET_OBJECT:
- i = MATCH_CHARSET; break;
- case FC_ANTIALIAS_OBJECT:
- i = MATCH_ANTIALIAS; break;
- case FC_LANG_OBJECT:
- i = MATCH_LANG; break;
- case FC_SPACING_OBJECT:
- i = MATCH_SPACING; break;
- case FC_STYLE_OBJECT:
- i = MATCH_STYLE; break;
- case FC_SLANT_OBJECT:
- i = MATCH_SLANT; break;
- case FC_PIXEL_SIZE_OBJECT:
- i = MATCH_PIXEL_SIZE; break;
- case FC_WIDTH_OBJECT:
- i = MATCH_WIDTH; break;
- case FC_WEIGHT_OBJECT:
- i = MATCH_WEIGHT; break;
- case FC_RASTERIZER_OBJECT:
- i = MATCH_RASTERIZER; break;
- case FC_OUTLINE_OBJECT:
- i = MATCH_OUTLINE; break;
- case FC_DECORATIVE_OBJECT:
- i = MATCH_DECORATIVE; break;
- default:
- if (include_lang)
- {
- switch (object) {
- case FC_FAMILYLANG_OBJECT:
- case FC_STYLELANG_OBJECT:
- case FC_FULLNAMELANG_OBJECT:
- i = MATCH_LANG; break;
- }
+ if (include_lang)
+ {
+ switch (object) {
+ case FC_FAMILYLANG_OBJECT:
+ case FC_STYLELANG_OBJECT:
+ case FC_FULLNAMELANG_OBJECT:
+ object = FC_LANG_OBJECT;
+ break;
}
}
-
- if (i < 0)
+ if (!_FcMatchers[object].compare ||
+ _FcMatchers[object].strong == -1 ||
+ _FcMatchers[object].weak == -1)
return NULL;
- return _FcMatchers+i;
+ return _FcMatchers + object;
}
static FcBool
@@ -390,7 +374,7 @@ FcCompare (FcPattern *pat,
{
int i, i1, i2;
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
value[i] = 0.0;
i1 = 0;
@@ -565,14 +549,14 @@ FcFontSetMatchInternal (FcFontSet **sets,
FcPattern *p,
FcResult *result)
{
- double score[NUM_MATCH_VALUES], bestscore[NUM_MATCH_VALUES];
+ double score[PRI_END], bestscore[PRI_END];
int f;
FcFontSet *s;
FcPattern *best;
int i;
int set;
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
bestscore[i] = 0;
best = 0;
if (FcDebug () & FC_DBG_MATCH)
@@ -597,19 +581,19 @@ FcFontSetMatchInternal (FcFontSet **sets,
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Score");
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
{
printf (" %g", score[i]);
}
printf ("\n");
}
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
{
if (best && bestscore[i] < score[i])
break;
if (!best || score[i] < bestscore[i])
{
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
bestscore[i] = score[i];
best = s->fonts[f];
break;
@@ -620,7 +604,7 @@ FcFontSetMatchInternal (FcFontSet **sets,
if (FcDebug () & FC_DBG_MATCH)
{
printf ("Best score");
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
printf (" %g", bestscore[i]);
printf ("\n");
FcPatternPrint (best);
@@ -696,7 +680,7 @@ FcFontMatch (FcConfig *config,
typedef struct _FcSortNode {
FcPattern *pattern;
- double score[NUM_MATCH_VALUES];
+ double score[PRI_END];
} FcSortNode;
static int
@@ -709,7 +693,7 @@ FcSortCompare (const void *aa, const void *ab)
double ad = 0, bd = 0;
int i;
- i = NUM_MATCH_VALUES;
+ i = PRI_END;
while (i-- && (ad = *as++) == (bd = *bs++))
;
return ad < bd ? -1 : ad > bd ? 1 : 0;
@@ -874,7 +858,7 @@ FcFontSetSort (FcConfig *config FC_UNUSED,
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Score");
- for (i = 0; i < NUM_MATCH_VALUES; i++)
+ for (i = 0; i < PRI_END; i++)
{
printf (" %g", new->score[i]);
}
@@ -901,7 +885,8 @@ FcFontSetSort (FcConfig *config FC_UNUSED,
* If this node matches any language, go check
* which ones and satisfy those entries
*/
- if (nodeps[f]->score[MATCH_LANG_INDEX] < 2000)
+ if (nodeps[f]->score[PRI_LANG_STRONG] < 2000 ||
+ nodeps[f]->score[PRI_LANG_WEAK] < 2000)
{
for (i = 0; i < nPatternLang; i++)
{
@@ -931,7 +916,10 @@ FcFontSetSort (FcConfig *config FC_UNUSED,
}
}
if (!satisfies)
- nodeps[f]->score[MATCH_LANG_INDEX] = 10000.0;
+ {
+ nodeps[f]->score[PRI_LANG_STRONG] = 10000.0;
+ nodeps[f]->score[PRI_LANG_WEAK] = 10000.0;
+ }
}
/*