Commit d1214ac947c544f47fbf30f5ebbf4faab4f409f1

David Turner 2002-07-17T21:14:23

* include/freetype/config/ftoption.h, include/freetype/internal/tttypes.h, src/base/ftobjs.c, src/bdf/bdfdrivr.c, src/cff/cffobjs.c, src/pcf/pcfdrivr.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c, src/sfnt/ttcmap0.h, src/sfnt/ttload.c, src/type1/t1objs.c, src/type42/t42objs.c, src/winfonts/winfnt.c: code cleanup, FT_CONFIG_OPTION_USE_CMAPS is now the default

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
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index e0e894b..2ca69b5 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -46,9 +46,6 @@ THE SOFTWARE.
 #define FT_COMPONENT  trace_bdfdriver
 
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
-
   typedef struct  BDF_CMapRec_
   {
     FT_CMapRec        cmap;
@@ -171,39 +168,6 @@ THE SOFTWARE.
   };
 
 
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-
-  static FT_UInt
-  BDF_Get_Char_Index( FT_CharMap  charmap,
-                      FT_ULong    char_code )
-  {
-    BDF_Face          face     = (BDF_Face)charmap->face;
-    BDF_encoding_el*  en_table = face->en_table;
-    int               low, high, mid;
-
-
-    FT_TRACE4(( "BDF_Get_Char_Index %ld\n", char_code ));
-
-    low  = 0;
-    high = face->bdffont->glyphs_used - 1;
-
-    while ( low <= high )
-    {
-      mid = ( low + high ) / 2;
-      if ( char_code < en_table[mid].enc )
-        high = mid - 1;
-      else if ( char_code > en_table[mid].enc )
-        low = mid + 1;
-      else
-        return en_table[mid].glyph + 1;
-    }
-
-    return face->bdffont->default_glyph + 1;
-  }
-
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
 
 
   FT_CALLBACK_DEF( FT_Error )
@@ -429,8 +393,6 @@ THE SOFTWARE.
                    !ft_strcmp( face->charset_encoding, "1" )       )  )
               unicode_charmap = 1;
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
             {
               FT_CharMapRec  charmap;
 
@@ -454,32 +416,12 @@ THE SOFTWARE.
                 root->charmap = root->charmaps[0];
             }
 
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-            face->charmap.encoding    = ft_encoding_none;
-            face->charmap.platform_id = 0;
-            face->charmap.encoding_id = 0;
-            if ( unicode_charmap )
-            {
-              face->charmap.encoding    = ft_encoding_unicode;
-              face->charmap.platform_id = 3;
-              face->charmap.encoding_id = 1;
-            }
-            face->charmap.face        = root;
-            face->charmap_handle      = &face->charmap;
-
-            root->charmap = face->charmap_handle;
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
             goto Exit;
           }
         }
 
         /* otherwise assume Adobe standard encoding */
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
         {
           FT_CharMapRec  charmap;
 
@@ -495,19 +437,6 @@ THE SOFTWARE.
           if (root->num_charmaps)
             root->charmap = root->charmaps[0];
         }
-
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-        face->charmap.encoding    = ft_encoding_adobe_standard;
-        face->charmap.platform_id = 7; /* taken from t1objs.c */
-        face->charmap.encoding_id = 0;
-        face->charmap.face        = root;
-        face->charmap_handle      = &face->charmap;
-
-        root->charmap = face->charmap_handle;
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
       }
     }
 
@@ -733,21 +662,13 @@ THE SOFTWARE.
 
     (FT_Slot_LoadFunc)        BDF_Glyph_Load,
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
     (FT_CharMap_CharIndexFunc)0,
-#else
-    (FT_CharMap_CharIndexFunc)BDF_Get_Char_Index,
-#endif
 
     (FT_Face_GetKerningFunc)  0,
     (FT_Face_AttachFunc)      0,
     (FT_Face_GetAdvancesFunc) 0,
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
     (FT_CharMap_CharNextFunc) 0
