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

Akira TAGOH tagoh at kemper.freedesktop.org
Wed May 27 22:54:04 PDT 2015


 fontconfig/fontconfig.h |    5 +-
 src/fccache.c           |    6 +-
 src/fcdbg.c             |   10 ----
 src/fcfreetype.c        |   23 +---------
 src/fcint.h             |   28 ------------
 src/fcmatch.c           |    2 
 src/fcname.c            |   20 ++------
 src/fcrange.c           |  109 +++++++-----------------------------------------
 src/fcxml.c             |   15 +++---
 9 files changed, 47 insertions(+), 171 deletions(-)

New commits:
commit 481a9f03a020ee53500585332786826e8c3ebd8e
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed May 27 14:40:15 2015 -0700

    Bump cache version number to 6, because of recent FcRange changes

diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index c86e7a7..128b939 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -66,7 +66,7 @@ typedef int		FcBool;
  * it means multiple copies of the font information.
  */
 
-#define FC_CACHE_VERSION_NUMBER	5
+#define FC_CACHE_VERSION_NUMBER	6
 #define _FC_STRINGIFY_(s)    	#s
 #define _FC_STRINGIFY(s)    	_FC_STRINGIFY_(s)
 #define FC_CACHE_VERSION    	_FC_STRINGIFY(FC_CACHE_VERSION_NUMBER)
commit ee2d1da2d21bc14127f4cf12312e1f007935e8b0
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed May 27 14:36:35 2015 -0700

    Reduce number of places that cache version is specified to 1

diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 65b85ae..c86e7a7 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -66,7 +66,10 @@ typedef int		FcBool;
  * it means multiple copies of the font information.
  */
 
-#define FC_CACHE_VERSION    "5"
+#define FC_CACHE_VERSION_NUMBER	5
+#define _FC_STRINGIFY_(s)    	#s
+#define _FC_STRINGIFY(s)    	_FC_STRINGIFY_(s)
+#define FC_CACHE_VERSION    	_FC_STRINGIFY(FC_CACHE_VERSION_NUMBER)
 
 #define FcTrue		1
 #define FcFalse		0
