Commit bd889e5de9676e3705592c21565c06ae5f59c6e3

Werner Lemberg 2002-05-12T19:59:17

* src/sfnt/ttload.c (TT_LookUp_Table): Protect against tables with a zero length value. * builds/beos/beos.mk: Include `link-std.mk'. * src/type1/t1load.h (T1_Loader): Renamed to... (T1_LoaderRec): This. (T1_Loader): Now pointer to T1_LoaderRec. * src/type1/t1load.c: Updated. * include/freetype/internal/t1types.h, src/type1/t1load.c, src/type1/t1objs.c: s/T1_ENCODING_TYPE_EXPORT/T1_ENCODING_TYPE_EXPERT/.

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
diff --git a/ChangeLog b/ChangeLog
index 5232288..0537d5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2002-05-12  Owen Taylor  <otaylor@redhat.com>
+
+	* src/sfnt/ttload.c (TT_LookUp_Table): Protect against tables
+	with a zero length value.
+
+2002-05-12  Michael Pfeiffer  <michael.pfeiffer@utanet.at>
+
+	* builds/beos/beos.mk: Include `link-std.mk'.
+
+2002-05-12  Werner Lemberg  <wl@gnu.org>
+
+	* src/type1/t1load.h (T1_Loader): Renamed to...
+	(T1_LoaderRec): This.
+	(T1_Loader): Now pointer to T1_LoaderRec.
+	* src/type1/t1load.c: Updated.
+
+	* include/freetype/internal/t1types.h, src/type1/t1load.c,
+	src/type1/t1objs.c:
+	s/T1_ENCODING_TYPE_EXPORT/T1_ENCODING_TYPE_EXPERT/.
+
 2002-05-06  Werner Lemberg  <wl@gnu.org>
 
 	* README: Add a note regarding libttf vs. libfreetype.
diff --git a/builds/beos/beos.mk b/builds/beos/beos.mk
index 956b96a..9c0ff5f 100644
--- a/builds/beos/beos.mk
+++ b/builds/beos/beos.mk
@@ -2,7 +2,7 @@
 # FreeType 2 configuration rules for a BeOS system
 #
 
-# Copyright 1996-2000 by
+# Copyright 1996-2000, 2002 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -13,6 +13,7 @@
 
 include $(TOP)/builds/compiler/ansi-cc.mk
 include $(TOP)/builds/beos/beos-def.mk
+include $(TOP)/builds/link_std.mk
 
 # EOF
 
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index fbb5bc6..6a14f30 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -81,7 +81,7 @@ FT_BEGIN_HEADER
     T1_ENCODING_TYPE_ARRAY,
     T1_ENCODING_TYPE_STANDARD,
     T1_ENCODING_TYPE_ISOLATIN1,
-    T1_ENCODING_TYPE_EXPORT
+    T1_ENCODING_TYPE_EXPERT
 
   } T1_EncodingType;
 
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 24ab8bb..15f2786 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -73,7 +73,9 @@
 
     for ( ; entry < limit; entry++ )
     {
-      if ( entry->Tag == tag )
+      /* For compatibility with Windows, we consider 0-length */
+      /* tables the same as missing tables.                   */
+      if ( entry->Tag == tag && entry->Length != 0 )
       {
         FT_TRACE3(( "found table.\n" ));
         return entry;
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index db611e3..e7b1e6e 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -445,8 +445,8 @@
             const char*  gname = face->type1.glyph_names[n];
 
 
-            if ( gname && gname[0] == glyph_name[0] &&
-                 ft_strcmp( gname, glyph_name ) == 0   )
+            if ( gname && gname[0] == glyph_name[0]  &&
+                 ft_strcmp( gname, glyph_name ) == 0 )
               return charcode;
           }
         }
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index d062975..d2f810d 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -378,8 +378,8 @@
 
 
   static void
