Commit f95a603117672c12ff4a00e680519db17b21cf7b

David Turner 2000-08-21T04:58:49

minor updates to the "psaux" module. Werner, please do not start re-formatting my experimental code until I declare it "finished", because I still make big changes to it that create lots of CVS conflicts.. thanks for your work, anyway :-)

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
diff --git a/Makefile b/Makefile
index 4834fd4..f995853 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
 # It works as follows:
 #
 # - When invoked for the first time, this Makefile will include the rules
-#   found in `freetype/config/detect.mk'.  They are in charge of detecting
+#   found in `freetype/builds/detect.mk'.  They are in charge of detecting
 #   the current platform.
 #
 #   A summary of the detection will be displayed, and the file `config.mk'
@@ -27,7 +27,7 @@
 # - When invoked later, this Makefile will include the rules found in
 #   `config.mk'.  This sub-Makefile will define some system-specific
 #   variables (like compiler, compilation flags, object suffix, etc.), then
-#   include the rules found in `freetype/config/freetype.mk', used to build
+#   include the rules found in `freetype/builds/freetype.mk', used to build
 #   the library.
 #
 # See the comments in `config/detect.mk' and `config/freetype.mk' for more
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index 50cc46b..8a9ea0a 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -1,6 +1,7 @@
 FT_USE_MODULE(autohint_module_class)
 FT_USE_MODULE(cff_driver_class)
 FT_USE_MODULE(t1cid_driver_class)
+FT_USE_MODULE(psaux_module_class)
 FT_USE_MODULE(psnames_module_class)
 FT_USE_MODULE(ft_raster1_renderer_class)
 FT_USE_MODULE(sfnt_module_class)
diff --git a/include/freetype/ftglyph.h b/include/freetype/ftglyph.h
index 0647c88..cd1b3d3 100644
--- a/include/freetype/ftglyph.h
+++ b/include/freetype/ftglyph.h
@@ -218,9 +218,10 @@
 
   enum
   {
-    ft_glyph_bbox_pixels    = 0,
-    ft_glyph_bbox_subpixels = 1,
-    ft_glyph_bbox_gridfit   = 2
+    ft_glyph_bbox_subpixels = 0, /* return unfitted coordinates in 26.6 pixels */
+    ft_glyph_bbox_gridfit   = 1, /* return grid-fitted coordinates             */
+    ft_glyph_bbox_truncate  = 2, /* return coordinates in integer pixels       */
+    ft_glyph_bbox_pixels    = 3  /* return grid-fitted pixel coordinates       */
   };
 
 
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 5eaeada..1e70f0f 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -41,10 +41,10 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Struct>                                                              */
-  /*    T1_Table                                                           */
+  /*    PS_Table                                                           */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    A T1_Table is a simple object used to store an array of objects in */
+  /*    A PS_Table is a simple object used to store an array of objects in */
   /*    a single memory block.                                             */
   /*                                                                       */
   /* <Fields>                                                              */
@@ -68,7 +68,7 @@
   /*    memory    :: The object used for memory operations                 */
   /*                 (alloc/realloc).                                      */
   /*                                                                       */
-  typedef struct  T1_Table_
+  typedef struct  PS_Table_
   {
     FT_Byte*   block;          /* current memory block           */
     FT_Int     cursor;         /* current cursor in memory block */
@@ -82,17 +82,17 @@
 
     FT_Memory  memory;
 
-  } T1_Table;
+  } PS_Table;
 
 
 
   /*************************************************************************/
   /*                                                                       */
   /* <Struct>                                                              */
-  /*    T1_Table_Funcs                                                     */
+  /*    PS_Table_Funcs                                                     */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    A set of function pointers used to manage T1_Table objects..       */
+  /*    A set of function pointers used to manage PS_Table objects..       */
   /*                                                                       */
   /* <Fields>                                                              */
   /*    table_init    :: used to initialise a a table                      */
@@ -100,22 +100,22 @@
   /*    table_add     :: add one new object to a table                     */
   /*    table_release :: release table data, then finalize it              */
   /*                                                                       */
