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

Akira TAGOH tagoh at kemper.freedesktop.org
Thu Feb 26 22:57:09 PST 2015


 Makefile.am               |    2 
 configure.ac              |    2 
 fc-blanks/Makefile.am     |   40 +++++++++++++
 fc-blanks/fc-blanks.py    |  132 ++++++++++++++++++++++++++++++++++++++++++++++
 fc-blanks/fcblanks.tmpl.h |   25 ++++++++
 fonts.conf.in             |   68 -----------------------
 src/fcblanks.c            |    7 ++
 src/fccfg.c               |    3 -
 8 files changed, 209 insertions(+), 70 deletions(-)

New commits:
commit a9d4dba7492e060f9d225307c58d79bc50b16cd3
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri Feb 27 15:48:54 2015 +0900

    Update the script to recognize the escaped space

diff --git a/fc-blanks/fc-blanks.py b/fc-blanks/fc-blanks.py
index fb01614..a2f0b95 100755
--- a/fc-blanks/fc-blanks.py
+++ b/fc-blanks/fc-blanks.py
@@ -44,13 +44,20 @@ for i in p:
         fescape = True
     elif i.lower() == 'u' and fescape == True:
         funicode = True
+        fescape = False
     elif i >= '0' and i <= '9' or i.lower() >= 'a' and i.lower() <= 'f':
+        if fescape == True:
+            raise RuntimeError, "Unexpected escape code"
         if funicode == True:
             v <<= 4
             v += int(i, 16)
         else:
             raise RuntimeError, "Unable to parse Unicode"
     elif i == ' ':
+        if fescape == True:
+            funicode = True
+            fescape = False
+            v = 0x20
         if frange == True and funicode == True:
             vend = v
             insert(l, vbegin, vend)
@@ -60,13 +67,13 @@ for i in p:
             vend = v
             insert(l, vbegin, vend)
             fprocess = True
-        fescape = False
         funicode = False
         frange = False
     elif i == '-':
+        if fescape == True:
+            raise RuntimeError, "Unexpected escape code"
         vbegin = v
         v = 0
-        fescape = False
         funicode = False
         frange = True
     else:
@@ -88,8 +95,6 @@ elif funicode == True:
     vbegin = vend = v
     insert(l, vbegin, vend)
 
-# somewhat missing 0x0020 in the list of code from Unicode Utilities
-insert(l, 0x0020, 0x0020)
 ncode = 0
 for i in l:
     ncode += (i[1] - i[0] + 1)
@@ -98,6 +103,8 @@ a = int(x[0].split(' ')[0].replace(',', ''))
 if a != ncode:
     sys.stderr.write("Unexpected the amount of code points: %d (expected %d)\n" % (ncode, a))
     sys.exit(1)
+
+# exception; BRAILLE PATTERN BLANK
 insert(l, 0x2800, 0x2800)
 
 while True:
commit d6a5cc665a1d7e91332944353e92c83ad114368c
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri Feb 27 14:17:26 2015 +0900

    Hardcode the blanks in the library
    
    https://bugs.freedesktop.org/show_bug.cgi?id=79956

diff --git a/Makefile.am b/Makefile.am
index 2b949e4..2b4a5b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,7 +21,7 @@
 #  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 #  PERFORMANCE OF THIS SOFTWARE.
 
-SUBDIRS=fontconfig fc-case fc-lang fc-glyphname src \
+SUBDIRS=fontconfig fc-blanks fc-case fc-lang fc-glyphname src \
 	fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \
 	fc-validate conf.d test
 if ENABLE_DOCS
diff --git a/configure.ac b/configure.ac
index 9141d3d..8f0150e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,7 @@ m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/
 
 AM_MISSING_PROG([GIT], [git])
 AM_MISSING_PROG([GPERF], [gperf])
+AM_PATH_PYTHON
 
 AC_MSG_CHECKING([for RM macro])
 _predefined_rm=`make -p -f /dev/null 2>/dev/null|grep '^RM ='|sed -e 's/^RM = //'`
@@ -697,6 +698,7 @@ Makefile
 fontconfig/Makefile
 fc-lang/Makefile
 fc-glyphname/Makefile
+fc-blanks/Makefile
 fc-case/Makefile
 src/Makefile
 conf.d/Makefile
