Commit ed54f28e4ac2ff2ed0016fe8b2d0f5d7b4689ef3

David Turner 2002-03-22T17:09:52

various fixes to the FT_CMaps support

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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 3c13680..a445cc1 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -76,7 +76,7 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
 
-#undef  FT_CONFIG_OPTION_USE_CMAPS
+#define FT_CONFIG_OPTION_USE_CMAPS
 #define TT_CONFIG_CMAP_FORMAT_0
 #define TT_CONFIG_CMAP_FORMAT_2
 #define TT_CONFIG_CMAP_FORMAT_4
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 5d336d8..15becd1 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -127,8 +127,8 @@ FT_BEGIN_HEADER
  /* validator structure */
   typedef struct FT_ValidatorRec_
   {
-    FT_Byte*            base;   /* address of table in memory           */
-    FT_Byte*            limit;  /* 'base' + sizeof(table) in memory     */
+    const FT_Byte*      base;   /* address of table in memory           */
+    const FT_Byte*      limit;  /* 'base' + sizeof(table) in memory     */
     FT_ValidationLevel  level;  /* validation level                     */
     FT_Error            error;  /* error returned. 0 means success      */
 
@@ -136,13 +136,17 @@ FT_BEGIN_HEADER
 
   } FT_ValidatorRec;
 
+#define FT_VALIDATOR(x)  ((FT_Validator)(x))
 
   FT_BASE( void )
   ft_validator_init( FT_Validator        valid,
-                     FT_Byte*            base,
-                     FT_Byte*            limit,
+                     const FT_Byte*      base,
+                     const FT_Byte*      limit,
                      FT_ValidationLevel  level );
 
+  FT_BASE( FT_Int )
+  ft_validator_run( FT_Validator  valid );
+
  /* sets the error field in a validator, then calls 'longjmp' to return */
  /* to high-level caller. Using 'setjmp/longjmp' avoids many stupid     */
  /* error checks within the validation routines..                       */
@@ -450,6 +454,7 @@ FT_BEGIN_HEADER
 #define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
 #define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
 #define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
+#define FT_FACE_STREAM( x )   FT_FACE( x )->stream
 
 #define FT_SIZE_FACE( x )     FT_SIZE( x )->face
 #define FT_SLOT_FACE( x )     FT_SLOT( x )->face
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 7ab8c4a..780b9be 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -26,6 +26,37 @@
 #include FT_OUTLINE_H
 
 #include <string.h>     /* for strcmp() */
+#include <setjmp.h>     /* for setjmp() and longjmp() */
+
+  FT_BASE_DEF( void )
+  ft_validator_init( FT_Validator        valid,
+                     const FT_Byte*      base,
+                     const FT_Byte*      limit,
+                     FT_ValidationLevel  level )
+  {
+    valid->base  = base;
+    valid->limit = limit;
+    valid->level = level;
+    valid->error = 0;
+  }
+                       
+
+  FT_BASE_DEF( FT_Int )
+  ft_validator_run( FT_Validator  valid )
+  {
+    int  result;
+    
+    result = setjmp( valid->jump_buffer );
+    return result;
+  }
+
+  FT_BASE_DEF( void )
+  ft_validator_error( FT_Validator  valid,
+                      FT_Error      error )
+  {
+    valid->error = error;
+    longjmp( valid->jump_buffer, 1 );
+  }                      
 
 
   /*************************************************************************/
@@ -1443,29 +1474,47 @@
 
   /* documentation is in freetype.h */
 
+#ifdef FT_CONFIG_OPTION_USE_CMAPS
+
   FT_EXPORT_DEF( FT_UInt )
   FT_Get_Char_Index( FT_Face   face,
                      FT_ULong  charcode )
   {
-    FT_UInt    result;
-    FT_Driver  driver;
+    FT_UInt  result = 0;
 
 
-    result = 0;
     if ( face && face->charmap )
     {
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
       FT_CMap  cmap = FT_CMAP( face->charmap );
-
+      
       result = cmap->clazz->char_index( cmap, charcode );
+    }
+    return  result;
+  }
+
 #else /* !FT_CONFIG_OPTION_USE_CMAPS */
