[Commit] fontconfig/src fccfg.c, 1.39, 1.40 fcdbg.c, 1.16, 1.17 fcint.h, 1.39, 1.40 fclang.c, 1.12, 1.13 fclist.c, 1.13, 1.14 fcxml.c, 1.29, 1.30

Keith Packard commit at keithp.com
Sun Jul 20 10:06:21 PDT 2003


Committed by: keithp

Update of /local/src/CVS/fontconfig/src
In directory home.keithp.com:/tmp/cvs-serv27000/src

Modified Files:
	fccfg.c fcdbg.c fcint.h fclang.c fclist.c fcxml.c 
Log Message:
Implement new semantics for Contains and LISTING:

LISTING requires that the font Contain all of the pattern values,
where Contain is redefined for strings to mean precise matching
(so that Courier 10 Pitch doesn't list Courier fonts)

"Contains" for lang means both langs have the same language
and either the same country or one is missing the country


Index: fccfg.c
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fccfg.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- fccfg.c	26 Jun 2003 00:39:04 -0000	1.39
+++ fccfg.c	20 Jul 2003 16:06:18 -0000	1.40
@@ -514,42 +514,43 @@
 }
 
 FcBool
-FcConfigCompareValue (const FcValue	m_o,
+FcConfigCompareValue (const FcValue	left_o,
 		      FcOp		op,
-		      const FcValue	v_o)
+		      const FcValue	right_o)
 {
-    FcValue	m = m_o;
-    FcValue	v = v_o;
+    FcValue	left = left_o;
+    FcValue	right = right_o;
     FcBool	ret = FcFalse;
     
-    m = FcConfigPromote (m, v);
-    v = FcConfigPromote (v, m);
-    if (m.type == v.type) 
+    left = FcConfigPromote (left, right);
+    right = FcConfigPromote (right, left);
+    if (left.type == right.type) 
     {
-	switch (m.type) {
+	switch (left.type) {
 	case FcTypeInteger:
 	    break;	/* FcConfigPromote prevents this from happening */
 	case FcTypeDouble:
 	    switch (op) {
 	    case FcOpEqual:
 	    case FcOpContains:
-		ret = m.u.d == v.u.d;
+	    case FcOpListing:
+		ret = left.u.d == right.u.d;
 		break;
 	    case FcOpNotEqual:
 	    case FcOpNotContains:
-		ret = m.u.d != v.u.d;
+		ret = left.u.d != right.u.d;
 		break;
 	    case FcOpLess:    
-		ret = m.u.d < v.u.d;
+		ret = left.u.d < right.u.d;
 		break;
 	    case FcOpLessEqual:    
-		ret = m.u.d <= v.u.d;
+		ret = left.u.d <= right.u.d;
 		break;
 	    case FcOpMore:    
-		ret = m.u.d > v.u.d;
+		ret = left.u.d > right.u.d;
 		break;
 	    case FcOpMoreEqual:    
-		ret = m.u.d >= v.u.d;
+		ret = left.u.d >= right.u.d;
 		break;
 	    default:
 		break;
@@ -559,11 +560,12 @@
 	    switch (op) {
 	    case FcOpEqual:    
 	    case FcOpContains:
-		ret = m.u.b == v.u.b;
+	    case FcOpListing:
+		ret = left.u.b == right.u.b;
 		break;
 	    case FcOpNotEqual:
 	    case FcOpNotContains:
-		ret = m.u.b != v.u.b;
+		ret = left.u.b != right.u.b;
 		break;
 	    default:
 		break;
@@ -572,16 +574,15 @@
 	case FcTypeString:
 	    switch (op) {
 	    case FcOpEqual:    
-		ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) == 0;
+	    case FcOpListing:
+		ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) == 0;
 		break;
 	    case FcOpContains:
-		ret = FcStrStrIgnoreCase (m.u.s, v.u.s) != 0;
+		ret = FcStrStrIgnoreCase (left.u.s, right.u.s) != 0;
 		break;
 	    case FcOpNotEqual:
-		ret = FcStrCmpIgnoreCase (m.u.s, v.u.s) != 0;
-		break;
 	    case FcOpNotContains:
-		ret = FcStrStrIgnoreCase (m.u.s, v.u.s) == 0;
+		ret = FcStrCmpIgnoreCase (left.u.s, right.u.s) != 0;
 		break;
 	    default:
 		break;
@@ -591,11 +592,12 @@
 	    switch (op) {
 	    case FcOpEqual:
 	    case FcOpContains:
-		ret = FcMatrixEqual (m.u.m, v.u.m);
+	    case FcOpListing:
+		ret = FcMatrixEqual (left.u.m, right.u.m);
 		break;
 	    case FcOpNotEqual:
 	    case FcOpNotContains:
-		ret = !FcMatrixEqual (m.u.m, v.u.m);
+		ret = !FcMatrixEqual (left.u.m, right.u.m);
 		break;
 	    default:
 		break;
@@ -604,18 +606,19 @@
 	case FcTypeCharSet:
 	    switch (op) {
 	    case FcOpContains:
-		/* v contains m if m is a subset of v */
-		ret = FcCharSetIsSubset (m.u.c, v.u.c);
+	    case FcOpListing:
+		/* left contains right if right is a subset of left */
+		ret = FcCharSetIsSubset (right.u.c, left.u.c);
 		break;
 	    case FcOpNotContains:
-		/* v contains m if m is a subset of v */
-		ret = !FcCharSetIsSubset (m.u.c, v.u.c);
+		/* left contains right if right is a subset of left */
+		ret = !FcCharSetIsSubset (right.u.c, left.u.c);
 		break;
 	    case FcOpEqual:
-		ret = FcCharSetEqual (m.u.c, v.u.c);
+		ret = FcCharSetEqual (left.u.c, right.u.c);
 		break;
 	    case FcOpNotEqual:
-		ret = !FcCharSetEqual (m.u.c, v.u.c);
+		ret = !FcCharSetEqual (left.u.c, right.u.c);
 		break;
 	    default:
 		break;
@@ -624,16 +627,17 @@
 	case FcTypeLangSet:
 	    switch (op) {
 	    case FcOpContains:
-		ret = FcLangSetContains (m.u.l, v.u.l);
+	    case FcOpListing:
+		ret = FcLangSetContains (left.u.l, right.u.l);
 		break;
 	    case FcOpNotContains:
-		ret = FcLangSetContains (m.u.l, v.u.l);
+		ret = FcLangSetContains (left.u.l, right.u.l);
 		break;
 	    case FcOpEqual:
-		ret = FcLangSetEqual (m.u.l, v.u.l);
+		ret = FcLangSetEqual (left.u.l, right.u.l);
 		break;
 	    case FcOpNotEqual:
-		ret = !FcLangSetEqual (m.u.l, v.u.l);
+		ret = !FcLangSetEqual (left.u.l, right.u.l);
 		break;
 	    default:
 		break;
@@ -643,6 +647,7 @@
 	    switch (op) {
 	    case FcOpEqual:
 	    case FcOpContains:
+	    case FcOpListing:
 		ret = FcTrue;
 		break;
 	    default:
@@ -653,11 +658,12 @@
 	    switch (op) {
 	    case FcOpEqual:
 	    case FcOpContains:
-		ret = m.u.f == v.u.f;
+	    case FcOpListing:
+		ret = left.u.f == right.u.f;
 		break;
 	    case FcOpNotEqual:
 	    case FcOpNotContains:
-		ret = m.u.f != v.u.f;
+		ret = left.u.f != right.u.f;
 		break;
 	    default:
 		break;
@@ -748,6 +754,7 @@
     case FcOpMoreEqual:
     case FcOpContains:
     case FcOpNotContains:
+    case FcOpListing:
 	vl = FcConfigEvaluate (p, e->u.tree.left);
 	vr = FcConfigEvaluate (p, e->u.tree.right);
 	v.type = FcTypeBool;
@@ -952,6 +959,7 @@
     
     while (e)
     {
+	/* Compute the value of the match expression */
 	if (e->op == FcOpComma)
 	{
 	    value = FcConfigEvaluate (p, e->u.tree.left);
@@ -965,6 +973,7 @@
 
 	for (v = values; v; v = v->next)
 	{
+	    /* Compare the pattern value to the match expression value */
 	    if (FcConfigCompareValue (v->value, t->op, value))
 	    {
 		if (!ret)

Index: fcdbg.c
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fcdbg.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- fcdbg.c	15 Apr 2003 23:38:06 -0000	1.16
+++ fcdbg.c	20 Jul 2003 16:06:18 -0000	1.17
@@ -157,6 +157,7 @@
     case FcOpCeil: printf ("Ceil"); break;
     case FcOpRound: printf ("Round"); break;
     case FcOpTrunc: printf ("Trunc"); break;
+    case FcOpListing: printf ("Listing"); break;
     case FcOpInvalid: printf ("Invalid"); break;
     }
 }
@@ -201,6 +202,7 @@
     case FcOpMore:
     case FcOpMoreEqual:
     case FcOpContains:
+    case FcOpListing:
     case FcOpNotContains:
     case FcOpPlus:
     case FcOpMinus:
@@ -225,6 +227,7 @@
 	case FcOpMore: printf ("More"); break;
 	case FcOpMoreEqual: printf ("MoreEqual"); break;
 	case FcOpContains: printf ("Contains"); break;
+	case FcOpListing: printf ("Listing"); break;
 	case FcOpNotContains: printf ("NotContains"); break;
 	case FcOpPlus: printf ("Plus"); break;
 	case FcOpMinus: printf ("Minus"); break;

Index: fcint.h
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fcint.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- fcint.h	7 May 2003 16:13:24 -0000	1.39
+++ fcint.h	20 Jul 2003 16:06:18 -0000	1.40
@@ -132,7 +132,8 @@
     FcOpAssign, FcOpAssignReplace, 
     FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
     FcOpQuest,
-    FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpNotContains,
+    FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, 
+    FcOpContains, FcOpListing, FcOpNotContains,
     FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
     FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
     FcOpNot, FcOpComma, FcOpFloor, FcOpCeil, FcOpRound, FcOpTrunc,

Index: fclang.c
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fclang.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- fclang.c	9 Jun 2003 17:31:03 -0000	1.12
+++ fclang.c	20 Jul 2003 16:06:18 -0000	1.13
@@ -144,28 +144,32 @@
 }
 
 /*
- * Return FcTrue when s1 contains s2. 
+ * Return FcTrue when super contains sub. 
  *
- * s1 contains s2 if s1 equals s2 or if s1 is a
- * language with a country and s2 is just a language
+ * super contains sub if super and sub have the same
+ * language and either the same country or one
+ * is missing the country
  */
 
 static FcBool
-FcLangContains (const FcChar8 *s1, const FcChar8 *s2)
+FcLangContains (const FcChar8 *super, const FcChar8 *sub)
 {
     FcChar8	    c1, c2;
 
     for (;;)
     {
-	c1 = *s1++;
-	c2 = *s2++;
+	c1 = *super++;
+	c2 = *sub++;
 	
 	c1 = FcToLower (c1);
 	c2 = FcToLower (c2);
 	if (c1 != c2)
 	{
-	    /* see if s1 has a country while s2 is mising one */
+	    /* see if super has a country while sub is mising one */
 	    if (c1 == '-' && c2 == '\0')
+		return FcTrue;
+	    /* see if sub has a country while super is mising one */
+	    if (c1 == '\0' && c2 == '-')
 		return FcTrue;
 	    return FcFalse;
 	}

Index: fclist.c
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fclist.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- fclist.c	5 Mar 2003 05:52:31 -0000	1.13
+++ fclist.c	20 Jul 2003 16:06:18 -0000	1.14
@@ -120,17 +120,33 @@
     return os;
 }
 
+/*
+ * Font must have a containing value for every value in the pattern
+ */
 static FcBool
-FcListValueListMatchAny (FcValueList *v1orig,
-			 FcValueList *v2orig)
+FcListValueListMatchAny (FcValueList *patOrig,	    /* pattern */
+			 FcValueList *fntOrig)	    /* font */
 {
-    FcValueList	    *v1, *v2;
+    FcValueList	    *pat, *fnt;
 
-    for (v1 = v1orig; v1; v1 = v1->next)
-	for (v2 = v2orig; v2; v2 = v2->next)
-	    if (FcConfigCompareValue (v1->value, FcOpContains, v2->value))
-		return FcTrue;
-    return FcFalse;
+    for (pat = patOrig; pat; pat = pat->next)
+    {
+	for (fnt = fntOrig; fnt; fnt = fnt->next)
+	{
+	    /*
+	     * make sure the font 'contains' the pattern.
+	     * (OpListing is OpContains except for strings
+	     *  where it requires an exact match)
+	     */
+	    if (FcConfigCompareValue (fnt->value,
+				      FcOpListing, 
+				      pat->value)) 
+		break;
+	}
+	if (!fnt)
+	    return FcFalse;
+    }
+    return FcTrue;
 }
 
 static FcBool
@@ -196,7 +212,8 @@
 	e = FcPatternFindElt (font, p->elts[i].object);
 	if (!e)
 	    return FcFalse;
-	if (!FcListValueListMatchAny (p->elts[i].values, e->values))
+	if (!FcListValueListMatchAny (p->elts[i].values,    /* pat elts */
+				      e->values))	    /* font elts */
 	    return FcFalse;
     }
     return FcTrue;
@@ -415,7 +432,8 @@
 	if (!s)
 	    continue;
 	for (f = 0; f < s->nfont; f++)
-	    if (FcListPatternMatchAny (p, s->fonts[f]))
+	    if (FcListPatternMatchAny (p,		/* pattern */
+				       s->fonts[f]))	/* font */
 		if (!FcListAppend (&table, s->fonts[f], os))
 		    goto bail1;
     }

Index: fcxml.c
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fcxml.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- fcxml.c	9 Jul 2003 17:04:17 -0000	1.29
+++ fcxml.c	20 Jul 2003 16:06:18 -0000	1.30
@@ -243,6 +243,7 @@
     case FcOpMore:
     case FcOpMoreEqual:
     case FcOpContains:
+    case FcOpListing:
     case FcOpNotContains:
     case FcOpPlus:
     case FcOpMinus:




More information about the Commit mailing list