Commit 8ab0979d6e2d29fe5d489d55ff4adc6a55744308

Werner Lemberg 2006-01-12T08:12:27

Prepare use of pscmap service within CFF module. * include/freetype/internal/services/svpscmap.h: Include FT_INTERNAL_OBJECTS_H. (PS_Unicode_Index_Func): Removed. Unused. (PS_Macintosh_Name_Func): Renamed to... (PS_Macintosh_NameFunc): This. Update all callers. (PS_Adobe_Std_Strings_Func): Renamed to... (PS_Adobe_Std_StringsFunc): This. Update all callers. (PS_UnicodesRec): This is the former `PS_Unicodes' structure. Add `cmap' member. Update all callers. (PS_Unicodes): This is now a typedef'd pointer to PS_UnicodesRec. Update all callers. (PS_Glyph_NameFunc): New typedef. (PS_Unicodes_InitFunc): Change arguments to expect a function and generic data pointer which returns a glyph name from a given index. * src/psnames/psmodule.c (ps_unicodes_init, ps_unicodes_char_index, ps_unicodes_char_next, pscmaps_interface): Updated. * include/freetype/internal/t1types.h (T1_FaceRec): Updated. * src/psaux/t1cmap.h (T1_CmapStdRec): Updated. (T1_CmapUnicode, T1_CmapUnicodeRec): Removed. * src/psaux/t1cmap.c (t1_get_glyph_name): New callback function. (t1_cmap_unicode_init, t1_cmap_unicode_done, t1_cmap_unicode_char_index, t1_cmap_unicode_char_next, t1_cmap_unicode_class_rec): Updated. * src/type42/t42types.h (T42_FaceRec): Updated.

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
diff --git a/ChangeLog b/ChangeLog
index 9ba19a8..54dc6cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,48 @@
-2006-01-12  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+2006-01-12  Werner Lemberg  <wl@gnu.org>
+
+	Prepare use of pscmap service within CFF module.
+
+	* include/freetype/internal/services/svpscmap.h: Include
+	FT_INTERNAL_OBJECTS_H.
+	(PS_Unicode_Index_Func): Removed.  Unused.
+	(PS_Macintosh_Name_Func): Renamed to...
+	(PS_Macintosh_NameFunc): This.
+	Update all callers.
+	(PS_Adobe_Std_Strings_Func): Renamed to...
+	(PS_Adobe_Std_StringsFunc): This.
+	Update all callers.
+	(PS_UnicodesRec): This is the former `PS_Unicodes' structure.
+	Add `cmap' member.
+	Update all callers.
+	(PS_Unicodes): This is now a typedef'd pointer to PS_UnicodesRec.
+	Update all callers.
+	(PS_Glyph_NameFunc): New typedef.
+	(PS_Unicodes_InitFunc): Change arguments to expect a function
+	and generic data pointer which returns a glyph name from a given
+	index.
+
+	* src/psnames/psmodule.c (ps_unicodes_init, ps_unicodes_char_index,
+	ps_unicodes_char_next, pscmaps_interface): Updated.
+
+	* include/freetype/internal/t1types.h (T1_FaceRec): Updated.
+
+	* src/psaux/t1cmap.h (T1_CmapStdRec): Updated.
+	(T1_CmapUnicode, T1_CmapUnicodeRec): Removed.
+
+	* src/psaux/t1cmap.c (t1_get_glyph_name): New callback function.
+	(t1_cmap_unicode_init, t1_cmap_unicode_done,
+	t1_cmap_unicode_char_index, t1_cmap_unicode_char_next,
+	t1_cmap_unicode_class_rec): Updated.
+
+	* src/type42/t42types.h (T42_FaceRec): Updated.
+
+2006-01-11  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	* include/freetype/ftmac.h: Add declaration of new functions
 	FT_New_Face_From_FSRef and FT_GetFile_From_Mac_ATS_Name that
 	were introduced by the jumbo patch on  2006-01-11.
 
-2006-01-10  Werner Lemberg  <wl@gnu.org>
+2006-01-11  Werner Lemberg  <wl@gnu.org>
 
 	Fix Savannah bug #15056 and use pscmap service in psaux module.
 
diff --git a/include/freetype/internal/services/svpscmap.h b/include/freetype/internal/services/svpscmap.h
index 74d57f9..8f418a8 100644
--- a/include/freetype/internal/services/svpscmap.h
+++ b/include/freetype/internal/services/svpscmap.h
@@ -19,6 +19,8 @@
 #ifndef __SVPSCMAP_H__
 #define __SVPSCMAP_H__
 
