summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fcdefault.c3
-rw-r--r--src/fcfreetype.c54
-rw-r--r--src/fcmatch.c29
-rw-r--r--src/fcname.c18
4 files changed, 89 insertions, 15 deletions
diff --git a/src/fcdefault.c b/src/fcdefault.c
index bd17a43..b070ea8 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -55,6 +55,9 @@ FcDefaultSubstitute (FcPattern *pattern)
}
}
+ if (FcPatternGet (pattern, FC_WIDTH, 0, &v) == FcResultNoMatch)
+ FcPatternAddInteger (pattern, FC_WIDTH, FC_WIDTH_NORMAL);
+
for (i = 0; i < NUM_FC_BOOL_DEFAULTS; i++)
if (FcPatternGet (pattern, FcBoolDefaults[i].field, 0, &v) == FcResultNoMatch)
FcPatternAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value);
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 72b4181..c4d4cfc 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -121,6 +121,7 @@ FcFreeTypeQuery (const FcChar8 *file,
FcPattern *pat;
int slant;
int weight;
+ int width = -1;
int i;
FcCharSet *cs;
FcLangSet *ls;
@@ -162,16 +163,11 @@ FcFreeTypeQuery (const FcChar8 *file,
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
slant = FC_SLANT_ITALIC;
- if (!FcPatternAddInteger (pat, FC_SLANT, slant))
- goto bail1;
weight = FC_WEIGHT_MEDIUM;
if (face->style_flags & FT_STYLE_FLAG_BOLD)
weight = FC_WEIGHT_BOLD;
- if (!FcPatternAddInteger (pat, FC_WEIGHT, weight))
- goto bail1;
-
/*
* Grub through the name table looking for family
* and style names. FreeType makes quite a hash
@@ -530,6 +526,54 @@ FcFreeTypeQuery (const FcChar8 *file,
}
}
+ if (os2 && os2->version != 0xffff)
+ {
+ if (os2->usWeightClass == 0)
+ weight = -1;
+ else if (os2->usWeightClass < 150)
+ weight = FC_WEIGHT_THIN;
+ else if (os2->usWeightClass < 250)
+ weight = FC_WEIGHT_EXTRALIGHT;
+ else if (os2->usWeightClass < 350)
+ weight = FC_WEIGHT_LIGHT;
+ else if (os2->usWeightClass < 450)
+ weight = FC_WEIGHT_REGULAR;
+ else if (os2->usWeightClass < 550)
+ weight = FC_WEIGHT_MEDIUM;
+ else if (os2->usWeightClass < 650)
+ weight = FC_WEIGHT_SEMIBOLD;
+ else if (os2->usWeightClass < 750)
+ weight = FC_WEIGHT_BOLD;
+ else if (os2->usWeightClass < 850)
+ weight = FC_WEIGHT_EXTRABOLD;
+ else if (os2->usWeightClass < 950)
+ weight = FC_WEIGHT_BLACK;
+ else
+ weight = FC_WEIGHT_MEDIUM;
+
+ switch (os2->usWidthClass) {
+ case 1: width = FC_WIDTH_ULTRACONDENSED; break;
+ case 2: width = FC_WIDTH_EXTRACONDENSED; break;
+ case 3: width = FC_WIDTH_CONDENSED; break;
+ case 4: width = FC_WIDTH_SEMICONDENSED; break;
+ case 5: width = FC_WIDTH_NORMAL; break;
+ case 6: width = FC_WIDTH_SEMIEXPANDED; break;
+ case 7: width = FC_WIDTH_EXPANDED; break;
+ case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
+ case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
+ }
+ }
+
+ if (!FcPatternAddInteger (pat, FC_SLANT, slant))
+ goto bail1;
+
+ if (!FcPatternAddInteger (pat, FC_WEIGHT, weight))
+ goto bail1;
+
+ if (width != -1)
+ if (!FcPatternAddInteger (pat, FC_WIDTH, width))
+ goto bail1;
+
/*
* Compute the unicode coverage for the font
*/
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 6ec500a..4bb3d46 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -206,20 +206,23 @@ static FcMatcher _FcMatchers [] = {
{ FC_WEIGHT, FcCompareNumber, 9, 9 },
#define MATCH_WEIGHT 8
- { FC_ANTIALIAS, FcCompareBool, 10, 10 },
-#define MATCH_ANTIALIAS 9
+ { FC_WIDTH, FcCompareNumber, 10, 10 },
+#define MATCH_WIDTH 9
- { FC_RASTERIZER, FcCompareString, 11, 11 },
-#define MATCH_RASTERIZER 10
+ { FC_ANTIALIAS, FcCompareBool, 11, 11 },
+#define MATCH_ANTIALIAS 10
- { FC_OUTLINE, FcCompareBool, 12, 12 },
-#define MATCH_OUTLINE 11
+ { FC_RASTERIZER, FcCompareString, 12, 12 },
+#define MATCH_RASTERIZER 11
+
+ { FC_OUTLINE, FcCompareBool, 13, 13 },
+#define MATCH_OUTLINE 12
- { FC_FONTVERSION, FcCompareNumber, 13, 13 },
-#define MATCH_FONTVERSION 12
+ { FC_FONTVERSION, FcCompareNumber, 14, 14 },
+#define MATCH_FONTVERSION 13
};
-#define NUM_MATCH_VALUES 14
+#define NUM_MATCH_VALUES 15
static FcBool
FcCompareValueList (const char *object,
@@ -273,7 +276,13 @@ FcCompareValueList (const char *object,
case 'p':
i = MATCH_PIXEL_SIZE; break;
case 'w':
- i = MATCH_WEIGHT; break;
+ switch (FcToLower (object[1])) {
+ case 'i':
+ i = MATCH_WIDTH; break;
+ case 'e':
+ i = MATCH_WEIGHT; break;
+ }
+ break;
case 'r':
i = MATCH_RASTERIZER; break;
case 'o':
diff --git a/src/fcname.c b/src/fcname.c
index 1f3f2ed..e211ab3 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -33,6 +33,7 @@ static const FcObjectType _FcBaseObjectTypes[] = {
{ FC_STYLE, FcTypeString, },
{ FC_SLANT, FcTypeInteger, },
{ FC_WEIGHT, FcTypeInteger, },
+ { FC_WIDTH, FcTypeInteger, },
{ FC_SIZE, FcTypeDouble, },
{ FC_ASPECT, FcTypeDouble, },
{ FC_PIXEL_SIZE, FcTypeDouble, },
@@ -137,16 +138,33 @@ FcNameGetObjectType (const char *object)
}
static const FcConstant _FcBaseConstants[] = {
+ { (FcChar8 *) "thin", "weight", FC_WEIGHT_THIN, },
+ { (FcChar8 *) "extralight", "weight", FC_WEIGHT_EXTRALIGHT, },
+ { (FcChar8 *) "ultralight", "weight", FC_WEIGHT_EXTRALIGHT, },
{ (FcChar8 *) "light", "weight", FC_WEIGHT_LIGHT, },
+ { (FcChar8 *) "regular", "weight", FC_WEIGHT_REGULAR, },
{ (FcChar8 *) "medium", "weight", FC_WEIGHT_MEDIUM, },
{ (FcChar8 *) "demibold", "weight", FC_WEIGHT_DEMIBOLD, },
+ { (FcChar8 *) "semibold", "weight", FC_WEIGHT_DEMIBOLD, },
{ (FcChar8 *) "bold", "weight", FC_WEIGHT_BOLD, },
+ { (FcChar8 *) "extrabold", "weight", FC_WEIGHT_EXTRABOLD, },
+ { (FcChar8 *) "ultrabold", "weight", FC_WEIGHT_EXTRABOLD, },
{ (FcChar8 *) "black", "weight", FC_WEIGHT_BLACK, },
{ (FcChar8 *) "roman", "slant", FC_SLANT_ROMAN, },
{ (FcChar8 *) "italic", "slant", FC_SLANT_ITALIC, },
{ (FcChar8 *) "oblique", "slant", FC_SLANT_OBLIQUE, },
+ { (FcChar8 *) "ultracondensed", "width", FC_WIDTH_ULTRACONDENSED },
+ { (FcChar8 *) "extracondensed", "width", FC_WIDTH_EXTRACONDENSED },
+ { (FcChar8 *) "condensed", "width", FC_WIDTH_CONDENSED },
+ { (FcChar8 *) "semicondensed", "width", FC_WIDTH_SEMICONDENSED },
+ { (FcChar8 *) "normal", "width", FC_WIDTH_NORMAL },
+ { (FcChar8 *) "semiexpanded", "width", FC_WIDTH_SEMIEXPANDED },
+ { (FcChar8 *) "expanded", "width", FC_WIDTH_EXPANDED },
+ { (FcChar8 *) "extraexpanded", "width", FC_WIDTH_EXTRAEXPANDED },
+ { (FcChar8 *) "ultraexpanded", "width", FC_WIDTH_ULTRAEXPANDED },
+
{ (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },