Commit a959c3c960c433919e8b8f1c22a6702fa2664cd8

Werner Lemberg 2003-06-14T07:40:09

* src/pfr/pfrobjs.c (pfr_slot_load): Apply font matrix. * src/cid/cidload.c: Remove parse_font_bbox code (already enclosed with #if 0 ... #endif). * src/type1/t1tokens.h: Handle /FontName. * src/type1/t1load.c (parse_font_name): Removed. Remove parse_font_bbox code (already enclosed with #if 0 ... #endif). * src/type42/t42parse.c (t42_parse_font_name): Removed. Remove t42_parse_font_bbox code (already enclosed with #if 0 ... #endif). (t42_keywords): Handle /FontName with T1_FIELD_KEY.

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
diff --git a/ChangeLog b/ChangeLog
index 7a05f5b..9a6dce6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-06-13  Detlef Würkner  <TetiSoft@apg.lahn.de>
+
+	* src/pfr/pfrobjs.c (pfr_slot_load): Apply font matrix.
+
 2003-06-13  Werner Lemberg  <wl@gnu.org>
 
 	* builds/dos/detect.mk: Test not only for `Dos' but for `DOS' also.
@@ -9,6 +13,19 @@
 	* builds/compiler/watcom.mk (LINK_LIBRARY): GNU Make for DOS doesn't
 	like a trailing semicolon; add a dummy command.
 
+	* src/cid/cidload.c: Remove parse_font_bbox code (already enclosed
+	with #if 0 ... #endif).
+
+	* src/type1/t1tokens.h: Handle /FontName.
+	* src/type1/t1load.c (parse_font_name): Removed.
+	Remove parse_font_bbox code (already enclosed with #if 0 ...
+	#endif).
+
+	* src/type42/t42parse.c (t42_parse_font_name): Removed.
+	Remove t42_parse_font_bbox code (already enclosed with #if 0 ...
+	#endif).
+	(t42_keywords): Handle /FontName with T1_FIELD_KEY.
+
 2003-06-12  Werner Lemberg  <wl@gnu.org>
 
 	* include/freetype/internal/psaux.h (T1_FieldType): Add
diff --git a/docs/TODO b/docs/TODO
index 73a3498..ee4ec39 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -9,5 +9,18 @@ not exactly bugs, but should be considered though:
   the quality of AA text, but Monochrome and LCD hinting still suck.  We
   need to do something about that.
 
+* Add CIDCMap support to the CID driver.
+
+* Add track kerning support to the Type1 and PFR driver and the API
+  (The degree of kerning, e.g. light, normal or tight, and
+  the glyph size has to be passed as parameter).
+
+* Add kerning (AFM file) support to the CID driver.
+
+* Possibly add support for reading PFM files.
+
+* Is the anti-aliased glyphs feature of BDF also available in PCF format?
+  If yes, add support to the PCF driver.
+
 
 --- end of TODO ---
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 7d20a4b..6ed12a0 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -743,10 +743,11 @@ FT_BEGIN_HEADER
   /*    descender           :: The face's descender is the vertical        */
   /*                           distance from the baseline to the           */
   /*                           bottommost point of any glyph in the face.  */
-  /*                           This field's value is *negative*, expressed */
-  /*                           in font units.  Some font designs use a     */
-  /*                           value different from `bbox.yMin'.  Only     */
-  /*                           relevant for scalable formats.              */
+  /*                           This field's value is *negative* for values */
+  /*                           below the baseline.  It is expressed in     */
+  /*                           font units.  Some font designs use a value  */
+  /*                           different from `bbox.yMin'.  Only relevant  */
+  /*                           for scalable formats.                       */
   /*                                                                       */
   /*    height              :: The face's height is the vertical distance  */
   /*                           from one baseline to the next when writing  */
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 1458025..7b0aba6 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -142,27 +142,6 @@
   }
 
 
-#if 0
-  FT_CALLBACK_DEF( FT_Error )
-  parse_font_bbox( CID_Face     face,
-                   CID_Parser*  parser )
-  {
-    FT_Fixed  temp[4];
-    FT_BBox*  bbox = &face->cid.font_bbox;
-
-
-    (void)cid_parser_to_fixed_array( parser, 4, temp, 0 );
-    bbox->xMin = FT_RoundFix( temp[0] );
-    bbox->yMin = FT_RoundFix( temp[1] );
-    bbox->xMax = FT_RoundFix( temp[2] );
-    bbox->yMax = FT_RoundFix( temp[3] );
-
-    return CID_Err_Ok;       /* this is a callback function; */
-                             /* we must return an error code */
-  }
-#endif
-
-
   FT_CALLBACK_DEF( FT_Error )
   parse_font_matrix( CID_Face     face,
                      CID_Parser*  parser )
@@ -261,10 +240,7 @@
 
 #include "cidtoken.h"
 
-#if 0
-    T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
-#endif
-    T1_FIELD_CALLBACK( "FDArray", parse_fd_array )
+    T1_FIELD_CALLBACK( "FDArray",    parse_fd_array )
     T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix )
 
     { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0 }
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 4673222..af993e8 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -114,128 +114,128 @@
       goto Exit;
 
     /* now load the physical font descriptor */
-     error = pfr_phy_font_load( &face->phy_font, stream,
-                                 face->log_font.phys_offset,
-                                 face->log_font.phys_size );
-     if ( error )
-       goto Exit;
-
-     /* now, set-up all root face fields */
-     {
-       FT_Face      root     = FT_FACE( face );
-       PFR_PhyFont  phy_font = &face->phy_font;
-
-
-       root->face_index = face_index;
-       root->num_glyphs = phy_font->num_chars;
-       root->face_flags = FT_FACE_FLAG_SCALABLE;
-
-       if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
-         root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
-
-       if ( phy_font->flags & PFR_PHY_VERTICAL )
-         root->face_flags |= FT_FACE_FLAG_VERTICAL;
-       else
-         root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
-
-       if ( phy_font->num_strikes > 0 )
-         root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
-
-       if ( phy_font->num_kern_pairs > 0 )
-         root->face_flags |= FT_FACE_FLAG_KERNING;
-
-       /* If no family name was found in the "undocumented" auxiliary
-        * data, use the font ID instead.  This sucks but is better than
-        * nothing.
-        */
-       root->family_name = phy_font->family_name;
-       if ( root->family_name == NULL )
-         root->family_name = phy_font->font_id;
-
-       /* note that the style name can be NULL in certain PFR fonts,
-        * probably meaning "Regular"
-        */
-       root->style_name = phy_font->style_name;
-
-       root->num_fixed_sizes = 0;
-       root->available_sizes = 0;
-
-       root->bbox         = phy_font->bbox;
-       root->units_per_EM = (FT_UShort)phy_font->outline_resolution;
-       root->ascender     = (FT_Short) phy_font->bbox.yMax;
-       root->descender    = (FT_Short) phy_font->bbox.yMin;
-       root->height       = (FT_Short)
-                              ( ( ( root->ascender - root->descender ) * 12 )
-                                / 10 );
-
-       if ( phy_font->num_strikes > 0 )
-       {
-         FT_UInt          n, count = phy_font->num_strikes;
-         FT_Bitmap_Size*  size;
-         PFR_Strike       strike;
-         FT_Memory        memory = root->stream->memory;
+    error = pfr_phy_font_load( &face->phy_font, stream,
+                               face->log_font.phys_offset,
+                               face->log_font.phys_size );
+    if ( error )
+      goto Exit;
+
+    /* now, set-up all root face fields */
+    {
+      FT_Face      root     = FT_FACE( face );
+      PFR_PhyFont  phy_font = &face->phy_font;
+
+
+      root->face_index = face_index;
+      root->num_glyphs = phy_font->num_chars;
+      root->face_flags = FT_FACE_FLAG_SCALABLE;
+
+      if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
+        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+
+      if ( phy_font->flags & PFR_PHY_VERTICAL )
+        root->face_flags |= FT_FACE_FLAG_VERTICAL;
+      else
+        root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
+
+      if ( phy_font->num_strikes > 0 )
+        root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
+
+      if ( phy_font->num_kern_pairs > 0 )
+        root->face_flags |= FT_FACE_FLAG_KERNING;
+
+      /* If no family name was found in the "undocumented" auxiliary
+       * data, use the font ID instead.  This sucks but is better than
+       * nothing.
+       */
+      root->family_name = phy_font->family_name;
+      if ( root->family_name == NULL )
+        root->family_name = phy_font->font_id;
+
+      /* note that the style name can be NULL in certain PFR fonts,
+       * probably meaning "Regular"
+       */
+      root->style_name = phy_font->style_name;
+
+      root->num_fixed_sizes = 0;
+      root->available_sizes = 0;
+
+      root->bbox         = phy_font->bbox;
+      root->units_per_EM = (FT_UShort)phy_font->outline_resolution;
+      root->ascender     = (FT_Short) phy_font->bbox.yMax;
+      root->descender    = (FT_Short) phy_font->bbox.yMin;
+      root->height       = (FT_Short)
+                             ( ( ( root->ascender - root->descender ) * 12 )
+                               / 10 );
+
+      if ( phy_font->num_strikes > 0 )
+      {
+        FT_UInt          n, count = phy_font->num_strikes;
+        FT_Bitmap_Size*  size;
+        PFR_Strike       strike;
+        FT_Memory        memory = root->stream->memory;
          
          
-         if ( FT_NEW_ARRAY( root->available_sizes, count ) )
-           goto Exit;
+        if ( FT_NEW_ARRAY( root->available_sizes, count ) )
+          goto Exit;
          
-         size   = root->available_sizes;
-         strike = phy_font->strikes;
-         for ( n = 0; n < count; n++, size++, strike++ )
-         {
-           size->height = (FT_UShort)strike->y_ppm;
-           size->width  = (FT_UShort)strike->x_ppm;
-         }
-         root->num_fixed_sizes = count;
-       }
+        size   = root->available_sizes;
+        strike = phy_font->strikes;
+        for ( n = 0; n < count; n++, size++, strike++ )
+        {
+          size->height = (FT_UShort)strike->y_ppm;
+          size->width  = (FT_UShort)strike->x_ppm;
+        }
+        root->num_fixed_sizes = count;
+      }
 
-       /* now compute maximum advance width */
-       if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
-         root->max_advance_width = (FT_Short)phy_font->standard_advance;
-       else
-       {
-         FT_Int    max = 0;
-         FT_UInt   count = phy_font->num_chars;
-         PFR_Char  gchar = phy_font->chars;
+      /* now compute maximum advance width */
+      if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
+        root->max_advance_width = (FT_Short)phy_font->standard_advance;
+      else
+      {
+        FT_Int    max = 0;
+        FT_UInt   count = phy_font->num_chars;
+        PFR_Char  gchar = phy_font->chars;
 
 
-         for ( ; count > 0; count--, gchar++ )
-         {
-           if ( max < gchar->advance )
-             max = gchar->advance;
-         }
+        for ( ; count > 0; count--, gchar++ )
+        {
+          if ( max < gchar->advance )
+            max = gchar->advance;
+        }
 
-         root->max_advance_width = (FT_Short)max;
-       }
+        root->max_advance_width = (FT_Short)max;
+      }
 
-       root->max_advance_height = root->height;
+      root->max_advance_height = root->height;
 
-       root->underline_position  = (FT_Short)( - root->units_per_EM / 10 );
-       root->underline_thickness = (FT_Short)(   root->units_per_EM / 30 );
+      root->underline_position  = (FT_Short)( - root->units_per_EM / 10 );
+      root->underline_thickness = (FT_Short)(   root->units_per_EM / 30 );
 
-       /* create charmap */
-       {
-         FT_CharMapRec  charmap;
+      /* create charmap */
+      {
+        FT_CharMapRec  charmap;
 
 
-         charmap.face        = root;
-         charmap.platform_id = 3;
-         charmap.encoding_id = 1;
-         charmap.encoding    = FT_ENCODING_UNICODE;
+        charmap.face        = root;
+        charmap.platform_id = 3;
+        charmap.encoding_id = 1;
+        charmap.encoding    = FT_ENCODING_UNICODE;
 
-         FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
+        FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
 
 #if 0
-         /* Select default charmap */
-         if (root->num_charmaps)
-           root->charmap = root->charmaps[0];
+        /* Select default charmap */
+        if (root->num_charmaps)
+          root->charmap = root->charmaps[0];
 #endif
-       }
+      }
 
-       /* check whether we've loaded any kerning pairs */
-       if ( phy_font->num_kern_pairs )
-         root->face_flags |= FT_FACE_FLAG_KERNING;
-     }
+      /* check whether we've loaded any kerning pairs */
+      if ( phy_font->num_kern_pairs )
+        root->face_flags |= FT_FACE_FLAG_KERNING;
+    }
 
   Exit:
     return error;
@@ -354,6 +354,21 @@
       metrics->vertBearingX = 0;
       metrics->vertBearingY = 0;
 
+      /* Apply the font matrix, if any.                 */
+      /* TODO: Test existing fonts with unusual matrix  */
+      /* whether we have to adjust Units per EM.        */
+      {
+        FT_Matrix font_matrix;
+
+
+        font_matrix.xx = face->log_font.matrix[0] << 8;
+        font_matrix.yx = face->log_font.matrix[1] << 8;
+        font_matrix.xy = face->log_font.matrix[2] << 8;
+        font_matrix.yy = face->log_font.matrix[3] << 8;
+
+        FT_Outline_Transform( outline, &font_matrix );
+      }
+
       /* scale when needed */
       if ( scaling )
       {
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 0b02bf0..3e3850e 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -843,71 +843,6 @@
   /* dictionaries                                   */
 
   static void
-  parse_font_name( T1_Face    face,
-                   T1_Loader  loader )
-  {
-    T1_Parser   parser = &loader->parser;
-    FT_Error    error;
-    FT_Memory   memory = parser->root.memory;
-    FT_PtrDist  len;
-    FT_Byte*    cur;
-    FT_Byte*    cur2;
-    FT_Byte*    limit;
-
-
-    if ( face->type1.font_name )
-      /*  with synthetic fonts, it's possible we get here twice  */
-      return;
-
-    T1_Skip_Spaces( parser );
-
-    cur   = parser->root.cursor;
-    limit = parser->root.limit;
-
-    if ( cur >= limit - 1 || *cur != '/' )
-      return;
-
-    cur++;
-    cur2 = cur;
-    while ( cur2 < limit && is_name_char( *cur2 ) )
-      cur2++;
-
-    len = cur2 - cur;
-    if ( len > 0 )
-    {
-      if ( FT_ALLOC( face->type1.font_name, len + 1 ) )
-      {
-        parser->root.error = error;
-        return;
-      }
-
-      FT_MEM_COPY( face->type1.font_name, cur, len );
-      face->type1.font_name[len] = '\0';
-    }
-    parser->root.cursor = cur2;
-  }
-
-
-#if 0
-  static void
-  parse_font_bbox( T1_Face    face,
-                   T1_Loader  loader )
-  {
-    T1_Parser  parser = &loader->parser;
-    FT_Fixed   temp[4];
-    FT_BBox*   bbox   = &face->type1.font_bbox;
-
-
-    (void)T1_ToFixedArray( parser, 4, temp, 0 );
-    bbox->xMin = FT_RoundFix( temp[0] );
-    bbox->yMin = FT_RoundFix( temp[1] );
-    bbox->xMax = FT_RoundFix( temp[2] );
-    bbox->yMax = FT_RoundFix( temp[3] );
-  }
-#endif
-
-
-  static void
   parse_font_matrix( T1_Face    face,
                      T1_Loader  loader )
   {
@@ -1498,10 +1433,6 @@
 #include "t1tokens.h"
 
     /* now add the special functions... */
-    T1_FIELD_CALLBACK( "FontName", parse_font_name )
-#if 0
-    T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
-#endif
     T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix )
     T1_FIELD_CALLBACK( "Encoding", parse_encoding )
     T1_FIELD_CALLBACK( "Subrs", parse_subrs )
diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h
index 411073f..5308df1 100644
--- a/src/type1/t1tokens.h
+++ b/src/type1/t1tokens.h
@@ -66,6 +66,7 @@
 #undef  T1CODE
 #define T1CODE        T1_FIELD_LOCATION_FONT_DICT
 
+  T1_FIELD_KEY    ( "FontName", font_name )
   T1_FIELD_NUM_P  ( "PaintType", paint_type )
   T1_FIELD_NUM    ( "FontType", font_type )
   T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index 4428228..66d4635 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -34,16 +34,6 @@
 
 
   static void
-  t42_parse_font_name( T42_Face    face,
-                       T42_Loader  loader );
-
-#if 0                       
-  static void
-  t42_parse_font_bbox( T42_Face    face,
-                       T42_Loader  loader );
-#endif
-                       
-  static void
   t42_parse_font_matrix( T42_Face    face,
                          T42_Loader  loader );
   static void
@@ -82,6 +72,7 @@
 #undef  T1CODE
 #define T1CODE        T1_FIELD_LOCATION_FONT_DICT
 
+    T1_FIELD_KEY    ( "FontName",    font_name )
     T1_FIELD_NUM_P  ( "PaintType",   paint_type )
     T1_FIELD_NUM    ( "FontType",    font_type )
     T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )
@@ -93,10 +84,6 @@
 
     T1_FIELD_BBOX("FontBBox", xMin )
 
-    T1_FIELD_CALLBACK( "FontName",    t42_parse_font_name )
-#if 0
-    T1_FIELD_CALLBACK( "FontBBox",    t42_parse_font_bbox )
-#endif
     T1_FIELD_CALLBACK( "FontMatrix",  t42_parse_font_matrix )
     T1_FIELD_CALLBACK( "Encoding",    t42_parse_encoding )
     T1_FIELD_CALLBACK( "CharStrings", t42_parse_charstrings )
@@ -259,66 +246,6 @@
 
 
   static void
-  t42_parse_font_name( T42_Face    face,
-                       T42_Loader  loader )
-  {
-    T42_Parser  parser = &loader->parser;
-    FT_Error    error;
-    FT_Memory   memory = parser->root.memory;
-    FT_Int      len;
-    FT_Byte*    cur;
-    FT_Byte*    cur2;
-    FT_Byte*    limit;
-
-
-    T1_Skip_Spaces( parser );
-
-    cur   = parser->root.cursor;
-    limit = parser->root.limit;
-
-    if ( cur >= limit - 1              ||
-         ( *cur != '/' && *cur != '(') )
-      return;
-
-    cur++;
-    cur2 = cur;
-    while ( cur2 < limit && t42_is_alpha( *cur2 ) )
-      cur2++;
-
-    len = (FT_Int)( cur2 - cur );
-    if ( len > 0 )
-    {
-      if ( FT_ALLOC( face->type1.font_name, len + 1 ) )
-      {
-        parser->root.error = error;
-        return;
-      }
-
-      FT_MEM_COPY( face->type1.font_name, cur, len );
-      face->type1.font_name[len] = '\0';
-    }
-    parser->root.cursor = cur2;
-  }
-
-
-#if 0
-  static void
-  t42_parse_font_bbox( T42_Face    face,
-                       T42_Loader  loader )
-  {
-    T42_Parser  parser = &loader->parser;
-    FT_BBox*    bbox   = &face->type1.font_bbox;
-
-
-    bbox->xMin = T1_ToInt( parser );
-    bbox->yMin = T1_ToInt( parser );
-    bbox->xMax = T1_ToInt( parser );
-    bbox->yMax = T1_ToInt( parser );
-  }
-#endif
-
-
-  static void
   t42_parse_font_matrix( T42_Face    face,
                          T42_Loader  loader )
   {