+#include FT_INTERNAL_OBJECTS_H
+
 
 FT_BEGIN_HEADER
 
@@ -33,24 +35,17 @@ FT_BEGIN_HEADER
   (*PS_Unicode_ValueFunc)( const char*  glyph_name );
 
   /*
-   *  Unicode value to Adobe glyph name index.  0xFFFF if not found.
-   */
-  typedef FT_UInt
-  (*PS_Unicode_Index_Func)( FT_UInt       num_glyphs,
-                            const char**  glyph_names,
-                            FT_ULong      unicode );
-
-  /*
    *  Macintosh name id to glyph name.  NULL if invalid index.
    */
   typedef const char*
-  (*PS_Macintosh_Name_Func)( FT_UInt  name_index );
+  (*PS_Macintosh_NameFunc)( FT_UInt  name_index );
 
   /*
    *  Adobe standard string ID to glyph name.  NULL if invalid index.
    */
   typedef const char*
-  (*PS_Adobe_Std_Strings_Func)( FT_UInt  string_index );
+  (*PS_Adobe_Std_StringsFunc)( FT_UInt  string_index );
+
 
   /*
    *  Simple unicode -> glyph index charmap built from font glyph names
@@ -64,27 +59,39 @@ FT_BEGIN_HEADER
   } PS_UniMap;
 
 
-  typedef struct  PS_Unicodes_
+  typedef struct PS_UnicodesRec_*  PS_Unicodes;
+
+  typedef struct  PS_UnicodesRec_
   {
+    FT_CMapRec  cmap;
     FT_UInt     num_maps;
     PS_UniMap*  maps;
 
-  } PS_Unicodes;
+  } PS_UnicodesRec;
+
 
+  /*
+   *  A function which returns a glyph name for a given index.  Returns
+   *  NULL if invalid index.
+   */
+  typedef const char*
+  (*PS_Glyph_NameFunc)( FT_Pointer  data,
+                        FT_UInt     string_index );
 
   typedef FT_Error
-  (*PS_Unicodes_InitFunc)( FT_Memory     memory,
-                           FT_UInt       num_glyphs,
-                           FT_String**   glyph_names,
-                           PS_Unicodes*  unicodes );
+  (*PS_Unicodes_InitFunc)( FT_Memory          memory,
+                           PS_Unicodes        unicodes,
+                           FT_UInt            num_glyphs,
+                           PS_Glyph_NameFunc  get_glyph_name,
+                           FT_Pointer         glyph_data );
 
   typedef FT_UInt
-  (*PS_Unicodes_CharIndexFunc)( PS_Unicodes*  unicodes,
-                                FT_UInt32     unicode );
+  (*PS_Unicodes_CharIndexFunc)( PS_Unicodes  unicodes,
+                                FT_UInt32    unicode );
 
   typedef FT_ULong
-  (*PS_Unicodes_CharNextFunc)( PS_Unicodes*  unicodes,
-                               FT_UInt32    *unicode );
+  (*PS_Unicodes_CharNextFunc)( PS_Unicodes  unicodes,
+                               FT_UInt32   *unicode );
 
 
   FT_DEFINE_SERVICE( PsCMaps )
@@ -95,8 +102,8 @@ FT_BEGIN_HEADER
     PS_Unicodes_CharIndexFunc  unicodes_char_index;
     PS_Unicodes_CharNextFunc   unicodes_char_next;
 
-    PS_Macintosh_Name_Func     macintosh_name;
-    PS_Adobe_Std_Strings_Func  adobe_std_strings;
+    PS_Macintosh_NameFunc      macintosh_name;
+    PS_Adobe_Std_StringsFunc   adobe_std_strings;
     const unsigned short*      adobe_std_encoding;
     const unsigned short*      adobe_expert_encoding;
   };
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index 702bb1e..75f737b 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -5,7 +5,7 @@
 /*    Basic Type1/Type2 type definitions and interface (specification      */
 /*    only).                                                               */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004 by                               */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2006 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -148,20 +148,20 @@ FT_BEGIN_HEADER
 
   typedef struct  T1_FaceRec_
   {
-    FT_FaceRec     root;
-    T1_FontRec     type1;
-    const void*    psnames;
-    const void*    psaux;
-    const void*    afm_data;
-    FT_CharMapRec  charmaprecs[2];
-    FT_CharMap     charmaps[2];
-    PS_Unicodes    unicode_map;
+    FT_FaceRec      root;
+    T1_FontRec      type1;
+    const void*     psnames;
+    const void*     psaux;
+    const void*     afm_data;
+    FT_CharMapRec   charmaprecs[2];
+    FT_CharMap      charmaps[2];
+    PS_UnicodesRec  unicode_map;
 
     /* support for Multiple Masters fonts */
-    PS_Blend       blend;
+    PS_Blend        blend;
 
     /* since FT 2.1 - interface to PostScript hinter */
-    const void*    pshinter;
+    const void*     pshinter;
 
   } T1_FaceRec;
 
diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c
index a0e25e2..98816f2 100644
--- a/src/psaux/t1cmap.c
+++ b/src/psaux/t1cmap.c
@@ -257,61 +257,70 @@
   /*************************************************************************/
   /*************************************************************************/
 
+  const char *
+  t1_get_glyph_name( T1_Face  face,
+                     FT_UInt  idx )
+  {
+    return face->type1.glyph_names[idx];
+  }
+
+
   FT_CALLBACK_DEF( FT_Error )
-  t1_cmap_unicode_init( T1_CMapUnicode  cmap )
+  t1_cmap_unicode_init( PS_Unicodes  unicodes )
   {
-    T1_Face             face    = (T1_Face)FT_CMAP_FACE( cmap );
+    T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
     FT_Memory           memory  = FT_FACE_MEMORY( face );
     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
 
 
     return psnames->unicodes_init( memory,
+                                   unicodes,
                                    face->type1.num_glyphs,
-                                   face->type1.glyph_names,
-                                   &cmap->unicodes );
+                                   (PS_Glyph_NameFunc)&t1_get_glyph_name,
+                                   (FT_Pointer)face );
   }
 
 
   FT_CALLBACK_DEF( void )
-  t1_cmap_unicode_done( T1_CMapUnicode  cmap )
+  t1_cmap_unicode_done( PS_Unicodes  unicodes )
   {
-    FT_Face    face   = FT_CMAP_FACE( cmap );
+    FT_Face    face   = FT_CMAP_FACE( unicodes );
     FT_Memory  memory = FT_FACE_MEMORY( face );
 
 
-    FT_FREE( cmap->unicodes.maps );
-    cmap->unicodes.num_maps = 0;
+    FT_FREE( unicodes->maps );
+    unicodes->num_maps = 0;
   }
 
 
   FT_CALLBACK_DEF( FT_UInt )
-  t1_cmap_unicode_char_index( T1_CMapUnicode  cmap,
-                              FT_UInt32       char_code )
+  t1_cmap_unicode_char_index( PS_Unicodes  unicodes,
+                              FT_UInt32    char_code )
   {
-    T1_Face             face    = (T1_Face)FT_CMAP_FACE( cmap );
+    T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
 
 
-    return psnames->unicodes_char_index( &cmap->unicodes, char_code );
+    return psnames->unicodes_char_index( unicodes, char_code );
   }
 
 
   FT_CALLBACK_DEF( FT_UInt )