+
+
+
+  FT_EXPORT_DEF( FT_UInt )
+  FT_Get_Char_Index( FT_Face   face,
+                     FT_ULong  charcode )
+  {
+    FT_UInt    result = 0;
+    FT_Driver  driver;
+
+
+    if ( face && face->charmap )
+    {
       driver = face->driver;
       result = driver->clazz->get_char_index( face->charmap, charcode );
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
     }
     return result;
   }
 
+#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
+
+
   /* documentation is in freetype.h */
 
   FT_EXPORT_DEF( FT_ULong )
@@ -1490,6 +1539,9 @@
 
   /* documentation is in freetype.h */
 
+
+#ifdef FT_CONFIG_OPTION_USE_CMAPS
+
   FT_EXPORT_DEF( FT_ULong )
   FT_Get_Next_Char( FT_Face   face,
                     FT_ULong  charcode,
@@ -1497,17 +1549,37 @@
   {
     FT_ULong   result = 0;
     FT_UInt    gindex = 0;
-    FT_Driver  driver;
 
 
     if ( face && face->charmap )
     {
-#ifdef FT_CONFIG_OPTION_USE_CMAPS
-      FT_CMap  cmap = FT_CMAP( face->charmap );
+      FT_UInt32  code = (FT_UInt32)charcode;
+      FT_CMap    cmap = FT_CMAP( face->charmap );
+
+      gindex = cmap->clazz->char_next( cmap, &code );
+      result = ( gindex == 0 ) ? 0 : code;
+    }
+
+    if ( agindex )
+      *agindex = gindex;
+
+    return result;
+  }
 
-      gindex = cmap->clazz->char_next( cmap, &charcode );
-      result = ( gindex == 0 ) ? 0 : charcode;
 #else /* !FT_CONFIG_OPTION_USE_CMAPS */
+
+  FT_EXPORT_DEF( FT_ULong )
+  FT_Get_Next_Char( FT_Face   face,
+                    FT_ULong  charcode,
+                    FT_UInt  *agindex )
+  {
+    FT_ULong   result = 0;
+    FT_UInt    gindex = 0;
+    FT_Driver  driver;
+
+
+    if ( face && face->charmap )
+    {
       driver = face->driver;
       result = driver->clazz->get_next_char( face->charmap, charcode );
       if ( result != 0 )
@@ -1516,7 +1588,6 @@
         if ( gindex == 0 )
           result = 0;
       }
-#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
     }
 
     if ( agindex )
@@ -1525,6 +1596,8 @@
     return result;
   }
 
+#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
+
 
   /* documentation is in freetype.h */
 
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 84a7c50..067c43d 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -249,56 +249,6 @@
 
 
 
