Hardcode the blanks in the library

https://bugs.freedesktop.org/show_bug.cgi?id=79956
This commit is contained in:
Akira TAGOH 2015-02-27 14:17:26 +09:00
parent 97cf7ec4d7
commit d6a5cc665a
8 changed files with 202 additions and 70 deletions

View File

@ -21,7 +21,7 @@
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE. # 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-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \
fc-validate conf.d test fc-validate conf.d test
if ENABLE_DOCS if ENABLE_DOCS

View File

@ -53,6 +53,7 @@ m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/
AM_MISSING_PROG([GIT], [git]) AM_MISSING_PROG([GIT], [git])
AM_MISSING_PROG([GPERF], [gperf]) AM_MISSING_PROG([GPERF], [gperf])
AM_PATH_PYTHON
AC_MSG_CHECKING([for RM macro]) AC_MSG_CHECKING([for RM macro])
_predefined_rm=`make -p -f /dev/null 2>/dev/null|grep '^RM ='|sed -e 's/^RM = //'` _predefined_rm=`make -p -f /dev/null 2>/dev/null|grep '^RM ='|sed -e 's/^RM = //'`
@ -697,6 +698,7 @@ Makefile
fontconfig/Makefile fontconfig/Makefile
fc-lang/Makefile fc-lang/Makefile
fc-glyphname/Makefile fc-glyphname/Makefile
fc-blanks/Makefile
fc-case/Makefile fc-case/Makefile
src/Makefile src/Makefile
conf.d/Makefile conf.d/Makefile

40
fc-blanks/Makefile.am Normal file
View File

@ -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

125
fc-blanks/fc-blanks.py Executable file
View File

@ -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)

25
fc-blanks/fcblanks.tmpl.h Normal file
View File

@ -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.
*/
@@@

View File

@ -78,74 +78,6 @@
<cachedir>~/.fontconfig</cachedir> <cachedir>~/.fontconfig</cachedir>
<config> <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 configuration every 30 seconds when FcFontSetList is called
--> -->

View File

@ -41,6 +41,8 @@ FcBlanksCreate (void)
void void
FcBlanksDestroy (FcBlanks *b) FcBlanksDestroy (FcBlanks *b)
{ {
if (b->sblank == -1)
return;
if (b->blanks) if (b->blanks)
free (b->blanks); free (b->blanks);
free (b); free (b);
@ -56,6 +58,11 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
if (b->blanks[sblank] == ucs4) if (b->blanks[sblank] == ucs4)
return FcTrue; 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) if (b->nblank == b->sblank)
{ {
sblank = b->sblank + 32; sblank = b->sblank + 32;

View File

@ -27,6 +27,7 @@
#include "fcint.h" #include "fcint.h"
#include <dirent.h> #include <dirent.h>
#include <sys/types.h> #include <sys/types.h>
#include "../fc-blanks/fcblanks.h"
#if defined (_WIN32) && !defined (R_OK) #if defined (_WIN32) && !defined (R_OK)
#define R_OK 4 #define R_OK 4
@ -109,7 +110,7 @@ FcConfigCreate (void)
if (!config->cacheDirs) if (!config->cacheDirs)
goto bail8; goto bail8;
config->blanks = 0; config->blanks = &fcBlanks;
config->substPattern = 0; config->substPattern = 0;
config->substFont = 0; config->substFont = 0;