[Fontconfig] fontconfig: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Jan 4 15:23:46 UTC 2018


 src/fcfreetype.c |   24 ++++++++----------------
 src/fcweight.c   |   20 +-------------------
 2 files changed, 9 insertions(+), 35 deletions(-)

New commits:
commit 37fb4a989e6243bceebadb8120f458d8d5b82c45
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 3 16:51:18 2018 +0000

    Support FC_WIDTH as double as well

diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 158f272..461fbf9 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1172,7 +1172,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
     FcPattern	    *pat;
     int		    slant = -1;
     double	    weight = -1;
-    int		    width = -1;
+    double	    width = -1;
     FcBool	    decorative = FcFalse;
     FcBool	    variable = FcFalse;
     FcBool	    variable_weight = FcFalse;
@@ -1695,10 +1695,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
 	    printf ("\tos2 weight class %d multiplier %g maps to weight %g\n",
 		    os2->usWeightClass, weight_mult, weight);
 
-	/* TODO:
-	 * Add FcWidthFromOpenTypeDouble and FcWidthToOpenTypeDouble,
-	 * and apply width_mult post-conversion? */
-	switch ((int) (os2->usWidthClass * width_mult + .5)) {
+	switch (os2->usWidthClass) {
 	case 1:	width = FC_WIDTH_ULTRACONDENSED; break;
 	case 2:	width = FC_WIDTH_EXTRACONDENSED; break;
 	case 3:	width = FC_WIDTH_CONDENSED; break;
@@ -1709,8 +1706,9 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
 	case 8:	width = FC_WIDTH_EXTRAEXPANDED; break;
 	case 9:	width = FC_WIDTH_ULTRAEXPANDED; break;
 	}
+	width *= width_mult;
 	if ((FcDebug() & FC_DBG_SCANV) && width != -1)
-	    printf ("\tos2 width class %d multiplier %g maps to width %d\n",
+	    printf ("\tos2 width class %d multiplier %g maps to width %g\n",
 		    os2->usWidthClass, width_mult, width);
     }
     if (os2 && (complex_ = FcFontCapabilities(face)))
@@ -1825,7 +1823,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
 	{
 	    width = FcIsWidth ((FcChar8 *) prop.u.atom);
 	    if (FcDebug () & FC_DBG_SCANV)
-		printf ("\tsetwidth %s maps to %d\n", prop.u.atom, width);
+		printf ("\tsetwidth %s maps to %g\n", prop.u.atom, width);
 	}
     }
 #endif
@@ -1845,7 +1843,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
 	{
 	    width = FcContainsWidth (style);
 	    if (FcDebug() & FC_DBG_SCANV)
-		printf ("\tStyle %s maps to width %d\n", style, width);
+		printf ("\tStyle %s maps to width %g\n", style, width);
 	}
 	if (slant == -1)
 	{
@@ -1890,7 +1888,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
     if (!variable_weight && !FcPatternAddDouble (pat, FC_WEIGHT, weight))
 	goto bail1;
 
-    if (!variable_width && !FcPatternAddInteger (pat, FC_WIDTH, width))
+    if (!variable_width && !FcPatternAddDouble (pat, FC_WIDTH, width))
 	goto bail1;
 
     if (!FcPatternAddString (pat, FC_FOUNDRY, foundry))
commit 1fa9cb78c1120e11e27e2a84f59b3fb239b165df
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 3 16:48:54 2018 +0000

    Remove hack for OS/2 weights 1..9

diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 4af96b8..158f272 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1690,13 +1690,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face  face,
     if (os2 && os2->version != 0xffff)
     {
 	weight = os2->usWeightClass;
-	if (weight < 10 && weight_mult != 1.0)
-	{
-		/* Work around bad values by cleaning them up before
-		 * multiplying by weight_mult. */
-		weight = FcWeightToOpenTypeDouble (FcWeightFromOpenTypeDouble (weight));
-	}
-	weight = FcWeightFromOpenTypeDouble ((int) (weight * weight_mult + .5));
+	weight = FcWeightFromOpenTypeDouble (weight * weight_mult);
 	if ((FcDebug() & FC_DBG_SCANV) && weight != -1)
 	    printf ("\tos2 weight class %d multiplier %g maps to weight %g\n",
 		    os2->usWeightClass, weight_mult, weight);
diff --git a/src/fcweight.c b/src/fcweight.c
index 278231d..276b467 100644
--- a/src/fcweight.c
+++ b/src/fcweight.c
@@ -54,27 +54,9 @@ FcWeightFromOpenTypeDouble (double ot_weight)
 {
 	int i;
 
-	/* Loosely based on WPF Font Selection Model's advice. */
-
 	if (ot_weight < 0)
 	    return -1;
-	else if (1 <= ot_weight && ot_weight <= 9)
-	{
-	    /* WPF Font Selection Model says do "ot_weight *= 100",
-	     * but Greg Hitchcock revealed that GDI had a mapping
-	     * reflected below: */
-	    switch ((int) ot_weight) {
-		case 1: ot_weight =  80; break;
-		case 2: ot_weight = 160; break;
-		case 3: ot_weight = 240; break;
-		case 4: ot_weight = 320; break;
-		case 5: ot_weight = 400; break;
-		case 6: ot_weight = 550; break;
-		case 7: ot_weight = 700; break;
-		case 8: ot_weight = 800; break;
-		case 9: ot_weight = 900; break;
-	    }
-	}
+
 	ot_weight = FC_MIN (ot_weight, map[(sizeof (map) / sizeof (map[0])) - 1].ot);
 
 	for (i = 1; ot_weight > map[i].ot; i++)


More information about the Fontconfig mailing list