diff --git a/src/fccache.c b/src/fccache.c
index 25538bd..fc3ed41 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -655,7 +655,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
 	allocated = FcTrue;
     }
     if (cache->magic != FC_CACHE_MAGIC_MMAP ||
-	cache->version < FC_CACHE_CONTENT_VERSION ||
+	cache->version < FC_CACHE_VERSION_NUMBER ||
 	cache->size != (intptr_t) fd_stat->st_size ||
 	!FcCacheTimeValid (config, cache, dir_stat) ||
 	!FcCacheDirsValid (config, cache) ||
@@ -751,7 +751,7 @@ FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct
 	ret = FcFalse;
     else if (c.magic != FC_CACHE_MAGIC_MMAP)
 	ret = FcFalse;
-    else if (c.version < FC_CACHE_CONTENT_VERSION)
+    else if (c.version < FC_CACHE_VERSION_NUMBER)
 	ret = FcFalse;
     else if (fd_stat->st_size != c.size)
 	ret = FcFalse;
@@ -828,7 +828,7 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcSt
     serialize->linear = cache;
 
     cache->magic = FC_CACHE_MAGIC_ALLOC;
-    cache->version = FC_CACHE_CONTENT_VERSION;
+    cache->version = FC_CACHE_VERSION_NUMBER;
     cache->size = serialize->size;
     cache->checksum = (int) dir_stat->st_mtime;
 
diff --git a/src/fcint.h b/src/fcint.h
index bc4f924..fda18ce 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -361,7 +361,7 @@ typedef struct _FcStrBuf {
 
 struct _FcCache {
     unsigned int magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
-    int		version;	    /* FC_CACHE_CONTENT_VERSION */
+    int		version;	    /* FC_CACHE_VERSION_NUMBER */
     intptr_t	size;		    /* size of file */
     intptr_t	dir;		    /* offset to dir name */
     intptr_t	dirs;		    /* offset to subdirs */
@@ -453,7 +453,6 @@ typedef struct _FcCaseFold {
 
 #define FC_CACHE_MAGIC_MMAP	    0xFC02FC04
 #define FC_CACHE_MAGIC_ALLOC	    0xFC02FC05
-#define FC_CACHE_CONTENT_VERSION    5
 
 struct _FcAtomic {
     FcChar8	*file;		/* original file name */
commit 5bad26ccb6686f1b9c8df6c1e9b49a72d42ad661
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 20 16:07:26 2014 -0400

    Simplify FcRange

diff --git a/src/fcdbg.c b/src/fcdbg.c
index 7a1928a..985fee9 100644
--- a/src/fcdbg.c
+++ b/src/fcdbg.c
@@ -29,8 +29,6 @@
 static void
 _FcValuePrintFile (FILE *f, const FcValue v)
 {
-    FcRange r;
-
     switch (v.type) {
     case FcTypeUnknown:
 	fprintf (f, "<unknown>");
@@ -64,8 +62,7 @@ _FcValuePrintFile (FILE *f, const FcValue v)
 	fprintf (f, "face");
 	break;
     case FcTypeRange:
-	r = FcRangeCanonicalize (v.u.r);
-	fprintf (f, "[%g %g)", r.u.d.begin, r.u.d.end);
+	fprintf (f, "[%g %g)", v.u.r->begin, v.u.r->end);
 	break;
     }
 }
@@ -267,8 +264,6 @@ FcOpPrint (FcOp op_)
 void
 FcExprPrint (const FcExpr *expr)
 {
-    FcRange r;
-
     if (!expr) printf ("none");
     else switch (FC_OP_GET_OP (expr->op)) {
     case FcOpInteger: printf ("%d", expr->u.ival); break;
@@ -286,8 +281,7 @@ FcExprPrint (const FcExpr *expr)
 	printf ("]");
 	break;
     case FcOpRange:
-	r = FcRangeCanonicalize (expr->u.rval);
-	printf ("(%g, %g)", r.u.d.begin, r.u.d.end);
+	printf ("(%g, %g)", expr->u.rval->begin, expr->u.rval->end);
 	break;
     case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
     case FcOpCharSet: printf ("charset\n"); break;
diff --git a/src/fcint.h b/src/fcint.h
index 83815f7..bc4f924 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -96,11 +96,6 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
 #define FC_ABS(a)   ((a) < 0 ? -(a) : (a))
 
-#define FcDoubleIsZero(a)	(fabs ((a)) <= DBL_EPSILON)
-#define FcDoubleCmpEQ(a,b)	(fabs ((a) - (b)) <= DBL_EPSILON)
-#define FcDoubleCmpGE(a,b)	(FcDoubleCmpEQ (a, b) || (a) > (b))
-#define FcDoubleCmpLE(a,b)	(FcDoubleCmpEQ (a, b) || (a) < (b))
-
 /* slim_internal.h */
 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
 #define FcPrivate		__attribute__((__visibility__("hidden")))
@@ -252,21 +247,9 @@ typedef struct _FcExprName {
   FcMatchKind	kind;
 } FcExprName;
 
-typedef struct _FcRangeInt {
-    FcChar32 begin;
-    FcChar32 end;
-} FcRangeInt;
-typedef struct _FcRangeDouble {
+struct _FcRange {
     double begin;
     double end;
-} FcRangeDouble;
-struct _FcRange {
-    FcBool is_double;
-    FcBool is_inclusive;
-    union {
-	FcRangeInt i;
-	FcRangeDouble d;
-    } u;
 };
 
 
@@ -1083,16 +1066,10 @@ FcMatrixFree (FcMatrix *mat);
 
 /* fcrange.c */
 
-FcPrivate FcRange
-FcRangeCanonicalize (const FcRange *range);
-
 FcPrivate FcRange *
 FcRangePromote (double v, FcValuePromotionBuffer *vbuf);
 
 FcPrivate FcBool
-FcRangeIsZero (const FcRange *r);
-
-FcPrivate FcBool
 FcRangeIsInRange (const FcRange *a, const FcRange *b);
 
 FcPrivate FcBool
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 623d4aa..7fbaf0e 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -220,7 +220,7 @@ FcCompareSizeRange (FcValue *v1, FcValue *v2)
     if (FcRangeIsInRange (r1, r2))
 	ret = 0.0;
     else
-	ret = FC_MIN (fabs (r1->u.d.end - r2->u.d.begin), fabs (r1->u.d.begin - r2->u.d.end));
+	ret = FC_MIN (fabs (r1->end - r2->begin), fabs (r1->begin - r2->end));
 
 bail:
     if (r1)
diff --git a/src/fcname.c b/src/fcname.c
index aec6114..8be36c7 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -500,7 +500,6 @@ FcNameUnparseValue (FcStrBuf	*buf,
 {
     FcChar8	temp[1024];
     FcValue v = FcValueCanonicalize(v0);
-    FcRange r;
 
     switch (v.type) {
     case FcTypeUnknown:
@@ -527,17 +526,8 @@ FcNameUnparseValue (FcStrBuf	*buf,
     case FcTypeFTFace:
 	return FcTrue;
     case FcTypeRange:
-	r = FcRangeCanonicalize (v.u.r);
-	if (!FcDoubleIsZero (r.u.d.begin) || !FcDoubleIsZero (r.u.d.end))
-	{
-	    if (FcDoubleCmpEQ (r.u.d.begin, r.u.d.end))
-		sprintf ((char *) temp, "%g", r.u.d.begin);
-	    else
-		sprintf ((char *) temp, "[%g %g)", r.u.d.begin, r.u.d.end);
-	    return FcNameUnparseString (buf, temp, 0);
-	}
-	else
-	    return FcTrue;
+	sprintf ((char *) temp, "[%g %g)", v.u.r->begin, v.u.r->end);
+	return FcNameUnparseString (buf, temp, 0);
     }
     return FcFalse;
 }
diff --git a/src/fcrange.c b/src/fcrange.c
index 9b1b67b..f70226c 100644
--- a/src/fcrange.c
+++ b/src/fcrange.c
@@ -32,10 +32,8 @@ FcRangeCreateDouble (double begin, double end)
 
     if (ret)
     {
-	ret->is_double = FcTrue;
-	ret->is_inclusive = FcDoubleCmpEQ (begin, end);
-	ret->u.d.begin = begin;
-	ret->u.d.end = end;
+	ret->begin = begin;
+	ret->end = end;
     }
 
     return ret;
@@ -48,10 +46,8 @@ FcRangeCreateInteger (FcChar32 begin, FcChar32 end)
 
     if (ret)
     {
-	ret->is_double = FcFalse;
-	ret->is_inclusive = (begin == end);
-	ret->u.i.begin = begin;
-	ret->u.i.end = end;
+	ret->begin = begin;
+	ret->end = end;
     }
 
     return ret;
@@ -66,14 +62,7 @@ FcRangeDestroy (FcRange *range)
 FcRange *
 FcRangeCopy (const FcRange *range)
 {
-    FcRange *ret;
-
-    if (range->is_double)
-	ret = FcRangeCreateDouble (range->u.d.begin, range->u.d.end);
-    else
-	ret = FcRangeCreateInteger (range->u.i.begin, range->u.i.end);
-
-    return ret;
+    return FcRangeCreateDouble (range->begin, range->end);
 }
 
 FcBool
@@ -81,41 +70,14 @@ FcRangeGetDouble(const FcRange *range, double *begin, double *end)
 {
     if (!range)
 	return FcFalse;
-    if (range->is_double)
-    {
-	if (begin)
-	    *begin = range->u.d.begin;
-	if (end)
-	    *end = range->u.d.end;
-    }
-    else
-    {
-	if (begin)
-	    *begin = (double)range->u.i.begin;
-	if (end)
-	    *end = (double)range->u.i.end;
-    }
+    if (begin)
+	*begin = range->begin;
+    if (end)
+	*end = range->end;
 
     return FcTrue;
 }
 
-FcRange
-FcRangeCanonicalize (const FcRange *range)
-{
-    FcRange new;
-
-    if (range->is_double)
-	new = *range;
-    else
-    {
-	new.is_double = FcTrue;
-	new.is_inclusive = range->is_inclusive;
-	new.u.d.begin = (double)range->u.i.begin;
-	new.u.d.end = (double)range->u.i.end;
-    }
-    return new;
-}
-
 FcRange *
 FcRangePromote (double v, FcValuePromotionBuffer *vbuf)
 {
@@ -125,50 +87,24 @@ FcRangePromote (double v, FcValuePromotionBuffer *vbuf)
     FcRangePromotionBuffer *buf = (FcRangePromotionBuffer *) vbuf;
 
     FC_ASSERT_STATIC (sizeof (FcRangePromotionBuffer) <= sizeof (FcValuePromotionBuffer));
-    buf->r.is_double = FcTrue;
-    buf->r.is_inclusive = FcTrue;
-    buf->r.u.d.begin = v;
-    buf->r.u.d.end = v;
+    buf->r.begin = v;
+    buf->r.end = v;
 
     return &buf->r;
 }
 
 FcBool
-FcRangeIsZero (const FcRange *r)
-{
-    FcRange c;
-
-    if (!r)
-	return FcFalse;
-    c = FcRangeCanonicalize (r);
-
-    return FcDoubleIsZero (c.u.d.begin) && FcDoubleIsZero (c.u.d.end);
-}
-
-FcBool
 FcRangeIsInRange (const FcRange *a, const FcRange *b)
 {
-    FcRange ca, cb;
-    FcBool f;
-
     if (!a || !b)
 	return FcFalse;
 
-    ca = FcRangeCanonicalize (a);
-    cb = FcRangeCanonicalize (b);
-    if (ca.is_inclusive & cb.is_inclusive)
-	f = ca.u.d.end <= cb.u.d.end;
-    else
-	f = ca.u.d.end < cb.u.d.end;
-
-    return FcDoubleCmpGE (ca.u.d.begin, cb.u.d.begin) && f;
+    return a->begin >= b->begin && a->end <= b->end;
 }
 
 FcBool
 FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b)
 {
-    FcRange ca, cb;
-
     switch ((int) op) {
     case FcOpEqual:
     case FcOpContains:
@@ -178,21 +114,13 @@ FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b)
     case FcOpNotContains:
 	return !FcRangeIsInRange (a, b);
     case FcOpLess:
-	ca = FcRangeCanonicalize (a);
-	cb = FcRangeCanonicalize (b);
-	return ca.u.d.begin < cb.u.d.begin;
+	return a->begin < b->begin;
     case FcOpLessEqual:
-	ca = FcRangeCanonicalize (a);
-	cb = FcRangeCanonicalize (b);
-	return FcDoubleCmpLE (ca.u.d.begin, cb.u.d.begin);
+	return a->begin <= b->begin;
     case FcOpMore:
-	ca = FcRangeCanonicalize (a);
-	cb = FcRangeCanonicalize (b);
-	return ca.u.d.end > cb.u.d.end;
+	return a->end > b->end;
     case FcOpMoreEqual:
-	ca = FcRangeCanonicalize (a);
-	cb = FcRangeCanonicalize (b);
-	return FcDoubleCmpGE (ca.u.d.end, cb.u.d.end);
+	return a->end >= b->end;
     default:
 	break;
     }
@@ -202,9 +130,8 @@ FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b)
 FcChar32
 FcRangeHash (const FcRange *r)
 {
-    FcRange c = FcRangeCanonicalize (r);
-    int b = (int) (c.u.d.begin * 100);
-    int e = FcDoubleCmpEQ (c.u.d.end, DBL_MAX) ? INT_MAX : (int) (c.u.d.end * 100);
+    int b = (int) (r->begin * 100);
+    int e = (int) (r->end * 100);
 
     return b ^ (b << 1) ^ (e << 9);
 }
diff --git a/src/fcxml.c b/src/fcxml.c
index c39028e..bad6b81 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -1261,7 +1261,6 @@ FcParseBlank (FcConfigParse *parse)
 {
     int		n = FcVStackElements (parse);
     FcChar32	i, begin, end;
-    FcRange	r;
 
     while (n-- > 0)
     {
@@ -1278,9 +1277,8 @@ FcParseBlank (FcConfigParse *parse)
 		goto bail;
 	    break;
 	case FcVStackRange:
-	    r = FcRangeCanonicalize (v->u.range);
-	    begin = (FcChar32)r.u.d.begin;
-	    end = (FcChar32)r.u.d.end;
+	    begin = (FcChar32) v->u.range->begin;
+	    end = (FcChar32) v->u.range->end;
 	    if (begin <= end)
 	    {
 	      for (i = begin; i <= end; i++)
@@ -1593,7 +1591,6 @@ FcParseCharSet (FcConfigParse *parse)
     FcVStack	*vstack;
     FcCharSet	*charset = FcCharSetCreate ();
     FcChar32	i, begin, end;
-    FcRange	r;
     int n = 0;
 
     while ((vstack = FcVStackPeek (parse)))
@@ -1608,9 +1605,8 @@ FcParseCharSet (FcConfigParse *parse)
 		n++;
 	    break;
 	case FcVStackRange:
-	    r = FcRangeCanonicalize (vstack->u.range);
-	    begin = (FcChar32)r.u.d.begin;
-	    end = (FcChar32)r.u.d.end;
+	    begin = (FcChar32) vstack->u.range->begin;
+	    end = (FcChar32) vstack->u.range->end;
 
 	    if (begin <= end)
 	    {
commit 13a5ae9fb953c8a8eb3ec801781a499521c211f3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 20 16:03:02 2014 -0400

    Fix compiler warnings

diff --git a/src/fcxml.c b/src/fcxml.c
index d471569..c39028e 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -82,6 +82,7 @@ FcRuleDestroy (FcRule *rule)
     case FcRuleEdit:
 	FcEditDestroy (rule->u.edit);
 	break;
+    case FcRuleUnknown:
     default:
 	break;
     }
@@ -612,6 +613,7 @@ FcTypeName (FcType type)
 	return "langset";
     case FcTypeRange:
 	return "range";
+    case FcTypeUnknown:
     default:
 	return "unknown";
     }
@@ -809,6 +811,7 @@ FcRuleCreate (FcRuleType type,
     case FcRuleEdit:
 	r->u.edit = (FcEdit *) p;
 	break;
+    case FcRuleUnknown:
     default:
 	free (r);
 	r = NULL;
commit 346073d9dc17fc07758f7ef86c4ed05213ed0dab
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 6 20:36:18 2014 -0400

    Don't set FC_SIZE for bitmap fonts
    
    They get FC_PIXELSIZE set, which is later converted to FC_SIZE using
    FC_DPI.

diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index e9cf929..809ff29 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1613,36 +1613,24 @@ FcFreeTypeQueryFace (const FT_Face  face,
 	free (complex_);
     }
 
-    if (os2)
-    {
 #if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE)
-	if (os2 && os2->version >= 0x0005 && os2->version != 0xffff)
-	{
-	    double lower_size, upper_size;
+    if (os2 && os2->version >= 0x0005 && os2->version != 0xffff)
+    {
+	double lower_size, upper_size;
 
-	    /* usLowerPointSize and usUpperPointSize is actually twips */
-	    lower_size = os2->usLowerOpticalPointSize / 20.0L;
-	    upper_size = os2->usUpperOpticalPointSize / 20.0L;
+	/* usLowerPointSize and usUpperPointSize is actually twips */
+	lower_size = os2->usLowerOpticalPointSize / 20.0L;
+	upper_size = os2->usUpperOpticalPointSize / 20.0L;
 
-	    r = FcRangeCreateDouble (lower_size, upper_size);
-	    if (!FcPatternAddRange (pat, FC_SIZE, r))
-	    {
-		FcRangeDestroy (r);
-		goto bail1;
-	    }
-	    FcRangeDestroy (r);
-	}
-#endif
-    }
-    else
-    {
-	for (i = 0; i < face->num_fixed_sizes; i++)
+	r = FcRangeCreateDouble (lower_size, upper_size);
+	if (!FcPatternAddRange (pat, FC_SIZE, r))
 	{
-	    double d = FcGetPixelSize (face, i);
-	    if (!FcPatternAddDouble (pat, FC_SIZE, d))
-		goto bail1;
+	    FcRangeDestroy (r);
+	    goto bail1;
 	}
+	FcRangeDestroy (r);
     }
+#endif
 
     /*
      * Type 1: Check for FontInfo dictionary information
commit eba6f109de475215c2d4b42612f6baf57041536d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jul 4 17:15:11 2014 -0400

    Accept Integer for FC_SIZE
    
    There are more places to fix I'm sure...
    
    https://bugs.freedesktop.org/show_bug.cgi?id=80873

diff --git a/src/fcname.c b/src/fcname.c
index b0305aa..aec6114 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -88,7 +88,9 @@ FcObjectValidType (FcObject object, FcType type)
 		return FcTrue;
 	    break;
 	case FcTypeRange:
-	    if (type == FcTypeRange || type == FcTypeDouble)
+	    if (type == FcTypeRange ||
+		type == FcTypeDouble ||
+		type == FcTypeInteger)
 		return FcTrue;
 	    break;
 	default:
commit cb2f096e15cb868cbf29428b6dd339b8ba344e50
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jul 4 16:18:52 2014 -0400

    Add bitmap-only font size as Double, not Range
    
    The whole size setting part still smells to me.

diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 31bff8f..e9cf929 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1639,13 +1639,8 @@ FcFreeTypeQueryFace (const FT_Face  face,
 	for (i = 0; i < face->num_fixed_sizes; i++)
 	{
 	    double d = FcGetPixelSize (face, i);
-	    r = FcRangeCreateDouble (d, d);
-	    if (!FcPatternAddRange (pat, FC_SIZE, r))
-	    {
-		FcRangeDestroy (r);
+	    if (!FcPatternAddDouble (pat, FC_SIZE, d))
 		goto bail1;
-	    }
-	    FcRangeDestroy (r);
 	}
     }
 
commit 51756aab180c9f7a6632743885695add2f511100
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jul 4 16:13:45 2014 -0400

    Only set FC_SIZE for scalable fonts if OS/2 version 5 is present
    
    Part of https://bugs.freedesktop.org/show_bug.cgi?id=80873

diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 617b6b9..31bff8f 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -1199,7 +1199,6 @@ FcFreeTypeQueryFace (const FT_Face  face,
     const char	    *tmp;
 
     FcRange	    *r = NULL;
-    double	    lower_size = 0.0L, upper_size = DBL_MAX;
 
     FcBool	    symbol = FcFalse;
 
@@ -1614,23 +1613,26 @@ FcFreeTypeQueryFace (const FT_Face  face,
 	free (complex_);
     }
 
-#if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE)
-    if (os2 && os2->version >= 0x0005 && os2->version != 0xffff)
-    {
-	/* usLowerPointSize and usUpperPointSize is actually twips */
-	lower_size = os2->usLowerOpticalPointSize / 20.0L;
-	upper_size = os2->usUpperOpticalPointSize / 20.0L;
-    }
-#endif
     if (os2)
     {
-	r = FcRangeCreateDouble (lower_size, upper_size);
-	if (!FcPatternAddRange (pat, FC_SIZE, r))
+#if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE)
+	if (os2 && os2->version >= 0x0005 && os2->version != 0xffff)
 	{
+	    double lower_size, upper_size;
+
+	    /* usLowerPointSize and usUpperPointSize is actually twips */
+	    lower_size = os2->usLowerOpticalPointSize / 20.0L;
+	    upper_size = os2->usUpperOpticalPointSize / 20.0L;
+
+	    r = FcRangeCreateDouble (lower_size, upper_size);
+	    if (!FcPatternAddRange (pat, FC_SIZE, r))
+	    {
+		FcRangeDestroy (r);
+		goto bail1;
+	    }
 	    FcRangeDestroy (r);
-	    goto bail1;
 	}
-	FcRangeDestroy (r);
+#endif
     }
     else
     {
commit d09ba385892862e18c409f49405f51f066dea552
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jul 4 16:09:23 2014 -0400

    Write ranges using a [start finish) format
    
    To show closed and open ends.

diff --git a/src/fcdbg.c b/src/fcdbg.c
index ef038f0..7a1928a 100644
--- a/src/fcdbg.c
+++ b/src/fcdbg.c
@@ -65,7 +65,7 @@ _FcValuePrintFile (FILE *f, const FcValue v)
 	break;
     case FcTypeRange:
 	r = FcRangeCanonicalize (v.u.r);
-	fprintf (f, "(%g, %g)", r.u.d.begin, r.u.d.end);
+	fprintf (f, "[%g %g)", r.u.d.begin, r.u.d.end);
 	break;
     }
 }
diff --git a/src/fcname.c b/src/fcname.c
index 1d8fe75..b0305aa 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -316,7 +316,7 @@ FcNameConvert (FcType type, FcChar8 *string)
 	    v.type = FcTypeVoid;
 	break;
     case FcTypeRange:
-	if (sscanf ((char *) string, "(%lg %lg)", &b, &e) != 2)
+	if (sscanf ((char *) string, "[%lg %lg)", &b, &e) != 2)
 	{
 	    v.u.d = strtod ((char *) string, &p);
 	    if (p != NULL && p[0] != 0)
@@ -531,7 +531,7 @@ FcNameUnparseValue (FcStrBuf	*buf,
 	    if (FcDoubleCmpEQ (r.u.d.begin, r.u.d.end))
 		sprintf ((char *) temp, "%g", r.u.d.begin);
 	    else
-		sprintf ((char *) temp, "(%g %g)", r.u.d.begin, r.u.d.end);
+		sprintf ((char *) temp, "[%g %g)", r.u.d.begin, r.u.d.end);
 	    return FcNameUnparseString (buf, temp, 0);
 	}
 	else


More information about the Fontconfig mailing list