-
-  static FT_Encoding
-  find_encoding( int  platform_id,
-                 int  encoding_id )
-  {
-    typedef struct  TEncoding
-    {
-      int          platform_id;
-      int          encoding_id;
-      FT_Encoding  encoding;
-
-    } TEncoding;
-
-    static
-    const TEncoding  tt_encodings[] =
-    {
-      { TT_PLATFORM_ISO,           -1,                  ft_encoding_unicode },
-
-      { TT_PLATFORM_APPLE_UNICODE, -1,                  ft_encoding_unicode },
-
-      { TT_PLATFORM_MACINTOSH,     TT_MAC_ID_ROMAN,     ft_encoding_apple_roman },
-
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SJIS,       ft_encoding_sjis },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_GB2312,     ft_encoding_gb2312 },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_BIG_5,      ft_encoding_big5 },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_WANSUNG,    ft_encoding_wansung },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_JOHAB,      ft_encoding_johab }
-    };
-
-    const TEncoding  *cur, *limit;
-
-
-    cur   = tt_encodings;
-    limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
-
-    for ( ; cur < limit; cur++ )
-    {
-      if ( cur->platform_id == platform_id )
-      {
-        if ( cur->encoding_id == encoding_id ||
-             cur->encoding_id == -1          )
-          return cur->encoding;
-      }
-    }
-
-    return ft_encoding_none;
-  }
-
-
   FT_LOCAL_DEF( FT_Error )
   CFF_Face_Init( FT_Stream      stream,
                  CFF_Face       face,
@@ -498,48 +448,8 @@
           flags |= FT_STYLE_FLAG_BOLD;
 
         root->style_flags = flags;
-
-        /* set the charmaps if any */
-        if ( sfnt_format )
-        {
-          /*****************************************************************/
-          /*                                                               */
-          /* Polish the charmaps.                                          */
-          /*                                                               */
-          /*   Try to set the charmap encoding according to the platform & */
-          /*   encoding ID of each charmap.                                */
-          /*                                                               */
-          TT_CharMap  charmap;
-          FT_Int      n;
-
-
-          charmap            = face->charmaps;
-          root->num_charmaps = face->num_charmaps;
-
-          /* allocate table of pointers */
-          if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) )
-            goto Exit;
-
-          for ( n = 0; n < root->num_charmaps; n++, charmap++ )
-          {
-            FT_Int  platform = charmap->cmap.platformID;
-            FT_Int  encoding = charmap->cmap.platformEncodingID;
-
-
-            charmap->root.face        = (FT_Face)face;
-            charmap->root.platform_id = (FT_UShort)platform;
-            charmap->root.encoding_id = (FT_UShort)encoding;
-            charmap->root.encoding    = find_encoding( platform, encoding );
-
-            /* now, set root->charmap with a unicode charmap */
-            /* wherever available                            */
-            if ( !root->charmap                                &&
-                 charmap->root.encoding == ft_encoding_unicode )
-              root->charmap = (FT_CharMap)charmap;
-
-            root->charmaps[n] = (FT_CharMap)charmap;
-          }
-        }
+        
+        /* XXX: no charmaps for pure CFF fonts for now !! */
       }
     }
 
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index a671d83..97590ca 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -72,10 +72,10 @@ THE SOFTWARE.
                  
 
   FT_CALLBACK_DEF( FT_UInt )
-  pcf_cmap_char_index( FT_CMap    cmap,
+  pcf_cmap_char_index( PCF_CMap   cmap,
                        FT_UInt32  charcode )
   {
-    PCF_Encoding  encoding = cmap->encodings;
+    PCF_Encoding  encodings = cmap->encodings;
     FT_UInt       min, max, mid;
     FT_UInt       result = 0;
     
@@ -140,7 +140,7 @@ THE SOFTWARE.
     if ( ++min < cmap->num_encodings )
     {
       charcode = encodings[min].enc;
-      glyph    = encodings[min].glyph;
+      result   = encodings[min].glyph;
     }
     
   Exit:
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 1963b36..25030af 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -19,6 +19,7 @@
 #include <ft2build.h>
 #include "sfobjs.h"
 #include "ttload.h"
+#include "ttcmap0.h"
 #include FT_INTERNAL_SFNT_H
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_TRUETYPE_IDS_H
@@ -384,7 +385,6 @@
     {
       FT_Face     root = &face->root;
       FT_Int      flags = 0;
-      TT_CharMap  charmap;
       FT_Int      n;
       FT_Memory   memory;
 
@@ -456,12 +456,12 @@
       /*                                                                   */
 #ifdef FT_CONFIG_OPTION_USE_CMAPS
 
-      error = TT_Build_CMaps( face );
-      if (error) goto Exit;
+      TT_Build_CMaps( face );  /* ignore errors */
+      
       
       /* set the encoding fields */
       {
-        FT_UInt  n;
+        FT_Int  n;
         
         for ( n = 0; n < root->num_charmaps; n++ )
         {
@@ -480,32 +480,36 @@
       }
 
 #else /* !FT_CONFIG_OPTION_USE_CMAPS */
-
-      charmap            = face->charmaps;
-      root->num_charmaps = face->num_charmaps;
-
-      /* allocate table of pointers */
-      if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) )
-        goto Exit;
-
-      for ( n = 0; n < root->num_charmaps; n++, charmap++ )
+      
       {
-        FT_Int  platform = charmap->cmap.platformID;
-        FT_Int  encoding = charmap->cmap.platformEncodingID;
-
-
-        charmap->root.face        = (FT_Face)face;
-        charmap->root.platform_id = (FT_UShort)platform;
-        charmap->root.encoding_id = (FT_UShort)encoding;
-        charmap->root.encoding    = sfnt_find_encoding( platform, encoding );
-
-        /* now, set root->charmap with a unicode charmap */
-        /* wherever available                            */
-        if ( !root->charmap                                &&
-             charmap->root.encoding == ft_encoding_unicode )
-          root->charmap = (FT_CharMap)charmap;
-
-        root->charmaps[n] = (FT_CharMap)charmap;
+        TT_CharMap  charmap = face->charmaps;
+        
+        charmap            = face->charmaps;
+        root->num_charmaps = face->num_charmaps;
+  
+        /* allocate table of pointers */
+        if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) )
+          goto Exit;
+  
+        for ( n = 0; n < root->num_charmaps; n++, charmap++ )
+        {
+          FT_Int  platform = charmap->cmap.platformID;
+          FT_Int  encoding = charmap->cmap.platformEncodingID;
+  
+  
+          charmap->root.face        = (FT_Face)face;
+          charmap->root.platform_id = (FT_UShort)platform;
+          charmap->root.encoding_id = (FT_UShort)encoding;
+          charmap->root.encoding    = sfnt_find_encoding( platform, encoding );
+  
+          /* now, set root->charmap with a unicode charmap */
+          /* wherever available                            */
+          if ( !root->charmap                                &&
+               charmap->root.encoding == ft_encoding_unicode )
+            root->charmap = (FT_CharMap)charmap;
+  
+          root->charmaps[n] = (FT_CharMap)charmap;
+        }
       }
 
 #endif /* !FT_CONFIG_OPTION_USE_CMAPS */
diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c
index 609e9dd..f0aa965 100644
--- a/src/sfnt/ttcmap0.c
+++ b/src/sfnt/ttcmap0.c
@@ -1549,15 +1549,12 @@
   FT_LOCAL_DEF( FT_Error )
   TT_Build_CMaps( TT_Face   face )
   {
-    TT_CMap_Class    clazz;
-    FT_ValidatorRec  valid;
     FT_UInt          num_cmaps;
     FT_Byte*         table = face->cmap_table;
     FT_Byte*         limit = table + face->cmap_size;
     FT_Byte*         p     = table;
-    FT_UInt          format;
 
-    if ( p + 4 < limit )
+    if ( p + 4 > limit )
       return FT_Err_Invalid_Table;
 
     /* only recognize format 0 */
@@ -1582,29 +1579,31 @@
 
       if ( offset && table + offset + 2 < limit )
       {
-        FT_Byte*         cmap   = table + offset;
-        FT_UInt          format = TT_PEEK_USHORT(cmap);
-        TT_CMap_Class*   pclazz = tt_cmap_classes;
-        TT_CMap_Class    clazz;
+        FT_Byte*              cmap   = table + offset;
+        FT_UInt               format = TT_PEEK_USHORT(cmap);
+        const TT_CMap_Class*  pclazz = tt_cmap_classes;
+        TT_CMap_Class         clazz;
 
         for ( ; *pclazz; pclazz++ )
         {
           clazz = *pclazz;
           if ( clazz->format == format )
           {
-            volatile TT_Validator  valid;
-
+            volatile TT_ValidatorRec  valid;
+            
+            ft_validator_init( FT_VALIDATOR(&valid), cmap, limit,
+                               FT_VALIDATE_DEFAULT );
+                               
             valid.num_glyphs = face->root.num_glyphs;
 
-            if ( ft_validator_init( FT_VALIDATOR(&valid), cmap, limit,
-                                    FT_VALIDATE_LEVEL_DEFAULT ) == 0 )
+            if ( setjmp( FT_VALIDATOR(&valid)->jump_buffer ) == 0 )
             {
               /* validate this cmap sub-table */
               clazz->validate( cmap, FT_VALIDATOR(&valid) );
             }
 
-            if ( valid.error == 0 )
-              (void)FT_CMap_New( clazz, cmap, face, NULL );
+            if ( valid.validator.error == 0 )
+              (void)FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, NULL );
             else
               FT_ERROR(( "%s: broken cmap sub-table ignored !!\n",
                          "TT_Build_CMaps" ));
diff --git a/src/sfnt/ttcmap0.h b/src/sfnt/ttcmap0.h
index ccd55ba..7713885 100644
--- a/src/sfnt/ttcmap0.h
+++ b/src/sfnt/ttcmap0.h
@@ -49,8 +49,8 @@ FT_BEGIN_HEADER
 
   typedef struct TT_ValidatorRec_
   {
-    FT_Validator   validator;
-    FT_UInt        num_glyphs;
+    FT_ValidatorRec  validator;
+    FT_UInt          num_glyphs;
     
   } TT_ValidatorRec, *TT_Validator;
 
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 469a176..c8ac9c0 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -1128,9 +1128,6 @@
                 FT_Stream  stream )
   {
     FT_Error       error;
-    FT_Memory      memory = stream->memory;
-    FT_Long        table_start;
-    TT_CMapDirRec  cmap_dir;
 
     error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
     if ( error )
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 26a7a12..68087f5 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -436,7 +436,7 @@
       if ( psnames && psaux )
       {
         FT_CharMapRec    charmap;
-        FT_CMap_Classes  cmap_classes = psaux->cmap_classes;
+        T1_CMap_Classes  cmap_classes = psaux->t1_cmap_classes;
         FT_CMap_Class    clazz;
         
         charmap.face = root;
@@ -446,7 +446,7 @@
         charmap.encoding_id = 1;
         charmap.encoding    = ft_encoding_unicode;
         
-        FT_CMap_New( root, cmap_classes->unicode, &charmap, NULL );
+        FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
         
         /* now, generate an Adobe Standard encoding when appropriate */
         charmap.platform_id = 7;
@@ -473,9 +473,9 @@
             break;
             
           case T1_ENCODING_TYPE_ISOLATIN1:
-            charmap.encoding    = ft_encoding_adobe_latin_1;
+            charmap.encoding    = ft_encoding_latin_1;
             charmap.encoding_id = 3;
-            clazz               = cmap_classes->latin_1;
+            clazz               = cmap_classes->unicode;
             break;
             
           default:
@@ -483,7 +483,7 @@
         }
         
         if ( clazz )
-          FT_CMap_New( root, clazz, &charmap, NULL );
+          FT_CMap_New( clazz, NULL, &charmap, NULL );
       }
     }
 
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index e5f8464..eb9dbf3 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -323,7 +323,7 @@
 
 
   static FT_Error
-  fnt_cmap_init( FT_CMap  cmap )
+  fnt_cmap_init( FNT_CMap  cmap )
   {
     FNT_Face  face = (FNT_Face) FT_CMAP_FACE(cmap);
     FNT_Font  font = face->fonts;
@@ -336,7 +336,7 @@
 
 
   static FT_UInt
-  fnt_cmap_char_index( FT_CMap    cmap,
+  fnt_cmap_char_index( FNT_CMap   cmap,
                        FT_UInt32  char_code )
   {
     FT_UInt  gindex = 0;
@@ -350,7 +350,7 @@
 
 
   static FT_UInt
-  fnt_cmap_char_next( FT_CMap    cmap,
+  fnt_cmap_char_next( FNT_CMap   cmap,
                       FT_UInt32 *pchar_code )
   {
     FT_UInt    gindex = 0;
@@ -734,20 +734,29 @@
     (FT_Face_DoneFunc)     FNT_Face_Done,
     (FT_Size_InitFunc)     0,
     (FT_Size_DoneFunc)     0,
-    (FT_Slot_InitFunc)0,
-    (FT_Slot_DoneFunc)0,
+    (FT_Slot_InitFunc)     0,
+    (FT_Slot_DoneFunc)     0,
 
     (FT_Size_ResetPointsFunc) FNT_Size_Set_Pixels,
     (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    
   };