diff options
author | Akira TAGOH <akira@tagoh.org> | 2015-02-27 14:17:26 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2015-02-27 14:18:32 +0900 |
commit | d6a5cc665a1d7e91332944353e92c83ad114368c (patch) | |
tree | 206915cd8cffe0acccf4b363c9003e884594cb67 /fc-blanks | |
parent | 97cf7ec4d740c9b3ac7c29388224f5e0c226a120 (diff) |
Hardcode the blanks in the library
https://bugs.freedesktop.org/show_bug.cgi?id=79956
Diffstat (limited to 'fc-blanks')
-rw-r--r-- | fc-blanks/Makefile.am | 40 | ||||
-rwxr-xr-x | fc-blanks/fc-blanks.py | 125 | ||||
-rw-r--r-- | fc-blanks/fcblanks.tmpl.h | 25 |
3 files changed, 190 insertions, 0 deletions
diff --git a/fc-blanks/Makefile.am b/fc-blanks/Makefile.am new file mode 100644 index 00000000..f9c2486f --- /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 00000000..fb01614f --- /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 00000000..2bcaa21d --- /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. + */ + +@@@ |