rewrote "glnames.py" to fix a rather nasty bug that made FreeType

return incorrect glyph names for certain glyph indices..
This commit is contained in:
David Turner 2001-10-18 13:20:01 +00:00
parent c9349c9343
commit f373e2d9bc
5 changed files with 189 additions and 183 deletions

View File

@ -1,5 +1,10 @@
2001-10-18 David Turner <david@freetype.org>
* src/psnames/pstables.h, src/tools/glnames.py: rewrote the "glnames.py"
script used to generate the "pstables.h" header file. The old one
contained a bug (yes !!) that made FreeType return incorrect glyph
names for certain glyphs..
* src/truetype/ttdriver.c: changing computation of pixel size from
character size to use rounding. This is an experiment to see if this
gives values similar to Windows for scaled ascent/descent/etc..

View File

@ -238,9 +238,10 @@
{
PSH2_Hint* sort = table->sort;
FT_UInt count2;
PSH2_Hint hint2;
#if 0
PSH2_Hint hint2;
for ( count2 = count; count2 > 0; count2--, sort++ )
{
hint2 = sort[0];

View File

@ -34,7 +34,7 @@
/* finalize module */
FT_CALLBACK_DEF void
FT_CALLBACK_DEF(void)
ps_hinter_done( PS_Hinter_Module module )
{
module->t1_funcs.hints = NULL;
@ -45,7 +45,7 @@
/* initialise module, create hints recorder and the interface */
FT_CALLBACK_DEF FT_Error
FT_CALLBACK_DEF(FT_Error)
ps_hinter_init( PS_Hinter_Module module )
{
FT_Memory memory = module->root.memory;
@ -65,7 +65,7 @@
/* returns global hints interface */
FT_CALLBACK_DEF PSH_Globals_Funcs
FT_CALLBACK_DEF(PSH_Globals_Funcs)
pshinter_get_globals_funcs( FT_Module module )
{
return &((PS_Hinter_Module)module)->globals_funcs;
@ -73,7 +73,7 @@
/* return Type 1 hints interface */
FT_CALLBACK_DEF T1_Hints_Funcs
FT_CALLBACK_DEF(T1_Hints_Funcs)
pshinter_get_t1_funcs( FT_Module module )
{
return &((PS_Hinter_Module)module)->t1_funcs;
@ -81,15 +81,15 @@
/* return Type 2 hints interface */
FT_CALLBACK_DEF T2_Hints_Funcs
FT_CALLBACK_DEF(T2_Hints_Funcs)
pshinter_get_t2_funcs( FT_Module module )
{
return &((PS_Hinter_Module)module)->t2_funcs;
}
FT_CALLBACK_DEF
PSHinter_Interface pshinter_interface =
FT_CALLBACK_DEF(PSHinter_Interface)
pshinter_interface =
{
pshinter_get_globals_funcs,
pshinter_get_t1_funcs,

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* c:\david\source\freetype\freetype2\src\psnames\pstables.h */
/* pstables.h */
/* */
/* PostScript glyph names (specification only). */
/* */
@ -21,7 +21,6 @@
static const char* const ps_glyph_names[] =
{
".notdef",
".null",
"nonmarkingreturn",
"nonbreakingspace",
@ -1094,7 +1093,7 @@
};
static const char* const * const sid_standard_names = ps_glyph_names + 5;
static const char* const * const sid_standard_names = ps_glyph_names + 4;
#define NUM_SID_GLYPHS 391
@ -1108,17 +1107,18 @@
static const unsigned short mac_standard_names[259] =
{
5,
4,
0,
1,
5,
6,
7,
8,
9,
10,
11,
12,
109,
108,
13,
14,
15,
16,
@ -1174,8 +1174,8 @@
66,
67,
68,
69,
129,
128,
70,
71,
72,
73,
@ -1205,167 +1205,166 @@
97,
98,
99,
100,
178,
180,
182,
183,
191,
194,
200,
205,
208,
206,
207,
210,
209,
211,
212,
215,
213,
214,
216,
219,
217,
218,
220,
221,
224,
222,
223,
225,
227,
230,
228,
229,
117,
166,
102,
103,
107,
121,
120,
154,
170,
175,
158,
130,
136,
2,
143,
146,
3,
161,
4,
5,
105,
157,
6,
7,
8,
9,
10,
144,
148,
11,
149,
152,
128,
101,
156,
12,
106,
13,
14,
111,
125,
126,
15,
177,
179,
181,
196,
147,
153,
182,
190,
193,
199,
204,
207,
205,
206,
209,
208,
210,
211,
214,
212,
213,
215,
218,
216,
217,
219,
220,
223,
221,
222,
224,
226,
229,
227,
228,
116,
165,
101,
102,
106,
120,
119,
153,
169,
174,
157,
129,
135,
959,
142,
145,
917,
160,
941,
908,
104,
156,
980,
1018,
987,
985,
918,
143,
147,
471,
148,
151,
127,
100,
155,
994,
105,
815,
412,
110,
124,
70,
13,
164,
16,
232,
203,
104,
108,
125,
2,
178,
180,
195,
146,
152,
115,
141,
109,
123,
69,
12,
163,
948,
231,
202,
103,
107,
111,
112,
113,
114,
115,
117,
118,
119,
121,
122,
123,
127,
177,
184,
126,
176,
183,
175,
184,
185,
186,
187,
188,
189,
190,
191,
192,
193,
17,
195,
3,
194,
197,
198,
199,
201,
150,
200,
149,
130,
131,
132,
133,
134,
135,
136,
137,
138,
139,
140,
141,
145,
151,
197,
226,
204,
233,
165,
159,
144,
150,
196,
225,
203,
232,
164,
158,
171,
201,
230,
161,
166,
170,
172,
202,
231,
154,
168,
173,
159,
162,
167,
171,
173,
155,
169,
174,
160,
163,
168,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
899,
429,
901,
444,
526,
1006,
404,
847,
406,
849,
868,
0
};

View File

@ -1504,8 +1504,8 @@ def adobe_glyph_values():
return glyphs, values
def count_extra_glyphs( alist, filter ):
"""count the number of extra glyphs"""
def filter_glyph_names( alist, filter ):
"""filter 'alist' by taking _out_ all glyph names that are in 'filter'"""
count = 0
extras = []
@ -1519,21 +1519,15 @@ def count_extra_glyphs( alist, filter ):
return extras
def dump_mac_indices( file, t1_bias ):
def dump_mac_indices( file, all_glyphs ):
write = file.write
write( " static const unsigned short mac_standard_names[" + \
repr( len( mac_standard_names ) + 1 ) + "] =\n" )
write( " {\n" )
count = 0
for name in mac_standard_names:
try:
t1_index = sid_standard_names.index( name )
write( " " + repr( t1_bias + t1_index ) + ",\n" )
except:
write( " " + repr( count ) + ",\n" )
count = count + 1
write( " " + repr( all_glyphs.index(name) ) + ",\n" )
write( " 0\n" )
write( " };\n" )
@ -1541,7 +1535,7 @@ def dump_mac_indices( file, t1_bias ):
write( "\n" )
def dump_glyph_list( file, glyph_list, adobe_extra ):
def dump_glyph_list( file, base_list, adobe_list ):
write = file.write
name_list = []
@ -1549,7 +1543,7 @@ def dump_glyph_list( file, glyph_list, adobe_extra ):
write( " static const char* const ps_glyph_names[] =\n" )
write( " {\n" )
for name in glyph_list:
for name in base_list:
write( ' "' + name + '",\n' )
name_list.append( name )
@ -1557,7 +1551,7 @@ def dump_glyph_list( file, glyph_list, adobe_extra ):
write( "#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST\n" )
write( "\n" )
for name in adobe_extra:
for name in adobe_list:
write( ' "' + name + '",\n' )
name_list.append( name )
@ -1572,22 +1566,22 @@ def dump_glyph_list( file, glyph_list, adobe_extra ):
return name_list
def dump_unicode_values( file, base_list, adobe_list ):
def dump_unicode_values( file, sid_list, adobe_list ):
"""build the glyph names to unicode values table"""
write = file.write
glyph_names, uni_values = adobe_glyph_values()
agl_names, agl_unicodes = adobe_glyph_values()
write( "\n" )
write( " static const unsigned short ps_names_to_unicode[" + \
repr( len( base_list ) + len( adobe_list ) + 1 ) + "] =\n" )
repr( len( sid_list ) + len( adobe_list ) + 1 ) + "] =\n" )
write( " {\n" )
for name in base_list:
for name in sid_list:
try:
index = glyph_names.index( name )
write( " 0x" + uni_values[index] + ",\n" )
index = agl_names.index( name )
write( " 0x" + agl_unicodes[index] + ",\n" )
except:
write( " 0,\n" )
@ -1597,8 +1591,8 @@ def dump_unicode_values( file, base_list, adobe_list ):
for name in adobe_list:
try:
index = glyph_names.index( name )
write( " 0x" + uni_values[index] + ",\n" )
index = agl_names.index( name )
write( " 0x" + agl_unicodes[index] + ",\n" )
except:
write( " 0,\n" )
@ -1640,16 +1634,25 @@ def main():
count_sid = len( sid_standard_names )
# build mac index table & supplemental glyph names
mac_list = count_extra_glyphs( mac_standard_names, adobe_glyph_names() )
count_mac = len( mac_list )
t1_bias = count_mac
base_list = mac_list + sid_standard_names
# mac_extras contains the list of glyph names in the Macintosh standard
# encoding which are not in either the Adobe Glyph List or the SID Standard Names
#
mac_extras = filter_glyph_names( mac_standard_names, adobe_glyph_names() )
mac_extras = filter_glyph_names( mac_extras, sid_standard_names )
# build adobe unicode index table & supplemental glyph names
adobe_list = adobe_glyph_names()
adobe_list = count_extra_glyphs( adobe_list, base_list )
count_adobe = len( adobe_list )
# base_list contains the first names of our final glyph names table. It consists
# of the "mac_extras" glyph names, followed by the SID Standard names
#
mac_extras_count = len( mac_extras )
t1_bias = mac_extras_count
base_list = mac_extras + sid_standard_names
# adobe_list contains the glyph names that are in the AGL, but no in
# the base_list, they will be placed after base_list glyph names in
# our final table..
#
adobe_list = filter_glyph_names( adobe_glyph_names(), base_list )
adobe_count = len( adobe_list )
write( "/***************************************************************************/\n" )
write( "/* */\n" )
@ -1675,7 +1678,8 @@ def main():
write( "\n" )
write( "\n" )
# dump glyph list
# dump final glyph list (mac extras + sid standard names + AGL glyph names)
#
name_list = dump_glyph_list( file, base_list, adobe_list )
# dump t1_standard_list
@ -1697,13 +1701,10 @@ def main():
write( "\n" )
# dump mac indices table
dump_mac_indices( file, t1_bias )
# discard mac names from base list
base_list = base_list[t1_bias:]
dump_mac_indices( file, name_list )
# dump unicode values table
dump_unicode_values( file, base_list, adobe_list )
dump_unicode_values( file, sid_standard_names, adobe_list )
dump_encoding( file, "t1_standard_encoding", t1_standard_encoding )
dump_encoding( file, "t1_expert_encoding", t1_expert_encoding )