[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Mon Jun 8 01:44:07 PDT 2015


 doc/fontconfig-user.sgml |    6 +++
 fontconfig/fontconfig.h  |    6 +++
 src/fcdbg.c              |   78 +++++++++++++++++++++++++++++++++++++++++++++++
 src/fcint.h              |    1 
 src/fcmatch.c            |   41 ++++++++++++++++++++++++
 src/fcpat.c              |    6 +++
 6 files changed, 137 insertions(+), 1 deletion(-)

New commits:
commit 10a57edd07f8dc64b60c71d51c225436f4fbb3bc
Author: Akira TAGOH <akira at tagoh.org>
Date:   Mon Jun 8 17:38:02 2015 +0900

    Add one more debugging option to see transformation on font-matching
    
    just setting FC_MATCH=3 shows a lot of information and hard to keep on track for informamtion
    which is really necessary to see. to use this more effectively, added FC_DBG_MATCH_FILTER to
    see for what one really want to see. it takes a comma-separated-list of object names.
    If you want to see family name only, try like this:
    
    FC_DBG_MATCH_FILTER=family FC_DEBUG=4096 fc-match
    
    debugging output will be filtered out and see family only in the result.

diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml
index e7cdb2e..8f49f78 100644
--- a/doc/fontconfig-user.sgml
+++ b/doc/fontconfig-user.sgml
@@ -258,7 +258,7 @@ debugging messages.
   MEMORY         512    Monitor fontconfig memory usage
   CONFIG        1024    Monitor which config files are loaded
   LANGSET       2048    Dump char sets used to construct lang values
-  OBJTYPES      4096    Display message when value typechecks fail
+  MATCH2        4096    Display font-matching transformation in patterns
   </programlisting>
   <para>
 Add the value of the desired debug levels together and assign that (in
@@ -787,6 +787,10 @@ is used to override the default configuration directory.
 is used to output the detailed debugging messages. see <link linkend="debug">Debugging Applications</link> section for more details.
   </para>
   <para>
+<emphasis>FC_DBG_MATCH_FILTER</emphasis>
+is used to filter out the patterns. this takes a comma-separated list of object names and effects only when FC_DEBUG has MATCH2. see <link linkend="debug">Debugging Applications</link> section for more details.
+  </para>
+  <para>
 <emphasis>FONTCONFIG_USE_MMAP</emphasis>
 is used to control the use of mmap(2) for the cache files if available. this take a boolean value. fontconfig will checks if the cache files are stored on the filesystem that is safe to use mmap(2). explicitly setting this environment variable will causes skipping this check and enforce to use or not use mmap(2) anyway.
   </para>
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index a570b2f..eaeb3d9 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -518,6 +518,9 @@ FcPublic void
 FcPatternPrint (const FcPattern *p);
 
 FcPublic void
+FcPatternPrint2 (FcPattern *p1, FcPattern *p2, const FcObjectSet *os);
+
+FcPublic void
 FcFontSetPrint (const FcFontSet *s);
 
 /* fcdefault.c */
@@ -828,6 +831,9 @@ FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSe
 FcPublic FcChar32
 FcPatternHash (const FcPattern *p);
 
+FcPublic int
+FcPatternPosition (const FcPattern *p, const char *object);
+
 FcPublic FcBool
 FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
     
diff --git a/src/fcdbg.c b/src/fcdbg.c
index 985fee9..210fb57 100644
--- a/src/fcdbg.c
+++ b/src/fcdbg.c
@@ -211,6 +211,84 @@ FcPatternPrint (const FcPattern *p)
     }
 
 void
+FcPatternPrint2 (FcPattern         *pp1,
+		 FcPattern         *pp2,
+		 const FcObjectSet *os)
+{
+    int i, j, k, pos;
+    FcPatternElt *e1, *e2;
+    FcPattern *p1, *p2;
+
+    if (os)
+    {
+	p1 = FcPatternFilter (pp1, os);
+	p2 = FcPatternFilter (pp2, os);
+    }
+    else
+    {
+	p1 = pp1;
+	p2 = pp2;
+    }
+    printf ("Pattern has %d elts (size %d), %d elts (size %d)\n",
+	    p1->num, p1->size, p2->num, p2->size);
+    for (i = 0, j = 0; i < p1->num; i++)
+    {
+	e1 = &FcPatternElts(p1)[i];
+	e2 = &FcPatternElts(p2)[j];
+	if (e1->object != e2->object)
+	{
+	    pos = FcPatternPosition (p2, FcObjectName (e1->object));
+	    if (pos >= 0)
+	    {
+		for (k = j; k < pos; k++)
+		{
+		    e2 = &FcPatternElts(p2)[k];
+		    printf ("\t%s: (None) -> ", FcObjectName (e2->object));
+		    FcValueListPrint (FcPatternEltValues (e2));
+		    printf ("\n");
+		}
+		j = pos;
+		goto cont;
+	    }
+	    else
+	    {
+		printf ("\t%s:", FcObjectName (e1->object));
+		FcValueListPrint (FcPatternEltValues (e1));
+		printf (" -> (None)\n");
+	    }
+	}
+	else
+	{
+	cont:
+	    printf ("\t%s:", FcObjectName (e1->object));
+	    FcValueListPrint (FcPatternEltValues (e1));
+	    printf (" -> ");
+	    e2 = &FcPatternElts(p2)[j];
+	    FcValueListPrint (FcPatternEltValues (e2));
+	    printf ("\n");
+	    j++;
+	}
+    }
+    if (j < p2->num)
+    {
+	for (k = j; k < p2->num; k++)
+	{
+	    e2 = &FcPatternElts(p2)[k];
+	    if (FcObjectName (e2->object))
+	    {
+		printf ("\t%s: (None) -> ", FcObjectName (e2->object));
+		FcValueListPrint (FcPatternEltValues (e2));
+		printf ("\n");
+	    }
+	}
+    }
+    if (p1 != pp1)
+	FcPatternDestroy (p1);
+    if (p2 != pp2)
+	FcPatternDestroy (p2);
+}
+
+void
 FcOpPrint (FcOp op_)
 {
     FcOp op = FC_OP_GET_OP (op_);
diff --git a/src/fcint.h b/src/fcint.h
index fda18ce..3ab9e02 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -87,6 +87,7 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #define FC_DBG_SCANV	256
 #define FC_DBG_CONFIG	1024
 #define FC_DBG_LANGSET	2048
+#define FC_DBG_MATCH2	4096
 
 #define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] FC_UNUSED
 #define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 7fbaf0e..40efbd3 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -689,6 +689,47 @@ FcFontSetMatchInternal (FcFontSet   **sets,
 	printf ("\n");
 	FcPatternPrint (best);
     }
+    if (FcDebug () & FC_DBG_MATCH2)
+    {
+	char *env = getenv ("FC_DBG_MATCH_FILTER");
+	FcObjectSet *os = NULL;
+
+	if (env)
+	{
+	    char *ss, *s;
+	    char *p;
+	    FcBool f = FcTrue;
+
+	    ss = s = strdup (env);
+	    os = FcObjectSetCreate ();
+	    while (f)
+	    {
+		size_t len;
+		char *x;
+
+		if (!(p = strchr (s, ',')))
+		{
+		    f = FcFalse;
+		    len = strlen (s) + 1;
+		}
+		else
+		{
+		    len = (p - s) + 1;
+		}
+		x = malloc (sizeof (char) * len);
+		strncpy (x, s, len - 1);
+		x[len - 1] = 0;
+		if (FcObjectFromName (x) > 0)
+		    FcObjectSetAdd (os, x);
+		s = p + 1;
+		free (x);
+	    }
+	    free (ss);
+	}
+	FcPatternPrint2 (p, best, os);
+	if (os)
+	    FcObjectSetDestroy (os);
+    }
     /* assuming that 'result' is initialized with FcResultNoMatch
      * outside this function */
     if (best)
diff --git a/src/fcpat.c b/src/fcpat.c
index 7e7d54a..3ef1ed2 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -425,6 +425,12 @@ FcPatternObjectPosition (const FcPattern *p, FcObject object)
     return -(mid + 1);
 }
 
+int
+FcPatternPosition (const FcPattern *p, const char *object)
+{
+    return FcPatternObjectPosition (p, FcObjectFromName (object));
+}
+
 FcPatternElt *
 FcPatternObjectFindElt (const FcPattern *p, FcObject object)
 {


More information about the Fontconfig mailing list