-  parse_blend_axis_types( T1_Face     face,
-                          T1_Loader*  loader )
+  parse_blend_axis_types( T1_Face    face,
+                          T1_Loader  loader )
   {
     T1_TokenRec  axis_tokens[ T1_MAX_MM_AXIS ];
     FT_Int       n, num_axis;
@@ -440,8 +440,8 @@
 
 
   static void
-  parse_blend_design_positions( T1_Face     face,
-                                T1_Loader*  loader )
+  parse_blend_design_positions( T1_Face    face,
+                                T1_Loader  loader )
   {
     T1_TokenRec  design_tokens[ T1_MAX_MM_DESIGNS ];
     FT_Int       num_designs;
@@ -522,8 +522,8 @@
 
 
   static void
-  parse_blend_design_map( T1_Face     face,
-                          T1_Loader*  loader )
+  parse_blend_design_map( T1_Face    face,
+                          T1_Loader  loader )
   {
     FT_Error     error  = 0;
     T1_Parser    parser = &loader->parser;
@@ -603,8 +603,8 @@
 
 
   static void
-  parse_weight_vector( T1_Face     face,
-                       T1_Loader*  loader )
+  parse_weight_vector( T1_Face    face,
+                       T1_Loader  loader )
   {
     FT_Error     error  = 0;
     T1_Parser    parser = &loader->parser;
@@ -655,8 +655,8 @@
   /* of spec!); we detect it and terminate the parsing                 */
   /*                                                                   */
   static void
-  parse_shared_dict( T1_Face     face,
-                     T1_Loader*  loader )
+  parse_shared_dict( T1_Face    face,
+                     T1_Loader  loader )
   {
     T1_Parser  parser = &loader->parser;
 
@@ -688,15 +688,15 @@
 
 
   static FT_Error
-  t1_load_keyword( T1_Face     face,
-                   T1_Loader*  loader,
-                   T1_Field    field )
+  t1_load_keyword( T1_Face    face,
+                   T1_Loader  loader,
+                   T1_Field   field )
   {
-    FT_Error   error;
-    void*      dummy_object;
-    void**     objects;
-    FT_UInt    max_objects;
-    PS_Blend   blend = face->blend;
+    FT_Error  error;
+    void*     dummy_object;
+    void**    objects;
+    FT_UInt   max_objects;
+    PS_Blend  blend = face->blend;
 
 
     /* if the keyword has a dedicated callback, call it */
@@ -767,7 +767,11 @@
     /* Note: we must accept "+" as a valid character, as it is used in */
     /*       embedded type1 fonts in PDF documents.                    */
     /*                                                                 */
-    return ( ft_isalnum( c ) || c == '.' || c == '_' || c == '-' || c == '+' );
+    return ( ft_isalnum( c ) ||
+             c == '.'        ||
+             c == '_'        ||
+             c == '-'        ||
+             c == '+'        );
   }
 
 
@@ -814,8 +818,8 @@
   /* dictionaries                                   */
 
   static void
-  parse_font_name( T1_Face     face,
-                   T1_Loader*  loader )
+  parse_font_name( T1_Face    face,
+                   T1_Loader  loader )
   {
     T1_Parser  parser = &loader->parser;
     FT_Error   error;
@@ -860,8 +864,8 @@
 
 
   static void
-  parse_font_bbox( T1_Face     face,
-                   T1_Loader*  loader )
+  parse_font_bbox( T1_Face    face,
+                   T1_Loader  loader )
   {
     T1_Parser  parser = &loader->parser;
     FT_Fixed   temp[4];
@@ -877,8 +881,8 @@
 
 
   static void
-  parse_font_matrix( T1_Face     face,
-                     T1_Loader*  loader )
+  parse_font_matrix( T1_Face    face,
+                     T1_Loader  loader )
   {
     T1_Parser   parser = &loader->parser;
     FT_Matrix*  matrix = &face->type1.font_matrix;
@@ -889,7 +893,7 @@
 
 
     if ( matrix->xx || matrix->yx )
-      /*  with synthetic fonts, it's possible we get here twice  */
+      /* with synthetic fonts, it's possible we get here twice  */
       return;
 
     (void)T1_ToFixedArray( parser, 6, temp, 3 );
@@ -926,8 +930,8 @@
 
 
   static void
-  parse_encoding( T1_Face     face,
-                  T1_Loader*  loader )
+  parse_encoding( T1_Face    face,
+                  T1_Loader  loader )
   {
     T1_Parser      parser = &loader->parser;
     FT_Byte*       cur    = parser->root.cursor;
@@ -973,13 +977,13 @@
       if ( FT_NEW_ARRAY( encode->char_index, count ) ||
            FT_NEW_ARRAY( encode->char_name,  count ) ||
            FT_SET_ERROR( psaux->ps_table_funcs->init(
-                       char_table, count, memory ) ) )
+                           char_table, count, memory ) ) )
       {
         parser->root.error = error;
         return;
       }
 
-      /* We need to `zero' out encoding_table.elements          */
+      /* We need to `zero' out encoding_table.elements */
       for ( n = 0; n < count; n++ )
       {
         char*  notdef = (char *)".notdef";
@@ -1015,10 +1019,10 @@
         /* we stop when we encounter a `def' */
         if ( c == 'd' && cur + 3 < limit )
         {
-          if ( cur[1] == 'e' &&
-               cur[2] == 'f' &&
-               is_space(cur[-1]) &&
-               is_space(cur[3]) )
+          if ( cur[1] == 'e'       &&
+               cur[2] == 'f'       &&
+               is_space( cur[-1] ) &&
+               is_space( cur[3] )  )
           {
             FT_TRACE6(( "encoding end\n" ));
             break;
@@ -1033,7 +1037,7 @@
 
           parser->root.cursor = cur;
           charcode = T1_ToInt( parser );
-          cur = parser->root.cursor;
+          cur      = parser->root.cursor;
 
           /* skip whitespace */
           while ( cur < limit && is_space( *cur ) )
@@ -1068,19 +1072,19 @@
       face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
       parser->root.cursor       = cur;
     }
-    /* Otherwise, we should have either `StandardEncoding' or */
-    /* `ExpertEncoding'                                       */
+    /* Otherwise, we should have either `StandardEncoding', */
+    /* `ExpertEncoding', or `ISOLatin1Encoding'             */
     else
     {
-      if ( cur + 17 < limit &&
+      if ( cur + 17 < limit                                            &&
            ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
         face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
 
-      else if ( cur + 15 < limit &&
+      else if ( cur + 15 < limit                                          &&
                 ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
-        face->type1.encoding_type = T1_ENCODING_TYPE_EXPORT;
+        face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
 
-      else if ( cur + 18 < limit &&
+      else if ( cur + 18 < limit                                             &&
                 ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
         face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
 
@@ -1094,8 +1098,8 @@
 
 
   static void
-  parse_subrs( T1_Face     face,
-               T1_Loader*  loader )
+  parse_subrs( T1_Face    face,
+               T1_Loader  loader )
   {
     T1_Parser      parser = &loader->parser;
     PS_Table       table  = &loader->subrs;
@@ -1191,8 +1195,8 @@
 
 
   static void
-  parse_charstrings( T1_Face     face,
-                     T1_Loader*  loader )
+  parse_charstrings( T1_Face    face,
+                     T1_Loader  loader )
   {
     T1_Parser      parser       = &loader->parser;
     PS_Table       code_table   = &loader->charstrings;
@@ -1241,8 +1245,8 @@
     if ( error )
       goto Fail;
 
-
     n = 0;
+
     for (;;)
     {
       FT_Int    size;
@@ -1479,10 +1483,10 @@
 
 
   static FT_Error
-  parse_dict( T1_Face     face,
-              T1_Loader*  loader,
-              FT_Byte*    base,
-              FT_Long     size )
+  parse_dict( T1_Face    face,
+              T1_Loader  loader,
+              FT_Byte*   base,
+              FT_Long    size )
   {
     T1_Parser  parser = &loader->parser;
 
@@ -1499,7 +1503,7 @@
       for ( ; cur < limit; cur++ )
       {
         /* look for `FontDirectory', which causes problems on some fonts */
-        if ( *cur == 'F' && cur + 25 < limit                 &&
+        if ( *cur == 'F' && cur + 25 < limit                    &&
              ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
         {
           FT_Byte*  cur2;
@@ -1596,8 +1600,8 @@
 
 
   static void
-  t1_init_loader( T1_Loader*  loader,
-                  T1_Face     face )
+  t1_init_loader( T1_Loader  loader,
+                  T1_Face    face )
   {
     FT_UNUSED( face );
 
@@ -1616,7 +1620,7 @@
 
 
   static void
-  t1_done_loader( T1_Loader*  loader )
+  t1_done_loader( T1_Loader  loader )
   {
     T1_Parser  parser = &loader->parser;
 
@@ -1636,7 +1640,7 @@
   FT_LOCAL_DEF( FT_Error )
   T1_Open_Face( T1_Face  face )
   {
-    T1_Loader      loader;
+    T1_LoaderRec   loader;
     T1_Parser      parser;
     T1_Font        type1 = &face->type1;
     FT_Error       error;
@@ -1701,8 +1705,7 @@
     loader.glyph_names.block    = 0;
     loader.glyph_names.elements = 0;
 
-    /* we must now build type1.encoding when we have a custom */
-    /* array..                                                */
+    /* we must now build type1.encoding when we have a custom array */
     if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
     {
       FT_Int    charcode, idx, min_char, max_char;
@@ -1740,8 +1743,8 @@
               if ( ft_strcmp( (const char*)".notdef",
                               (const char*)glyph_name ) != 0 )
               {
-                if (charcode < min_char) min_char = charcode;
-                if (charcode > max_char) max_char = charcode;
+                if ( charcode < min_char ) min_char = charcode;
+                if ( charcode > max_char ) max_char = charcode;
               }
               break;
             }
diff --git a/src/type1/t1load.h b/src/type1/t1load.h
index 865d62c..804a010 100644
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -48,7 +48,7 @@ FT_BEGIN_HEADER
     PS_TableRec   subrs;
     FT_Bool       fontdata;
 
-  } T1_Loader;
+  } T1_LoaderRec, *T1_Loader;
 
 
   FT_LOCAL( FT_Error )
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 18d0b1e..2755f25 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -327,10 +327,9 @@
 
       root->num_glyphs = face->type1.num_glyphs;
       root->face_index = face_index;
-      root->face_flags = FT_FACE_FLAG_SCALABLE;
 
+      root->face_flags = FT_FACE_FLAG_SCALABLE;
       root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
-
       root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
 
       if ( face->type1.font_info.is_fixed_pitch )
@@ -432,28 +431,28 @@
 
     {
       FT_Face  root = &face->root;
-      
+
 
       if ( psnames && psaux )
       {
         FT_CharMapRec    charmap;
         T1_CMap_Classes  cmap_classes = psaux->t1_cmap_classes;
         FT_CMap_Class    clazz;
-        
+
 
         charmap.face = root;
-        
+
         /* first of all, try to synthetize a Unicode charmap */
         charmap.platform_id = 3;
         charmap.encoding_id = 1;
         charmap.encoding    = ft_encoding_unicode;
-        
+
         FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
-        
+
         /* now, generate an Adobe Standard encoding when appropriate */
         charmap.platform_id = 7;
         clazz               = NULL;
-        
+
         switch ( face->type1.encoding_type )
         {
         case T1_ENCODING_TYPE_STANDARD:
@@ -461,29 +460,29 @@
           charmap.encoding_id = 0;
           clazz               = cmap_classes->standard;
           break;
-          
-        case T1_ENCODING_TYPE_EXPORT:
+
+        case T1_ENCODING_TYPE_EXPERT:
           charmap.encoding    = ft_encoding_adobe_expert;
           charmap.encoding_id = 1;
           clazz               = cmap_classes->expert;
           break;
-            
+
         case T1_ENCODING_TYPE_ARRAY:
           charmap.encoding    = ft_encoding_adobe_custom;
           charmap.encoding_id = 2;
           clazz               = cmap_classes->custom;
           break;
-            
+
         case T1_ENCODING_TYPE_ISOLATIN1:
           charmap.encoding    = ft_encoding_latin_1;
           charmap.encoding_id = 3;
           clazz               = cmap_classes->unicode;
           break;
-            
+
         default:
           ;
         }
-        
+
         if ( clazz )
           FT_CMap_New( clazz, NULL, &charmap, NULL );
       }
@@ -535,7 +534,7 @@
         charmap->encoding_id = 0;
         break;
 
-      case T1_ENCODING_TYPE_EXPORT:
+      case T1_ENCODING_TYPE_EXPERT:
         charmap->encoding    = ft_encoding_adobe_expert;
         charmap->encoding_id = 1;
         break;