Commit fdc042b8a94e591d2d4405123cb6d9f9c6c990d8

Werner Lemberg 2003-06-12T04:59:07

* src/cid/cidobjs.c: Apply change 2003-05-31 from <Ron.Dev@gmx.de>. Compute style flags. Fix computation of root->height. * src/cid/cidtoken.h: Handle FontBBox. * src/cid/cidload.c (cid_load_keyword): Handle T1_FIELD_LOCATION_BBOX. (parse_font_bbox): Commented out. (cid_field_record): Comment out element for parsing FontBBox. * src/type42/t42parse.c (t42_parse_font_bbox): Commented out. (t42_keywords): Handle FontBBox with T1_FIELD_BBOX, not with T1_FIELD_CALLBACK. (t42_parse_font_bbox): Commented out. (t42_load_keyword): Handle T1_FIELD_LOCATION_BBOX. * src/type42/t42objs.c (T42_Face_Init): Apply change 2003-05-31 from <Ron.Dev@gmx.de>.

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
diff --git a/ChangeLog b/ChangeLog
index 1137002..5554089 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-06-11  Werner Lemberg  <wl@gnu.org>
+
+	* src/cid/cidobjs.c: Apply change 2003-05-31 from <Ron.Dev@gmx.de>.
+	Compute style flags.
+	Fix computation of root->height.
+	* src/cid/cidtoken.h: Handle FontBBox.
+	* src/cid/cidload.c (cid_load_keyword): Handle
+	T1_FIELD_LOCATION_BBOX.
+	(parse_font_bbox): Commented out.
+	(cid_field_record): Comment out element for parsing FontBBox.
+
+	* src/type42/t42parse.c (t42_parse_font_bbox): Commented out.
+	(t42_keywords): Handle FontBBox with T1_FIELD_BBOX, not with
+	T1_FIELD_CALLBACK.
+	(t42_parse_font_bbox): Commented out.
+	(t42_load_keyword): Handle T1_FIELD_LOCATION_BBOX.
+	* src/type42/t42objs.c (T42_Face_Init): Apply change 2003-05-31
+	from <Ron.Dev@gmx.de>.
+
 2003-06-09  George Williams  <gww@silcom.com>
 
 	* src/truetype/ttinterp.c (SetSuperRound) <0x30>: Follow Apple's
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 7dffd96..77d76a8 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -115,6 +115,10 @@
       object = (FT_Byte*)&cid->font_info;
       break;
 
+    case T1_FIELD_LOCATION_BBOX:
+      object = (FT_Byte*)&cid->font_bbox;
+      break;
+
     default:
       {
         CID_FaceDict  dict;
@@ -156,6 +160,7 @@
   }
 
 
+#if 0
   FT_CALLBACK_DEF( FT_Error )
   parse_font_bbox( CID_Face     face,
                    CID_Parser*  parser )
@@ -171,8 +176,9 @@
     bbox->yMax = FT_RoundFix( temp[3] );
 
     return CID_Err_Ok;       /* this is a callback function; */
-                            /* we must return an error code */
+                             /* we must return an error code */
   }
+#endif
 
 
   FT_CALLBACK_DEF( FT_Error )
@@ -273,9 +279,12 @@
 
 #include "cidtoken.h"
 
+#if 0
     T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
+#endif
     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/cid/cidobjs.c b/src/cid/cidobjs.c
index 788eb3a..784107f 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -19,8 +19,10 @@
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
+
 #include "cidgload.h"
 #include "cidload.h"
+
 #include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 #include FT_INTERNAL_POSTSCRIPT_HINTS_H
@@ -331,83 +333,108 @@
       goto Exit;
     }
 
-    /* Now, load the font program into the face object */
+    /* now load the font program into the face object */
+
+    /* initialize the face object fields */
+
+    /* set up root face fields */
     {
-      /* Init the face object fields */
-      /* Now set up root face fields */
-      {
-        FT_Face       root = (FT_Face)&face->root;
-        CID_FaceInfo  cid  = &face->cid;
-        PS_FontInfo   info = &cid->font_info;
+      FT_Face       root = (FT_Face)&face->root;
+      CID_FaceInfo  cid  = &face->cid;
+      PS_FontInfo   info = &cid->font_info;
 
 
-        root->num_glyphs   = cid->cid_count;
-        root->num_charmaps = 0;
+      root->num_glyphs   = cid->cid_count;
+      root->num_charmaps = 0;
 
-        root->face_index = face_index;
-        root->face_flags = FT_FACE_FLAG_SCALABLE;
+      root->face_index = face_index;
+      root->face_flags = FT_FACE_FLAG_SCALABLE;
 
-        root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
+      root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
 
-        if ( info->is_fixed_pitch && *info->is_fixed_pitch )
-          root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+      if ( info->is_fixed_pitch && *info->is_fixed_pitch )
+        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
 
-        /* XXX: TODO: add kerning with .afm support */
+      /* XXX: TODO: add kerning with .afm support */
 
-        /* get style name -- be careful, some broken fonts only */
-        /* have a /FontName dictionary entry!                   */
-        root->family_name = info->family_name;
-        if ( root->family_name )
-        {
-          char*  full   = info->full_name;
-          char*  family = root->family_name;
+      /* get style name -- be careful, some broken fonts only */
+      /* have a /FontName dictionary entry!                   */
+      root->family_name = info->family_name;
+      /* assume "Regular" style if we don't know better */
+      root->style_name = (char *)"Regular";
+      if ( root->family_name )
+      {
+        char*  full   = info->full_name;
+        char*  family = root->family_name;
 
-          while ( *family && *full == *family )
-          {
-            family++;
-            full++;
-          }
 
-          if ( *full == ' ' || *full == '-' )
-            root->style_name = full + 1;
-          else
-            root->style_name = (char *)"Regular";
-        }
-        else
+        if ( full )
         {
-          /* do we have a `/FontName'? */
-          if ( cid->cid_font_name )
+          while ( *full )
           {
-            root->family_name = cid->cid_font_name;
-            root->style_name  = (char *)"Regular";
+            if ( *full == *family )
+            {
+              family++;
+              full++;
+            }
+            else
+            {
+              if ( *full == ' ' || *full == '-' )
+                full++;
+              else if ( *family == ' ' || *family == '-' )
+                family++;
+              else
+              {
+                if ( !*family )
+                  root->style_name = full;
+                break;
+              }
+            }
           }
         }
+      }
+      else
+      {
+        /* do we have a `/FontName'? */
+        if ( cid->cid_font_name )
+          root->family_name = cid->cid_font_name;
+      }
 
-        /* no embedded bitmap support */
-        root->num_fixed_sizes = 0;
-        root->available_sizes = 0;
+      /* compute style flags */
+      root->style_flags = 0;
+      if ( info->italic_angle && *info->italic_angle )
+        root->style_flags |= FT_STYLE_FLAG_ITALIC;
+      if ( info->weight )
+      {
+        if ( !ft_strcmp( info->weight, "Bold"  ) ||
+             !ft_strcmp( info->weight, "Black" ) )
+          root->style_flags |= FT_STYLE_FLAG_BOLD;
+      }
 
-        root->bbox.xMin =   cid->font_bbox.xMin             >> 16;
-        root->bbox.yMin =   cid->font_bbox.yMin             >> 16;
-        root->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
-        root->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
+      /* no embedded bitmap support */
+      root->num_fixed_sizes = 0;
+      root->available_sizes = 0;
 
-        if ( !root->units_per_EM )
-          root->units_per_EM  = 1000;
+      root->bbox.xMin =   cid->font_bbox.xMin             >> 16;
+      root->bbox.yMin =   cid->font_bbox.yMin             >> 16;
+      root->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
+      root->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
 
-        root->ascender  = (FT_Short)( root->bbox.yMax );
-        root->descender = (FT_Short)( root->bbox.yMin );
-        root->height    = (FT_Short)(
-          ( ( root->ascender + root->descender ) * 12 ) / 10 );
+      if ( !root->units_per_EM )
+        root->units_per_EM = 1000;
 
-        if ( info->underline_position )
-          root->underline_position = *info->underline_position >> 16;
-        if ( info->underline_thickness )
-          root->underline_thickness = *info->underline_thickness >> 16;
+      root->ascender  = (FT_Short)( root->bbox.yMax );
+      root->descender = (FT_Short)( root->bbox.yMin );
+      root->height    = (FT_Short)(
+        ( ( root->ascender - root->descender ) * 12 ) / 10 );
 
-        root->internal->max_points   = 0;
-        root->internal->max_contours = 0;
-      }
+      if ( info->underline_position )
+        root->underline_position = *info->underline_position >> 16;
+      if ( info->underline_thickness )
+        root->underline_thickness = *info->underline_thickness >> 16;
+
+      root->internal->max_points   = 0;
+      root->internal->max_contours = 0;
     }
 
   Exit:
diff --git a/src/cid/cidtoken.h b/src/cid/cidtoken.h
index 6d8d797..eb38c7b 100644
--- a/src/cid/cidtoken.h
+++ b/src/cid/cidtoken.h
@@ -92,5 +92,12 @@
   T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
   T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
 
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  FT_BBox
+#undef  T1CODE
+#define T1CODE        T1_FIELD_LOCATION_BBOX
+
+  T1_FIELD_BBOX( "FontBBox", xMin )
+  
 
 /* END */
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index b255f9d..6d6a774 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -227,8 +227,6 @@
 #endif /* T1_CONFIG_OPTION_NO_AFM */
 
 
