aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src
diff options
context:
space:
mode:
Diffstat (limited to 'fontconfig/src')
-rw-r--r--fontconfig/src/fcint.h4
-rw-r--r--fontconfig/src/fcmatch.c184
-rw-r--r--fontconfig/src/fcname.c2
-rw-r--r--fontconfig/src/fcobjs.h90
-rw-r--r--fontconfig/src/fcobjshash.gperf.h2
5 files changed, 135 insertions, 147 deletions
diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h
index b5ff382f5..4eac6105a 100644
--- a/fontconfig/src/fcint.h
+++ b/fontconfig/src/fcint.h
@@ -425,7 +425,7 @@ typedef struct _FcCaseFold {
#define FC_CACHE_MAGIC_MMAP 0xFC02FC04
#define FC_CACHE_MAGIC_ALLOC 0xFC02FC05
-#define FC_CACHE_CONTENT_VERSION 3
+#define FC_CACHE_CONTENT_VERSION 4
struct _FcAtomic {
FcChar8 *file; /* original file name */
@@ -858,7 +858,7 @@ FcListPatternMatchAny (const FcPattern *p,
enum {
FC_INVALID_OBJECT = 0,
-#define FC_OBJECT(NAME, Type) FC_##NAME##_OBJECT,
+#define FC_OBJECT(NAME, Type, Cmp) FC_##NAME##_OBJECT,
#include "fcobjs.h"
#undef FC_OBJECT
FC_ONE_AFTER_MAX_BASE_OBJECT
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;
+ }
}
/*
diff --git a/fontconfig/src/fcname.c b/fontconfig/src/fcname.c
index 2418189f9..6dd4d4948 100644
--- a/fontconfig/src/fcname.c
+++ b/fontconfig/src/fcname.c
@@ -29,7 +29,7 @@
#include <stdio.h>
static const FcObjectType FcObjects[] = {
-#define FC_OBJECT(NAME, Type) { FC_##NAME, Type },
+#define FC_OBJECT(NAME, Type, Cmp) { FC_##NAME, Type },
#include "fcobjs.h"
#undef FC_OBJECT
};
diff --git a/fontconfig/src/fcobjs.h b/fontconfig/src/fcobjs.h
index 3cb2349d0..4c1138ae4 100644
--- a/fontconfig/src/fcobjs.h
+++ b/fontconfig/src/fcobjs.h
@@ -1,47 +1,47 @@
/* DON'T REORDER! The order is part of the cache signature. */
-FC_OBJECT (FAMILY, FcTypeString)
-FC_OBJECT (FAMILYLANG, FcTypeString)
-FC_OBJECT (STYLE, FcTypeString)
-FC_OBJECT (STYLELANG, FcTypeString)
-FC_OBJECT (FULLNAME, FcTypeString)
-FC_OBJECT (FULLNAMELANG, FcTypeString)
-FC_OBJECT (SLANT, FcTypeInteger)
-FC_OBJECT (WEIGHT, FcTypeInteger)
-FC_OBJECT (WIDTH, FcTypeInteger)
-FC_OBJECT (SIZE, FcTypeDouble)
-FC_OBJECT (ASPECT, FcTypeDouble)
-FC_OBJECT (PIXEL_SIZE, FcTypeDouble)
-FC_OBJECT (SPACING, FcTypeInteger)
-FC_OBJECT (FOUNDRY, FcTypeString)
-FC_OBJECT (ANTIALIAS, FcTypeBool)
-FC_OBJECT (HINT_STYLE, FcTypeInteger)
-FC_OBJECT (HINTING, FcTypeBool)
-FC_OBJECT (VERTICAL_LAYOUT, FcTypeBool)
-FC_OBJECT (AUTOHINT, FcTypeBool)
-FC_OBJECT (GLOBAL_ADVANCE, FcTypeBool) /* deprecated */
-FC_OBJECT (FILE, FcTypeString)
-FC_OBJECT (INDEX, FcTypeInteger)
-FC_OBJECT (RASTERIZER, FcTypeString)
-FC_OBJECT (OUTLINE, FcTypeBool)
-FC_OBJECT (SCALABLE, FcTypeBool)
-FC_OBJECT (DPI, FcTypeDouble)
-FC_OBJECT (RGBA, FcTypeInteger)
-FC_OBJECT (SCALE, FcTypeDouble)
-FC_OBJECT (MINSPACE, FcTypeBool)
-FC_OBJECT (CHAR_WIDTH, FcTypeInteger)
-FC_OBJECT (CHAR_HEIGHT, FcTypeInteger)
-FC_OBJECT (MATRIX, FcTypeMatrix)
-FC_OBJECT (CHARSET, FcTypeCharSet)
-FC_OBJECT (LANG, FcTypeLangSet)
-FC_OBJECT (FONTVERSION, FcTypeInteger)
-FC_OBJECT (CAPABILITY, FcTypeString)
-FC_OBJECT (FONTFORMAT, FcTypeString)
-FC_OBJECT (EMBOLDEN, FcTypeBool)
-FC_OBJECT (EMBEDDED_BITMAP, FcTypeBool)
-FC_OBJECT (DECORATIVE, FcTypeBool)
-FC_OBJECT (LCD_FILTER, FcTypeInteger)
-FC_OBJECT (NAMELANG, FcTypeString)
-FC_OBJECT (FONT_FEATURES, FcTypeString)
-FC_OBJECT (PRGNAME, FcTypeString)
-FC_OBJECT (HASH, FcTypeString)
+FC_OBJECT (FAMILY, FcTypeString, FcCompareFamily)
+FC_OBJECT (FAMILYLANG, FcTypeString, NULL)
+FC_OBJECT (STYLE, FcTypeString, FcCompareString)
+FC_OBJECT (STYLELANG, FcTypeString, NULL)
+FC_OBJECT (FULLNAME, FcTypeString, NULL)
+FC_OBJECT (FULLNAMELANG, FcTypeString, NULL)
+FC_OBJECT (SLANT, FcTypeInteger, FcCompareNumber)
+FC_OBJECT (WEIGHT, FcTypeInteger, FcCompareNumber)
+FC_OBJECT (WIDTH, FcTypeInteger, FcCompareNumber)
+FC_OBJECT (SIZE, FcTypeDouble, NULL)
+FC_OBJECT (ASPECT, FcTypeDouble, NULL)
+FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareSize)
+FC_OBJECT (SPACING, FcTypeInteger, FcCompareNumber)
+FC_OBJECT (FOUNDRY, FcTypeString, FcCompareString)
+FC_OBJECT (ANTIALIAS, FcTypeBool, FcCompareBool)
+FC_OBJECT (HINT_STYLE, FcTypeInteger, NULL)
+FC_OBJECT (HINTING, FcTypeBool, NULL)
+FC_OBJECT (VERTICAL_LAYOUT, FcTypeBool, NULL)
+FC_OBJECT (AUTOHINT, FcTypeBool, NULL)
+FC_OBJECT (GLOBAL_ADVANCE, FcTypeBool, NULL) /* deprecated */
+FC_OBJECT (FILE, FcTypeString, FcCompareFilename)
+FC_OBJECT (INDEX, FcTypeInteger, NULL)
+FC_OBJECT (RASTERIZER, FcTypeString, FcCompareString)
+FC_OBJECT (OUTLINE, FcTypeBool, FcCompareBool)
+FC_OBJECT (SCALABLE, FcTypeBool, NULL)
+FC_OBJECT (DPI, FcTypeDouble, NULL)
+FC_OBJECT (RGBA, FcTypeInteger, NULL)
+FC_OBJECT (SCALE, FcTypeDouble, NULL)
+FC_OBJECT (MINSPACE, FcTypeBool, NULL)
+FC_OBJECT (CHAR_WIDTH, FcTypeInteger, NULL)
+FC_OBJECT (CHAR_HEIGHT, FcTypeInteger, NULL)
+FC_OBJECT (MATRIX, FcTypeMatrix, NULL)
+FC_OBJECT (CHARSET, FcTypeCharSet, FcCompareCharSet)
+FC_OBJECT (LANG, FcTypeLangSet, FcCompareLang)
+FC_OBJECT (FONTVERSION, FcTypeInteger, FcCompareNumber)
+FC_OBJECT (CAPABILITY, FcTypeString, NULL)
+FC_OBJECT (FONTFORMAT, FcTypeString, NULL)
+FC_OBJECT (EMBOLDEN, FcTypeBool, NULL)
+FC_OBJECT (EMBEDDED_BITMAP, FcTypeBool, NULL)
+FC_OBJECT (DECORATIVE, FcTypeBool, FcCompareBool)
+FC_OBJECT (LCD_FILTER, FcTypeInteger, NULL)
+FC_OBJECT (NAMELANG, FcTypeString, NULL)
+FC_OBJECT (FONT_FEATURES, FcTypeString, NULL)
+FC_OBJECT (PRGNAME, FcTypeString, NULL)
+FC_OBJECT (HASH, FcTypeString, FcCompareString)
/* ^-------------- Add new objects here. */
diff --git a/fontconfig/src/fcobjshash.gperf.h b/fontconfig/src/fcobjshash.gperf.h
index dafac1bc2..ca23c0261 100644
--- a/fontconfig/src/fcobjshash.gperf.h
+++ b/fontconfig/src/fcobjshash.gperf.h
@@ -21,6 +21,6 @@ struct FcObjectTypeInfo {
};
%%
-#define FC_OBJECT(NAME, Type) FC_##NAME, FC_##NAME##_OBJECT
+#define FC_OBJECT(NAME, Type, Cmp) FC_##NAME, FC_##NAME##_OBJECT
#include "fcobjs.h"
#undef FC_OBJECT