-#else
-    (FT_CharMap_CharNextFunc) 0 /* BDF_Get_Next_Char */
-#endif
   };
 
 
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index c86bbfb..455ad0a 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -41,8 +41,6 @@ THE SOFTWARE.
 #define FT_COMPONENT  trace_pcfread
 
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
   typedef struct  PCF_CMapRec_
   {
     FT_CMapRec    cmap;
@@ -164,77 +162,6 @@ THE SOFTWARE.
     (FT_CMap_CharNextFunc) pcf_cmap_char_next
   };
 
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-  static FT_UInt
-  PCF_Char_Get_Index( FT_CharMap  charmap,
-                      FT_Long     char_code )
-  {
-    PCF_Face      face     = (PCF_Face)charmap->face;
-    PCF_Encoding  en_table = face->encodings;
-    int           low, high, mid;
-
-
-    FT_TRACE4(( "get_char_index %ld\n", char_code ));
-
-    low = 0;
-    high = face->nencodings - 1;
-    while ( low <= high )
-    {
-      mid = ( low + high ) / 2;
-      if ( char_code < en_table[mid].enc )
-        high = mid - 1;
-      else if ( char_code > en_table[mid].enc )
-        low = mid + 1;
-      else
-        return en_table[mid].glyph + 1;
-    }
-
-    return 0;
-  }
-
-
-  static FT_Long
-  PCF_Char_Get_Next( FT_CharMap  charmap,
-                     FT_Long     char_code )
-  {
-    PCF_Face      face     = (PCF_Face)charmap->face;
-    PCF_Encoding  en_table = face->encodings;
-    int           low, high, mid;
-
-
-    FT_TRACE4(( "get_next_char %ld\n", char_code ));
-
-    char_code++;
-    low  = 0;
-    high = face->nencodings - 1;
-
-    while ( low <= high )
-    {
-      mid = ( low + high ) / 2;
-      if ( char_code < en_table[mid].enc )
-        high = mid - 1;
-      else if ( char_code > en_table[mid].enc )
-        low = mid + 1;
-      else
-        return char_code;
-    }
-
-    if ( high < 0 )
-      high = 0;
-
-    while ( high < face->nencodings )
-    {
-      if ( en_table[high].enc >= char_code )
-        return en_table[high].enc;
-      high++;
-    }
-
-    return 0;
-  }
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -321,8 +248,6 @@ THE SOFTWARE.
           unicode_charmap = 1;
       }
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
       {
         FT_CharMapRec  charmap;
 
@@ -345,30 +270,6 @@ THE SOFTWARE.
         if (face->root.num_charmaps)
           face->root.charmap = face->root.charmaps[0];
       }
-
-#else  /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-      /* XXX: charmaps.  For now, report unicode for Unicode and Latin 1 */
-      face->root.charmaps     = &face->charmap_handle;
-      face->root.num_charmaps = 1;
-
-      face->charmap.encoding    = ft_encoding_none;
-      face->charmap.platform_id = 0;
-      face->charmap.encoding_id = 0;
-
-      if ( unicode_charmap )
-      {
-        face->charmap.encoding    = ft_encoding_unicode;
-        face->charmap.platform_id = 3;
-        face->charmap.encoding_id = 1;
-      }
-
-      face->charmap.face   = &face->root;
-      face->charmap_handle = &face->charmap;
-      face->root.charmap   = face->charmap_handle;
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
     }
 
   Exit:
@@ -559,21 +460,13 @@ THE SOFTWARE.
 
     (FT_Slot_LoadFunc)        PCF_Glyph_Load,
 
-#ifndef FT_CONFIG_OPTION_USE_CMAPS
-    (FT_CharMap_CharIndexFunc)PCF_Char_Get_Index,
-#else
     (FT_CharMap_CharIndexFunc)0,
-#endif
 
     (FT_Face_GetKerningFunc)  0,
     (FT_Face_AttachFunc)      0,
     (FT_Face_GetAdvancesFunc) 0,
 
-#ifndef FT_CONFIG_OPTION_USE_CMAPS
-    (FT_CharMap_CharNextFunc) PCF_Char_Get_Next,
-#else
     (FT_CharMap_CharNextFunc) 0
-#endif
   };
 
 
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index 7e90cfc..16211b6 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -283,8 +283,6 @@
     if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
       root->face_flags |= FT_FACE_FLAG_VERTICAL;
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
     {
       if ( psnames && psaux )
       {
@@ -344,79 +342,6 @@
           root->charmap = root->charmaps[0];
       }
     }
-
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-    /* charmap support -- synthetize unicode charmap if possible */
-    {
-      FT_CharMap  charmap = face->charmaprecs;
-
-      
-      /* synthesize a Unicode charmap if there is support in the `PSNames' */
-      /* module                                                            */
-      if ( psnames && psnames->unicode_value )
-      {
-        error = psnames->build_unicodes( root->memory,
-                                         face->type1.num_glyphs,
-                                         (const char**)face->type1.glyph_names,
-                                         &face->unicode_map );
-        if ( !error )
-        {
-          root->charmap        = charmap;
-          charmap->face        = (FT_Face)face;
-          charmap->encoding    = ft_encoding_unicode;
-          charmap->platform_id = 3;
-          charmap->encoding_id = 1;
-          charmap++;
-        }
-        
-        /* XXX: Is the following code correct?  It is used in t1objs.c */
-        
-        /* simply clear the error in case of failure (which really) */
-        /* means that out of memory or no unicode glyph names       */
-        error = T42_Err_Ok;
-      }
-      
-      /* now, support either the standard, expert, or custom encoding */
-      charmap->face        = (FT_Face)face;
-      charmap->platform_id = 7;  /* a new platform id for Adobe fonts? */
-      
-      switch ( face->type1.encoding_type )
-      {
-      case T1_ENCODING_TYPE_STANDARD:
-        charmap->encoding    = ft_encoding_adobe_standard;
-        charmap->encoding_id = 0;
-        break;
-        
-      case T1_ENCODING_TYPE_EXPERT:
-        charmap->encoding    = ft_encoding_adobe_expert;
-        charmap->encoding_id = 1;
-        break;
-        
-      case T1_ENCODING_TYPE_ARRAY:
-        charmap->encoding    = ft_encoding_adobe_custom;
-        charmap->encoding_id = 2;
-        break;
-        
-      case T1_ENCODING_TYPE_ISOLATIN1:
-        charmap->encoding    = ft_encoding_latin_1;
-        charmap->encoding_id = 3;
-        break;
-        
-      default:
-        FT_ERROR(( "T42_Face_Init: invalid encoding\n" ));
-        error = T42_Err_Invalid_File_Format;
-        goto Exit;
-      }
-      
-      root->charmaps     = face->charmaps;
-      root->num_charmaps = charmap - face->charmaprecs + 1;
-      face->charmaps[0]  = &face->charmaprecs[0];
-      face->charmaps[1]  = &face->charmaprecs[1];
-    }
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
   Exit:
     return error;
   }