-
-
   FT_CALLBACK_TABLE_DEF
   const FT_Driver_ClassRec  t1_driver_class =
   {
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 3301467..0b02bf0 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -693,9 +693,9 @@
 
 
   static FT_Error
-  t1_load_keyword( T1_Face    face,
-                   T1_Loader  loader,
-                   T1_Field   field )
+  t1_load_keyword( T1_Face         face,
+                   T1_Loader       loader,
+                   const T1_Field  field )
   {
     FT_Error  error;
     void*     dummy_object;
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 4554c67..0b6586c 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -308,7 +308,7 @@
     face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
                                               "pshinter" );
 
-    /* open the tokenizer, this will also check the font format */
+    /* open the tokenizer; this will also check the font format */
     error = T1_Open_Face( face );
     if ( error )
       goto Exit;
@@ -325,10 +325,11 @@
       goto Exit;
     }
 
-    /* Now, load the font program into the face object */
+    /* now load the font program into the face object */
 
-    /* Init the face object fields */
-    /* Now set up root face fields */
+    /* initialize the face object fields */
+
+    /* set up root face fields */
     {
       FT_Face  root = (FT_Face)&face->root;
 
@@ -336,7 +337,7 @@
       root->num_glyphs = type1->num_glyphs;
       root->face_index = face_index;
 
-      root->face_flags = FT_FACE_FLAG_SCALABLE;
+      root->face_flags  = FT_FACE_FLAG_SCALABLE;
       root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
       root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
 
@@ -418,7 +419,7 @@
       root->ascender  = (FT_Short)( root->bbox.yMax );
       root->descender = (FT_Short)( root->bbox.yMin );
       root->height    = (FT_Short)(
-                          ( ( root->ascender - root->descender ) * 12 ) / 10 );
+        ( ( root->ascender - root->descender ) * 12 ) / 10 );
 
       /* now compute the maximum advance width */
       root->max_advance_width =
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index 8fd1744..15848b3 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -211,6 +211,8 @@
     /* get style name -- be careful, some broken fonts only */
     /* have a `/FontName' dictionary entry!                 */
     root->family_name = info->family_name;
+    /* assume "Regular" style if we don't know better */
+    root->style_name = (char *)"Regular";
     if ( root->family_name )
     {
       char*  full   = info->full_name;
@@ -219,28 +221,34 @@
 
       if ( full )
       {
-        while ( *family && *full == *family )
+        while ( *full )
         {
-          family++;
-          full++;
+          if ( *full == *family )
+          {
+            family++;
+            full++;
+          }
+          else
+          {
+            if ( *full == ' ' || *full == '-' )
+              full++;
+            else if ( *family == ' ' || *family == '-' )
+              family++;
+            else
+            {
+              if ( !*family )
+                root->style_name = full;
+              break;
+            }
+          }
         }
-
-        if ( *full == ' ' || *full == '-' )
-          root->style_name = full + 1;
-        else
-          root->style_name = (char *)"Regular";
       }
-      else
-        root->style_name = (char *)"Regular";
     }
     else
     {
       /* do we have a `/FontName'? */
       if ( type1->font_name )
-      {
         root->family_name = type1->font_name;
-        root->style_name  = (char *)"Regular";
-      }
     }
 
     /* no embedded bitmap support */
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index 5e99e70..4428228 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -36,10 +36,12 @@
   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,
@@ -84,8 +86,17 @@
     T1_FIELD_NUM    ( "FontType",    font_type )
     T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )
 
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  FT_BBox
+#undef  T1CODE
+#define T1CODE        T1_FIELD_LOCATION_BBOX
+
+    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 )
@@ -290,18 +301,21 @@
   }
 
 
+#if 0
   static void
-  t42_parse_font_bbox( T42_Face   face,
+  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
@@ -837,14 +851,18 @@
     {
     case T1_FIELD_LOCATION_FONT_INFO:
       dummy_object = &face->type1.font_info;
-      objects      = &dummy_object;
+      break;
+
+    case T1_FIELD_LOCATION_BBOX:
+      dummy_object = &face->type1.font_bbox;
       break;
 
     default:
       dummy_object = &face->type1;
-      objects      = &dummy_object;
     }
 
+    objects = &dummy_object;
+
     if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
          field->type == T1_FIELD_TYPE_FIXED_ARRAY   )
       error = T1_Load_Field_Table( &loader->parser, field,