-  typedef  struct T1_Table_Funcs_
+  typedef  struct PS_Table_Funcs_
   {
-    FT_Error   (*init)   ( T1_Table*   table,
+    FT_Error   (*init)   ( PS_Table*   table,
                            FT_Int     count,
                            FT_Memory  memory );
   
-    void       (*done)   ( T1_Table*  table );                              
+    void       (*done)   ( PS_Table*  table );                              
   
-    FT_Error   (*add)    ( T1_Table*   table,
+    FT_Error   (*add)    ( PS_Table*   table,
                            FT_Int      index,
                            void*       object,
                            FT_Int      length );
 
-    void       (*release)( T1_Table*  table );                              
+    void       (*release)( PS_Table*  table );                              
   
-  } T1_Table_Funcs;
+  } PS_Table_Funcs;
 
 
   /*************************************************************************/
@@ -395,7 +395,7 @@
   /*                    the metrics of a given glyph, not load all of its  */
   /*                    points.                                            */
   /*                                                                       */
-  typedef struct  T2_Builder_
+  typedef struct  T1_Builder_
   {
     FT_Memory        memory;
     FT_Face          face;
@@ -426,30 +426,30 @@
   } T1_Builder;
 
 
-  typedef FT_Error  (*T1_Builder_Check_Points_Func)( T1_Builder*  builder,
-                                                     FT_Int       count );
+  typedef FT_Error  (*T1_Builder_Check_Points_Func) ( T1_Builder*  builder,
+                                                      FT_Int       count );
                                                       
-  typedef void  (*T1_Builder_Add_Point_Func)( T1_Builder*  builder,
-                                              FT_Pos       x,
-                                              FT_Pos       y,
-                                              FT_Byte      flag );    
+  typedef void      (*T1_Builder_Add_Point_Func)    ( T1_Builder*  builder,
+                                                      FT_Pos       x,
+                                                      FT_Pos       y,
+                                                      FT_Byte      flag );    
   
-  typedef void  (*T1_Builder_Add_Point1_Func)( T1_Builder*  builder,
-                                               FT_Pos       x,
-                                               FT_Pos       y );
+  typedef void      (*T1_Builder_Add_Point1_Func)   ( T1_Builder*  builder,
+                                                      FT_Pos       x,
+                                                      FT_Pos       y );
                                                     
-  typedef FT_Error  (*T1_Builder_Add_Contour_Func)( T1_Builder*  builder );                                                    
+  typedef FT_Error  (*T1_Builder_Add_Contour_Func)  ( T1_Builder*  builder );
 
-  typedef FT_Error  (*T1_Builder_Start_Point_Func)( T1_Builder*  builder,
-                                                    FT_Pos       x,
-                                                    FT_Pos       y );
+  typedef FT_Error  (*T1_Builder_Start_Point_Func)  ( T1_Builder*  builder,
+                                                      FT_Pos       x,
+                                                      FT_Pos       y );
 
-  typedef void  (*T1_Builder_Close_Contour_Func)( T1_Builder*  builder );
+  typedef void      (*T1_Builder_Close_Contour_Func)( T1_Builder*  builder );
 
 
   typedef struct  T1_Builder_Funcs_
   {
-    FT_Error  (*init)( T1_Builder*   builder,
+    void      (*init)( T1_Builder*   builder,
                        FT_Face       face,
                        FT_Size       size,
                        FT_GlyphSlot  slot );
@@ -457,7 +457,7 @@
     void      (*done)( T1_Builder*   builder );
     
     T1_Builder_Check_Points_Func   check_points;
-    T1_Builder_Add_Points_Func     add_point;
+    T1_Builder_Add_Point_Func      add_point;
     T1_Builder_Add_Point1_Func     add_point1;
     T1_Builder_Add_Contour_Func    add_contour;
     T1_Builder_Start_Point_Func    start_point;
@@ -465,7 +465,6 @@
   
   } T1_Builder_Funcs;
 
-
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
@@ -476,10 +475,13 @@
 
   typedef struct  PSAux_Interface_
   {
-    const T1_Table_Funcs*    t1_table_funcs;
-    const T1_Parser_Funcs*   t1_parser_funcs;
-    const T1_Builder_Funcs*  t1_builder_funcs;
+    const PS_Table_Funcs*   t1_table_funcs;
+    const T1_Parser_Funcs*  t1_parser_funcs;
+    const T1_Builder_Funcs* t1_builder_funcs;
 
+    void                  (*t1_decrypt)( FT_Byte*   buffer,
+                                         FT_Int     length,
+                                         FT_UShort  seed );
   } PSAux_Interface;
 
 
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 2912cde..c0b7cd9 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -18,6 +18,7 @@
 
 #include <freetype/internal/psaux.h>
 #include <freetype/fterrors.h>
+#include <freetype/internal/ftdebug.h>
 
 #ifdef FT_FLAT_COMPILE
 
@@ -33,7 +34,7 @@
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
-  /*****                             T1_TABLE                          *****/
+  /*****                             PS_TABLE                          *****/
   /*****                                                               *****/
   /*************************************************************************/
   /*************************************************************************/
@@ -41,10 +42,10 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    T1_New_Table                                                       */
+  /*    PS_Table_New                                                       */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Initializes a T1_Table.                                            */
+  /*    Initialises a PS_Table.                                            */
   /*                                                                       */
   /* <InOut>                                                               */
   /*    table  :: The address of the target table.                         */
@@ -59,7 +60,7 @@
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   LOCAL_FUNC
-  FT_Error  T1_New_Table( T1_Table*  table,
+  FT_Error  PS_Table_New( PS_Table*  table,
                           FT_Int     count,
                           FT_Memory  memory )
   {
@@ -87,7 +88,7 @@
 
 
   static
-  void  shift_elements( T1_Table*  table,
+  void  shift_elements( PS_Table*  table,
                         FT_Byte*   old_base )
   {
     FT_Long    delta  = table->block - old_base;
@@ -105,7 +106,7 @@
 
 
   static
-  FT_Error  reallocate_t1_table( T1_Table*  table,
+  FT_Error  reallocate_t1_table( PS_Table*  table,
                                  FT_Int     new_size )
   {
     FT_Memory  memory   = table->memory;
@@ -130,10 +131,10 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    T1_Add_Table                                                       */
+  /*    PS_Table_Add                                                       */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Adds an object to a T1_Table, possibly growing its memory block.   */
+  /*    Adds an object to a PS_Table, possibly growing its memory block.   */
   /*                                                                       */
   /* <InOut>                                                               */
   /*    table  :: The target table.                                        */
@@ -150,14 +151,14 @@
   /*    reallocation fails.                                                */
   /*                                                                       */
   LOCAL_DEF
-  FT_Error  T1_Add_Table( T1_Table*  table,
+  FT_Error  PS_Table_Add( PS_Table*  table,
                           FT_Int     index,
                           void*      object,
                           FT_Int     length )
   {
     if ( index < 0 || index > table->max_elems )
     {
-      FT_ERROR(( "T1_Add_Table: invalid index\n" ));
+      FT_ERROR(( "PS_Table_Add: invalid index\n" ));
       return FT_Err_Invalid_Argument;
     }
 
@@ -189,10 +190,10 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    T1_Done_Table                                                      */
+  /*    PS_Table_Done                                                      */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Finalizes a T1_Table (i.e., reallocate it to its current cursor).  */
+  /*    Finalizes a PS_Table (i.e., reallocate it to its current cursor).  */
   /*                                                                       */
   /* <InOut>                                                               */
   /*    table :: The target table.                                         */
@@ -202,7 +203,7 @@
   /*    to the caller to clean it, or reference it in its own structures.  */
   /*                                                                       */
   LOCAL_FUNC
-  void  T1_Done_Table( T1_Table*  table )
+  void  PS_Table_Done( PS_Table*  table )
   {
     FT_Memory  memory = table->memory;
     FT_Error   error;
@@ -223,7 +224,7 @@
 
 
   LOCAL_FUNC
-  void  T1_Release_Table( T1_Table*  table )
+  void  PS_Table_Release( PS_Table*  table )
   {
     FT_Memory  memory = table->memory;
 
@@ -1005,7 +1006,7 @@
   {
     parser->error  = 0;
     parser->base   = base;
-    parser->limit  = base;
+    parser->limit  = limit;
     parser->cursor = base;
     parser->memory = memory;
   }                            
@@ -1029,7 +1030,7 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    T1_Init_Builder                                                    */
+  /*    T1_Builder_Init                                                    */
   /*                                                                       */
   /* <Description>                                                         */
   /*    Initializes a given glyph builder.                                 */
@@ -1044,8 +1045,8 @@
   /*                                                                       */
   /*    glyph   :: The current glyph object.                               */
   /*                                                                       */
-  LOCALFUNC
-  void  T1_Init_Builder( T1_Builder*   builder,
+  LOCAL_FUNC
+  void  T1_Builder_Init( T1_Builder*   builder,
                          FT_Face       face,
                          FT_Size       size,
                          FT_GlyphSlot  glyph )
@@ -1055,11 +1056,11 @@
 
     builder->face   = face;
     builder->glyph  = glyph;
-    builder->memory = face->root.memory;
+    builder->memory = face->memory;
 
     if ( glyph )
     {
-      FT_GlyphLoader*  loader = glyph->root.loader;
+      FT_GlyphLoader*  loader = glyph->loader;
 
 
       builder->loader  = loader;
@@ -1087,7 +1088,7 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    T1_Done_Builder                                                    */
+  /*    T1_Builder_Done                                                    */
   /*                                                                       */
   /* <Description>                                                         */
   /*    Finalizes a given glyph builder.  Its contents can still be used   */
@@ -1097,14 +1098,14 @@
   /* <Input>                                                               */
   /*    builder :: A pointer to the glyph builder to finalize.             */
   /*                                                                       */
-  LOCALFUNC
-  void  T1_Done_Builder( T1_Builder*  builder )
+  LOCAL_FUNC
+  void  T1_Builder_Done( T1_Builder*  builder )
   {
-    T1_GlyphSlot  glyph = builder->glyph;
+    FT_GlyphSlot  glyph = builder->glyph;
 
 
     if ( glyph )
-      glyph->root.outline = *builder->base;
+      glyph->outline = *builder->base;
   }
 
 
@@ -1152,9 +1153,9 @@
     FT_Error  error;
 
 
-    error = check_points( builder, 1 );
+    error = T1_Builder_Check_Points( builder, 1 );
     if ( !error )
-      add_point( builder, x, y, 1 );
+      T1_Builder_Add_Point( builder, x, y, 1 );
 
     return error;
   }
@@ -1171,7 +1172,7 @@
     if ( !builder->load_points )
     {
       outline->n_contours++;
-      return T1_Err_Ok;
+      return FT_Err_Ok;
     }
 
     error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );
@@ -1200,9 +1201,9 @@
     if ( !builder->path_begun )
     {
       builder->path_begun = 1;
-      error = add_contour( builder );
+      error = T1_Builder_Add_Contour( builder );
       if ( !error )
-        error = add_point1( builder, x, y );
+        error = T1_Builder_Add_Point1( builder, x, y );
     }
     return error;
   }
@@ -1246,7 +1247,6 @@
   /*************************************************************************/
   /*************************************************************************/
 
-
   LOCAL_FUNC
   void  T1_Decrypt( FT_Byte*   buffer,
                     FT_Int     length,
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index c321536..c61bdbc 100644
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -37,21 +37,22 @@
 
 
   LOCAL_DEF
-  FT_Error  T1_New_Table( T1_Table*  table,
+  FT_Error  PS_Table_New( PS_Table*  table,
                           FT_Int     count,
                           FT_Memory  memory );
  
   LOCAL_DEF
-  FT_Error  T1_Add_Table( T1_Table*  table,
+  FT_Error  PS_Table_Add( PS_Table*  table,
                           FT_Int     index,
                           void*      object,
                           FT_Int     length );
 
   LOCAL_DEF
-  void  T1_Done_Table( T1_Table*  table );
+  void      PS_Table_Done( PS_Table*  table );
+
 
   LOCAL_DEF
-  void  T1_Release_Table( T1_Table*  table );
+  void      PS_Table_Release( PS_Table*  table );
 
 
   /*************************************************************************/
@@ -115,15 +116,69 @@
 
 
   LOCAL_DEF
-  void  T1_Init_Parser( T1_Parser*  parser,
-                        FT_Byte*    base,
-                        FT_Byte*    limit,
-                        FT_Memory   memory );
+  void      T1_Init_Parser( T1_Parser*  parser,
+                            FT_Byte*    base,
+                            FT_Byte*    limit,
+                            FT_Memory   memory );
+
+  LOCAL_DEF
+  void      T1_Done_Parser( T1_Parser*  parser );
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                            T1 BUILDER                         *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+  LOCAL_DEF
+  void  T1_Builder_Init( T1_Builder*   builder,
+                         FT_Face       face,
+                         FT_Size       size,
+                         FT_GlyphSlot  glyph );
+
+  LOCAL_DEF
+  void  T1_Builder_Done( T1_Builder*  builder );
+  
+  LOCAL_DEF
+  FT_Error  T1_Builder_Check_Points( T1_Builder*  builder,
+                                     FT_Int       count );
+  
+  LOCAL_DEF
+  void  T1_Builder_Add_Point( T1_Builder*  builder,
+                              FT_Pos       x,
+                              FT_Pos       y,
+                              FT_Byte      flag );
+
+  LOCAL_DEF
+  FT_Error  T1_Builder_Add_Point1( T1_Builder*  builder,
+                                   FT_Pos       x,
+                                   FT_Pos       y );
+                                   
+  LOCAL_DEF
+  FT_Error  T1_Builder_Add_Contour( T1_Builder*  builder );
+  
+
+  LOCAL_DEF
+  FT_Error  T1_Builder_Start_Point( T1_Builder*  builder,
+                                    FT_Pos       x,
+                                    FT_Pos       y );
+
 
   LOCAL_DEF
-  void  T1_Done_Parser( T1_Parser*  parser )
+  void  T1_Builder_Close_Contour( T1_Builder*  builder );
 
 
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                            OTHER                              *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
   LOCAL_DEF
   void  T1_Decrypt( FT_Byte*   buffer,
                     FT_Int     length,