@@ -718,7 +643,7 @@
 
 
     FT_Activate_Size(size->ttsize);
-    
+
     return FT_Set_Char_Size( t42face->ttf_face,
                              char_width,
                              char_height,
@@ -737,7 +662,7 @@
 
 
     FT_Activate_Size(size->ttsize);
-    
+
     return FT_Set_Pixel_Sizes( t42face->ttf_face,
                                pixel_width,
                                pixel_height );
@@ -807,10 +732,10 @@
       glyph->bitmap      = t42slot->ttslot->bitmap;
       glyph->bitmap_left = t42slot->ttslot->bitmap_left;
       glyph->bitmap_top  = t42slot->ttslot->bitmap_top;
-      
+
       glyph->num_subglyphs = t42slot->ttslot->num_subglyphs;
       glyph->subglyphs     = t42slot->ttslot->subglyphs;
-      
+
       glyph->control_data  = t42slot->ttslot->control_data;
       glyph->control_len   = t42slot->ttslot->control_len;
     }
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index 5344c68..54c0a97 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -310,8 +310,6 @@
   }
 
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
 
   typedef struct  FNT_CMapRec_
   {
@@ -393,57 +391,6 @@
   static FT_CMap_Class  fnt_cmap_class = &fnt_cmap_class_rec;
 
 
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-
-  static FT_UInt
-  FNT_Get_Char_Index( FT_CharMap  charmap,
-                      FT_Long     char_code )
-  {
-    FT_Long  result = char_code;
-
-
-    if ( charmap )
-    {
-      FNT_Font  font  = ((FNT_Face)charmap->face)->fonts;
-      FT_Long   first = font->header.first_char;
-      FT_Long   count = font->header.last_char - first + 1;
-
-
-      char_code -= first;
-      if ( char_code < count )
-        result = char_code + 1;
-      else
-        result = 0;
-    }
-
-    return result;
-  }
-
-
-  static FT_Long
-  FNT_Get_Next_Char( FT_CharMap  charmap,
-                     FT_Long     char_code )
-  {
-    char_code++;
-    if ( charmap )
-    {
-      FNT_Font  font  = ((FNT_Face)charmap->face)->fonts;
-      FT_Long   first = font->header.first_char;
-
-
-      if ( char_code < first )
-        char_code = first;
-      if ( char_code <= font->header.last_char )
-        return char_code;
-    }
-    else
-      return char_code;
-    return 0;
-  }
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
 
   static void
   FNT_Face_Done( FNT_Face  face )
@@ -534,8 +481,6 @@
         }
       }
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-
       {
         FT_CharMapRec  charmap;
 
@@ -556,23 +501,6 @@
           root->charmap = root->charmaps[0];
       }
 
-#else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-      /* Setup the `charmaps' array */
-      root->charmaps     = &face->charmap_handle;
-      root->num_charmaps = 1;
-
-      face->charmap.encoding    = ft_encoding_unicode;
-      face->charmap.platform_id = 3;
-      face->charmap.encoding_id = 1;
-      face->charmap.face        = root;
-
-      face->charmap_handle = &face->charmap;
-
-      root->charmap = face->charmap_handle;
-
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
-
       /* setup remaining flags */
       root->num_glyphs = fonts->header.last_char -
                          fonts->header.first_char + 1;
@@ -754,22 +682,14 @@
     (FT_Size_ResetPixelsFunc) FNT_Size_Set_Pixels,
     (FT_Slot_LoadFunc)        FNT_Load_Glyph,
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
     (FT_CharMap_CharIndexFunc)0,
-#else
-    (FT_CharMap_CharIndexFunc)FNT_Get_Char_Index,
-#endif
-    
+
 
     (FT_Face_GetKerningFunc)  0,
     (FT_Face_AttachFunc)      0,
     (FT_Face_GetAdvancesFunc) 0,
 
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
     (FT_CharMap_CharNextFunc) 0
-#else
-    (FT_CharMap_CharNextFunc) FNT_Get_Next_Char
-#endif    
   };