Commit f373e2d9bc5856925c6df82e6022e3e88881947a

David Turner 2001-10-18T13:20:01

rewrote "glnames.py" to fix a rather nasty bug that made FreeType return incorrect glyph names for certain glyph indices..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
diff --git a/ChangeLog b/ChangeLog
index 1f8dfcb..b655895 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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..
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index c98aa78..0dcbfe8 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -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];
diff --git a/src/pshinter/pshmod.c b/src/pshinter/pshmod.c
index 65b360d..c0fa29f 100644
--- a/src/pshinter/pshmod.c
+++ b/src/pshinter/pshmod.c
@@ -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,
diff --git a/src/psnames/pstables.h b/src/psnames/pstables.h
index 3db8fe7..39c838a 100644
--- a/src/psnames/pstables.h
+++ b/src/psnames/pstables.h
@@ -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,
+    177,
+    179,
+    181,
     182,
-    183,
-    191,
-    194,
-    200,
+    190,
+    193,
+    199,
+    204,
+    207,
     205,
-    208,
     206,
-    207,
-    210,
     209,
+    208,
+    210,
     211,
+    214,
     212,
-    215,
     213,
-    214,
+    215,
+    218,
     216,
-    219,
     217,
-    218,
+    219,
     220,
+    223,
     221,
-    224,
     222,
-    223,
-    225,
+    224,
+    226,
+    229,
     227,
-    230,
     228,
-    229,
-    117,
-    166,
+    116,
+    165,
+    101,
     102,
-    103,
-    107,
-    121,
+    106,
     120,
-    154,
-    170,
-    175,
-    158,
-    130,
-    136,
-    2,
-    143,
-    146,
-    3,
-    161,
-    4,
-    5,
-    105,
+    119,
+    153,
+    169,
+    174,
     157,
-    6,
-    7,
-    8,
-    9,
-    10,
-    144,
-    148,
-    11,
-    149,
-    152,
-    128,
-    101,
+    129,
+    135,
+    959,
+    142,
+    145,
+    917,
+    160,
+    941,
+    908,
+    104,
     156,
-    12,
-    106,
-    13,
-    14,
-    111,
-    125,
-    126,
-    15,
-    179,
-    181,
-    196,
+    980,
+    1018,
+    987,
+    985,
+    918,
+    143,
     147,
-    153,
-    116,
-    142,
+    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
   };
 
diff --git a/src/tools/glnames.py b/src/tools/glnames.py
index 808e365..561774d 100644
--- a/src/tools/glnames.py
+++ b/src/tools/glnames.py
@@ -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
-
-  # 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 )
+  # 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 )
+
+  # 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 )