-  t1_cmap_unicode_char_next( T1_CMapUnicode  cmap,
-                             FT_UInt32      *pchar_code )
+  t1_cmap_unicode_char_next( PS_Unicodes  unicodes,
+                             FT_UInt32   *pchar_code )
   {
-    T1_Face             face    = (T1_Face)FT_CMAP_FACE( cmap );
+    T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
 
 
-    return psnames->unicodes_char_next( &cmap->unicodes, pchar_code );
+    return psnames->unicodes_char_next( unicodes, pchar_code );
   }
 
 
   FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
   t1_cmap_unicode_class_rec =
   {
-    sizeof ( T1_CMapUnicodeRec ),
+    sizeof ( PS_UnicodesRec ),
 
     (FT_CMap_InitFunc)     t1_cmap_unicode_init,
     (FT_CMap_DoneFunc)     t1_cmap_unicode_done,
diff --git a/src/psaux/t1cmap.h b/src/psaux/t1cmap.h
index 5382efc..7ae65d2 100644
--- a/src/psaux/t1cmap.h
+++ b/src/psaux/t1cmap.h
@@ -39,13 +39,13 @@ FT_BEGIN_HEADER
 
   typedef struct  T1_CMapStdRec_
   {
-    FT_CMapRec                 cmap;
+    FT_CMapRec                cmap;
 
-    const FT_UShort*           code_to_sid;
-    PS_Adobe_Std_Strings_Func  sid_to_string;
+    const FT_UShort*          code_to_sid;
+    PS_Adobe_Std_StringsFunc  sid_to_string;
 
-    FT_UInt                    num_glyphs;
-    const char* const*         glyph_names;
+    FT_UInt                   num_glyphs;
+    const char* const*        glyph_names;
 
   } T1_CMapStdRec;
 
@@ -90,15 +90,6 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
   /* unicode (synthetic) cmaps */
-  typedef struct T1_CMapUnicodeRec_*  T1_CMapUnicode;
-
-  typedef struct  T1_CMapUnicodeRec_
-  {
-    FT_CMapRec   cmap;
-    PS_Unicodes  unicodes;
-
-  } T1_CMapUnicodeRec;
-
 
   FT_CALLBACK_TABLE const FT_CMap_ClassRec
   t1_cmap_unicode_class_rec;
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index db8b25f..144a991 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -182,10 +182,11 @@
 
   /* Build a table that maps Unicode values to glyph indices. */
   static FT_Error
-  ps_unicodes_init( FT_Memory     memory,
-                    FT_UInt       num_glyphs,
-                    FT_String**   glyph_names,
-                    PS_Unicodes*  table )
+  ps_unicodes_init( FT_Memory          memory,
+                    PS_Unicodes        table,
+                    FT_UInt            num_glyphs,
+                    PS_Glyph_NameFunc  get_glyph_name,
+                    FT_Pointer         glyph_data )
   {
     FT_Error  error;
 
@@ -206,7 +207,7 @@
 
       for ( n = 0; n < num_glyphs; n++ )
       {
-        const char*  gname = glyph_names[n];
+        const char*  gname = get_glyph_name( glyph_data, n );
 
 
         if ( gname )
@@ -253,8 +254,8 @@
 
 
   static FT_UInt
-  ps_unicodes_char_index( PS_Unicodes*  table,
-                          FT_UInt32     unicode )
+  ps_unicodes_char_index( PS_Unicodes  table,
+                          FT_UInt32    unicode )
   {
     PS_UniMap  *min, *max, *mid, *result = NULL;
 
@@ -299,8 +300,8 @@
 
 
   static FT_ULong
-  ps_unicodes_char_next( PS_Unicodes*  table,
-                         FT_UInt32    *unicode )
+  ps_unicodes_char_next( PS_Unicodes  table,
+                         FT_UInt32   *unicode )
   {
     FT_UInt    result    = 0;
     FT_UInt32  char_code = *unicode + 1;
@@ -398,8 +399,8 @@
 
 #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
 
-    (PS_Macintosh_Name_Func)   ps_get_macintosh_name,
-    (PS_Adobe_Std_Strings_Func)ps_get_standard_strings,
+    (PS_Macintosh_NameFunc)    ps_get_macintosh_name,
+    (PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
 
     t1_standard_encoding,
     t1_expert_encoding
diff --git a/src/type42/t42types.h b/src/type42/t42types.h
index d44ac4e..6626b04 100644
--- a/src/type42/t42types.h
+++ b/src/type42/t42types.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Type 42 font data types (specification only).                        */
 /*                                                                         */
-/*  Copyright 2002, 2003 by Roberto Alameda.                               */
+/*  Copyright 2002, 2003, 2006 by Roberto Alameda.                         */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 /*  modified, and distributed under the terms of the FreeType project      */
@@ -31,17 +31,17 @@ FT_BEGIN_HEADER
 
   typedef struct  T42_FaceRec_
   {
-    FT_FaceRec     root;
-    T1_FontRec     type1;
-    const void*    psnames;
-    const void*    psaux;
-    const void*    afm_data;
-    FT_Byte*       ttf_data;
-    FT_ULong       ttf_size;
-    FT_Face        ttf_face;
-    FT_CharMapRec  charmaprecs[2];
-    FT_CharMap     charmaps[2];
-    PS_Unicodes    unicode_map;
+    FT_FaceRec      root;
+    T1_FontRec      type1;
+    const void*     psnames;
+    const void*     psaux;
+    const void*     afm_data;
+    FT_Byte*        ttf_data;
+    FT_ULong        ttf_size;
+    FT_Face         ttf_face;
+    FT_CharMapRec   charmaprecs[2];
+    FT_CharMap      charmaps[2];
+    PS_UnicodesRec  unicode_map;
 
   } T42_FaceRec, *T42_Face;