diff --git a/fc-blanks/Makefile.am b/fc-blanks/Makefile.am
new file mode 100644
index 0000000..f9c2486
--- /dev/null
+++ b/fc-blanks/Makefile.am
@@ -0,0 +1,40 @@
+# -*- encoding: utf-8 -*-
+#
+# Copyright © 2003  Keith Packard
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of the author(s) not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission.  The authors make no
+# representations about the suitability of this software for any purpose.  It
+# is provided "as is" without express or implied warranty.
+#
+# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+NULL =
+BLANKSPY = fc-blanks.py
+BLANKS_H = fcblanks.h
+TMPL = fcblanks.tmpl.h
+noinst_SCRIPTS = $(BLANKSPY)
+noinst_HEADERS = $(BLANKS_H)
+
+$(BLANKS_H): $(BLANKSPY) $(TMPL)
+	$(AM_V_GEN) $(PYTHON) $(BLANKSPY) < $(TMPL) > $(BLANKS_H).tmp && \
+	mv $(BLANKS_H).tmp $(BLANKS_H) || ($(RM) $(BLANKS_H).tmp && false)
+
+EXTRA_DIST = 		\
+	$(BLANKS_H)	\
+	$(TMPL)		\
+	$(NULL)
+DISTCLEANFILES = $(BLANKS_H)
+
+-include $(top_srcdir)/git.mk
diff --git a/fc-blanks/fc-blanks.py b/fc-blanks/fc-blanks.py
new file mode 100755
index 0000000..fb01614
--- /dev/null
+++ b/fc-blanks/fc-blanks.py
@@ -0,0 +1,125 @@
+#! /usr/bin/python
+
+import urllib2
+import sys
+from lxml import html
+
+fp = urllib2.urlopen('http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3AGC%3DZs%3A][%3ADI%3A]&abb=on&ucd=on&esc=on&g')
+data = fp.read()
+fp.close()
+
+dom = html.fromstring(data)
+x = dom.xpath('/html/body/form/p/text()')
+p = x[1]
+if p[0] == '[' and p[-1] == ']':
+    p = p.replace('[', '').replace(']', '')
+else:
+    sys.exit(1)
+fescape = False
+funicode = False
+frange = False
+fprocess = False
+v = 0
+vbegin = 0
+vend = 0
+n = 0
+l = []
+
+def insert(db, begin, end):
+    db.append([begin, end])
+
+for i in p:
+    if i == '\\':
+        if n > 0:
+            if frange == True and funicode == True:
+                vend = v
+                insert(l, vbegin, vend)
+                fprocess = True
+            elif funicode == True:
+                vbegin = v
+                vend = v
+                insert(l, vbegin, vend)
+                fprocess = True
+        funicode = False
+        fescape = True
+    elif i.lower() == 'u' and fescape == True:
+        funicode = True
+    elif i >= '0' and i <= '9' or i.lower() >= 'a' and i.lower() <= 'f':
+        if funicode == True:
+            v <<= 4
+            v += int(i, 16)
+        else:
+            raise RuntimeError, "Unable to parse Unicode"
+    elif i == ' ':
+        if frange == True and funicode == True:
+            vend = v
+            insert(l, vbegin, vend)
+            fprocess = True
+        elif funicode == True:
+            vbegin = v
+            vend = v
+            insert(l, vbegin, vend)
+            fprocess = True
+        fescape = False
+        funicode = False
+        frange = False
+    elif i == '-':
+        vbegin = v
+        v = 0
+        fescape = False
+        funicode = False
+        frange = True
+    else:
+        raise RuntimeError, "Unable to parse Unicode: %s" % i
+
+    if fprocess == True:
+        vbegin = 0
+        vend = 0
+        v = 0
+        fprocess = False
+        funicode = False
+        frange = False
+    n += 1
+
+if frange == True and funicode == True:
+    vend = v
+    insert(l, vbegin, vend)
+elif funicode == True:
+    vbegin = vend = v
+    insert(l, vbegin, vend)
+
+# somewhat missing 0x0020 in the list of code from Unicode Utilities
+insert(l, 0x0020, 0x0020)
+ncode = 0
+for i in l:
+    ncode += (i[1] - i[0] + 1)
+
+a = int(x[0].split(' ')[0].replace(',', ''))
+if a != ncode:
+    sys.stderr.write("Unexpected the amount of code points: %d (expected %d)\n" % (ncode, a))
+    sys.exit(1)
+insert(l, 0x2800, 0x2800)
+
+while True:
+    s = sys.stdin.readline().rstrip()
+    if s == "@@@":
+        break
+    print s
+
+print "static FcChar32 _fcBlanks[%s] = {" % (ncode + 1)
+k = 0
+for i in sorted(l, key=lambda(a): a[0]):
+    for j in range(i[0], i[1] + 1):
+        if k != 0:
+            print ","
+        print "    0x%04x" % j,
+        k += 1
+
+print "};"
+print '''
+static FcBlanks fcBlanks = {
+    %s,
+    -1,
+    _fcBlanks
+};
+''' % (ncode + 1)
diff --git a/fc-blanks/fcblanks.tmpl.h b/fc-blanks/fcblanks.tmpl.h
new file mode 100644
index 0000000..2bcaa21
--- /dev/null
+++ b/fc-blanks/fcblanks.tmpl.h
@@ -0,0 +1,25 @@
+/*
+ * fontconfig/fc-blanks/fcblanks.tmpl.h
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors make no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+@@@
diff --git a/fonts.conf.in b/fonts.conf.in
index f63ada1..7c16a70 100644
--- a/fonts.conf.in
+++ b/fonts.conf.in
@@ -79,74 +79,6 @@
 
 	<config>
 <!--
-  These are the default Unicode chars that are expected to be blank
-  in fonts.  All other blank chars are assumed to be broken and
-  won't appear in the resulting charsets
- -->
-		<blank>
-			<int>0x0020</int>	<!-- SPACE -->
-			<int>0x00A0</int>	<!-- NO-BREAK SPACE -->
-			<int>0x00AD</int>	<!-- SOFT HYPHEN -->
-			<int>0x034F</int>	<!-- COMBINING GRAPHEME JOINER -->
-			<int>0x061C</int>	<!-- ARABIC LETTER MARK -->
-			<int>0x115F</int>	<!-- HANGUL CHOSEONG FILLER -->
-			<int>0x1160</int>	<!-- HANGUL JUNGSEONG FILLER -->
-			<int>0x1680</int>	<!-- OGHAM SPACE MARK -->
-			<int>0x17B4</int>	<!-- KHMER VOWEL INHERENT AQ -->
-			<int>0x17B5</int>	<!-- KHMER VOWEL INHERENT AA -->
-			<int>0x180B</int>	<!-- MONGOLIAN FREE VARIATION SELECTOR ONE -->
-			<int>0x180C</int>	<!-- MONGOLIAN FREE VARIATION SELECTOR TWO -->
-			<int>0x180D</int>	<!-- MONGOLIAN FREE VARIATION SELECTOR THREE -->
-			<int>0x180E</int>	<!-- MONGOLIAN VOWEL SEPARATOR -->
-			<int>0x2000</int>	<!-- EN QUAD -->
-			<int>0x2001</int>	<!-- EM QUAD -->
-			<int>0x2002</int>	<!-- EN SPACE -->
-			<int>0x2003</int>	<!-- EM SPACE -->
-			<int>0x2004</int>	<!-- THREE-PER-EM SPACE -->
-			<int>0x2005</int>	<!-- FOUR-PER-EM SPACE -->
-			<int>0x2006</int>	<!-- SIX-PER-EM SPACE -->
-			<int>0x2007</int>	<!-- FIGURE SPACE -->
-			<int>0x2008</int>	<!-- PUNCTUATION SPACE -->
-			<int>0x2009</int>	<!-- THIN SPACE -->
-			<int>0x200A</int>	<!-- HAIR SPACE -->
-			<int>0x200B</int>	<!-- ZERO WIDTH SPACE -->
-			<int>0x200C</int>	<!-- ZERO WIDTH NON-JOINER -->
-			<int>0x200D</int>	<!-- ZERO WIDTH JOINER -->
-			<int>0x200E</int>	<!-- LEFT-TO-RIGHT MARK -->
-			<int>0x200F</int>	<!-- RIGHT-TO-LEFT MARK -->
-			<int>0x202A</int>	<!-- LEFT-TO-RIGHT EMBEDDING -->
-			<int>0x202B</int>	<!-- RIGHT-TO-LEFT EMBEDDING -->
-			<int>0x202C</int>	<!-- POP DIRECTIONAL FORMATTING -->
-			<int>0x202D</int>	<!-- LEFT-TO-RIGHT OVERRIDE -->
-			<int>0x202E</int>	<!-- RIGHT-TO-LEFT OVERRIDE -->
-			<int>0x202F</int>	<!-- NARROW NO-BREAK SPACE -->
-			<int>0x205F</int>	<!-- MEDIUM MATHEMATICAL SPACE -->
-			<int>0x2060</int>	<!-- WORD JOINER -->
-			<int>0x2061</int>	<!-- FUNCTION APPLICATION -->
-			<int>0x2062</int>	<!-- INVISIBLE TIMES -->
-			<int>0x2063</int>	<!-- INVISIBLE SEPARATOR -->
-			<int>0x2064</int>	<!-- INVISIBLE PLUS -->
-			<int>0x2066</int>	<!-- LEFT-TO-RIGHT ISOLATE -->
-			<int>0x2067</int>	<!-- RIGHT-TO-LEFT ISOLATE -->
-			<int>0x2068</int>	<!-- FIRST STRONG ISOLATE -->
-			<int>0x2069</int>	<!-- POP DIRECTIONAL ISOLATE -->
-			<int>0x206A</int>	<!-- INHIBIT SYMMETRIC SWAPPING -->
-			<int>0x206B</int>	<!-- ACTIVATE SYMMETRIC SWAPPING -->
-			<int>0x206C</int>	<!-- INHIBIT ARABIC FORM SHAPING -->
-			<int>0x206D</int>	<!-- ACTIVATE ARABIC FORM SHAPING -->
-			<int>0x206E</int>	<!-- NATIONAL DIGIT SHAPES -->
-			<int>0x206F</int>	<!-- NOMINAL DIGIT SHAPES -->
-			<int>0x2800</int>	<!-- BRAILLE PATTERN BLANK -->
-			<int>0x3000</int>	<!-- IDEOGRAPHIC SPACE -->
-			<int>0x3164</int>	<!-- HANGUL FILLER -->
-			<int>0xFEFF</int>	<!-- ZERO WIDTH NO-BREAK SPACE -->
-			<int>0xFFA0</int>	<!-- HALFWIDTH HANGUL FILLER -->
-			<int>0x1BCA0</int>	<!-- SHORTHAND FORMAT LETTER OVERLAP -->
-			<int>0x1BCA1</int>	<!-- SHORTHAND FORMAT CONTINUING OVERLAP -->
-			<int>0x1BCA2</int>	<!-- SHORTHAND FORMAT DOWN STEP -->
-			<int>0x1BCA3</int>	<!-- SHORTHAND FORMAT UP STEP -->
-		</blank>
-<!--
   Rescan configuration every 30 seconds when FcFontSetList is called
  -->
 		<rescan>
diff --git a/src/fcblanks.c b/src/fcblanks.c
index 46698bc..49f520b 100644
--- a/src/fcblanks.c
+++ b/src/fcblanks.c
@@ -41,6 +41,8 @@ FcBlanksCreate (void)
 void
 FcBlanksDestroy (FcBlanks *b)
 {
+    if (b->sblank == -1)
+	return;
     if (b->blanks)
 	free (b->blanks);
     free (b);
@@ -56,6 +58,11 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
 	if (b->blanks[sblank] == ucs4)
 	    return FcTrue;
 
+    if (b->sblank == -1)
+    {
+	fprintf (stderr, "Unable to update the static FcBlanks: 0x%04x\n", ucs4);
+	return FcTrue;
+    }
     if (b->nblank == b->sblank)
     {
 	sblank = b->sblank + 32;
diff --git a/src/fccfg.c b/src/fccfg.c
index b27ab0b..e2f7ea8 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -27,6 +27,7 @@
 #include "fcint.h"
 #include <dirent.h>
 #include <sys/types.h>
+#include "../fc-blanks/fcblanks.h"
 
 #if defined (_WIN32) && !defined (R_OK)
 #define R_OK 4
@@ -109,7 +110,7 @@ FcConfigCreate (void)
     if (!config->cacheDirs)
 	goto bail8;
 
-    config->blanks = 0;
+    config->blanks = &fcBlanks;
 
     config->substPattern = 0;
     config->substFont = 0;


More information about the Fontconfig mailing list