Commit 428c2e4f62abb2c7f158f7f0da43d82f848db30d

Werner Lemberg 2003-04-25T05:35:04

* src/bdf/bdflib.c (hash_bucket, hash_lookup): Use `const' for first argument. (bdf_get_font_property): Use `const' for third argument. Updated all callers. * src/bdf/bdfdrivr.c (BDF_Face_Init): Set pixel width and height similar to the PCF driver. * src/bdf/bdf.h (_hashnode): Use `const' for `key'. Updated. * src/gzip/ftgzip.c: C++ doesn't like that the array `inflate_mask' is declared twice. It is perhaps better to modify the zlip source files directly instead of this hack. (zcalloc, zfree, ft_gzip_stream_close, ft_gzip_stream_io): Add casts to make build with g++ successful.

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
diff --git a/ChangeLog b/ChangeLog
index 71e29b6..e4cdd18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,32 @@
+2003-04-25  Werner Lemberg  <wl@gnu.org>
+
+	* src/bdf/bdflib.c (hash_bucket, hash_lookup): Use `const' for first
+	argument.
+	(bdf_get_font_property): Use `const' for third argument.
+	Updated all callers.
+	* src/bdf/bdfdrivr.c (BDF_Face_Init): Set pixel width and height
+	similar to the PCF driver.
+	* src/bdf/bdf.h (_hashnode): Use `const' for `key'.
+	Updated.
+
+	* src/gzip/ftgzip.c: C++ doesn't like that the array `inflate_mask'
+	is declared twice.  It is perhaps better to modify the zlip source
+	files directly instead of this hack.
+	(zcalloc, zfree, ft_gzip_stream_close, ft_gzip_stream_io): Add casts
+	to make build with g++ successful.
+
+2003-04-24  Manish Singh  <yosh@gimp.org>
+
+	* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
+	(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Split on `-'
+	also for searching the style name.
+
 2003-04-24  David Turner  <david@freetype.org>
 
-        * src/pcf/pcfread.c (pcf_load_font): fixed the computation of
-        face->num_glyphs, this required increase the value by 1 to respect
-        the convention that gindex 0 always corresponds to the "missing
-        glyph".
+	* src/pcf/pcfread.c (pcf_load_font): fixed the computation of
+	face->num_glyphs, this required increase the value by 1 to respect
+	the convention that gindex 0 always corresponds to the "missing
+	glyph".
 
 2003-04-24  Werner Lemberg  <wl@gnu.org>
 
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index dd873cd..ef4a7f6 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1426,8 +1426,8 @@
     if ( char_height < 1 * 64 )
       char_height = 1 * 64;
 
-   /* Compute pixel sizes in 26.6 units. we use rounding
-    */
+    /* Compute pixel sizes in 26.6 units. we use rounding
+     */
     dim_x = ( ( char_width  * horz_resolution + (36+32*72) ) / 72 ) & -64;
     dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & -64;
 
diff --git a/src/bdf/bdf.h b/src/bdf/bdf.h
index 6a4bb82..4dab5ae 100644
--- a/src/bdf/bdf.h
+++ b/src/bdf/bdf.h
@@ -1,6 +1,6 @@
 /*
  * Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002 Francesco Zappa Nardelli
+ * Copyright 2001, 2002, 2003 Francesco Zappa Nardelli
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -159,8 +159,8 @@ FT_BEGIN_HEADER
 
   typedef struct  _hashnode_
   {
-    char*  key;
-    void*  data;
+    const char*  key;
+    void*        data;
   
   } _hashnode, *hashnode;
 
@@ -283,7 +283,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( bdf_property_t * )
   bdf_get_font_property( bdf_font_t*  font,
-                         char*        name );
+                         const char*  name );
 
 
 FT_END_HEADER
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 62e7ca7..c7c140f 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -169,8 +169,6 @@ THE SOFTWARE.
   };
 
 
-
-
   FT_CALLBACK_DEF( FT_Error )
   BDF_Face_Done( BDF_Face  face )
   {
@@ -250,7 +248,7 @@ THE SOFTWARE.
                          FT_FACE_FLAG_HORIZONTAL  |
                          FT_FACE_FLAG_FAST_GLYPHS;
 
-      prop = bdf_get_font_property( font, (char *)"SPACING" );
+      prop = bdf_get_font_property( font, "SPACING" );
       if ( prop != NULL )
         if ( prop->format == BDF_ATOM )
           if ( prop->value.atom != NULL )
@@ -262,7 +260,7 @@ THE SOFTWARE.
       /* FZ XXX: I need a font to implement this */
 
       root->style_flags = 0;
-      prop = bdf_get_font_property( font, (char *)"SLANT" );
+      prop = bdf_get_font_property( font, "SLANT" );
       if ( prop != NULL )
         if ( prop->format == BDF_ATOM )
           if ( prop->value.atom != NULL )
@@ -270,14 +268,14 @@ THE SOFTWARE.
                  ( *(prop->value.atom) == 'I' ) )
               root->style_flags |= FT_STYLE_FLAG_ITALIC;
 
-      prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
+      prop = bdf_get_font_property( font, "WEIGHT_NAME" );
       if ( prop != NULL )
         if ( prop->format == BDF_ATOM )
           if ( prop->value.atom != NULL )
             if ( *(prop->value.atom) == 'B' )
               root->style_flags |= FT_STYLE_FLAG_BOLD;
 
-      prop = bdf_get_font_property( font, (char *)"FAMILY_NAME" );
+      prop = bdf_get_font_property( font, "FAMILY_NAME" );
       if ( ( prop != NULL ) && ( prop->value.atom != NULL ) )
       {
         int  l = ft_strlen( prop->value.atom ) + 1;
@@ -307,22 +305,24 @@ THE SOFTWARE.
       if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
         goto Exit;
 
-      prop = bdf_get_font_property( font, (char *)"AVERAGE_WIDTH" );
+      prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
       if ( ( prop != NULL ) && ( prop->value.int32 >= 10 ) )
         root->available_sizes->width = (short)( prop->value.int32 / 10 );
 
-      prop = bdf_get_font_property( font, (char *)"PIXEL_SIZE" );
-      if ( prop != NULL )
-        root->available_sizes->height = (short) prop->value.int32;
+      prop = bdf_get_font_property( font, "PIXEL_SIZE" );
+      if ( prop != NULL ) {
+        root->available_sizes->height =
+        root->available_sizes->width  = (short) prop->value.int32;
+      }
       else
       {
-        prop = bdf_get_font_property( font, (char *)"POINT_SIZE" );
+        prop = bdf_get_font_property( font, "POINT_SIZE" );
         if ( prop != NULL )
         {
           bdf_property_t  *yres;
 
 
-          yres = bdf_get_font_property( font, (char *)"RESOLUTION_Y" );
+          yres = bdf_get_font_property( font, "RESOLUTION_Y" );
           if ( yres != NULL )
           {
             FT_TRACE4(( "POINT_SIZE: %d  RESOLUTION_Y: %d\n",
@@ -371,9 +371,9 @@ THE SOFTWARE.
 
 
         charset_registry =
-          bdf_get_font_property( font, (char *)"CHARSET_REGISTRY" );
+          bdf_get_font_property( font, "CHARSET_REGISTRY" );
         charset_encoding =
-          bdf_get_font_property( font, (char *)"CHARSET_ENCODING" );
+          bdf_get_font_property( font, "CHARSET_ENCODING" );
         if ( ( charset_registry != NULL ) && ( charset_encoding != NULL ) )
         {
           if ( ( charset_registry->format == BDF_ATOM ) &&
@@ -640,7 +640,7 @@ THE SOFTWARE.
 
     FT_ASSERT( face && face->bdffont );
 
-    prop = bdf_get_font_property( face->bdffont, (char*)prop_name );
+    prop = bdf_get_font_property( face->bdffont, prop_name );
     if ( prop != NULL )
     {
       switch ( prop->format )
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 06ce4dd..9d6cc52 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -183,10 +183,10 @@
   (*hash_free_func)( hashnode  node );
 
   static hashnode*
-  hash_bucket( char*       key,
-               hashtable*  ht )
+  hash_bucket( const char*  key,
+               hashtable*   ht )
   {
-    char*          kp  = key;
+    const char*    kp  = key;
     unsigned long  res = 0;
     hashnode*      bp  = ht->table, *ndp;
 
@@ -317,7 +317,7 @@
 
 
   static hashnode
-  hash_lookup( char*       key,
+  hash_lookup( const char* key,
                hashtable*  ht )
   {
     hashnode *np = hash_bucket( key, ht );
@@ -1882,7 +1882,7 @@
       /*                                                                  */
       /* This is *always* done regardless of the options, because X11     */
       /* requires these two fields to compile fonts.                      */
-      if ( bdf_get_font_property( p->font, (char *)"FONT_ASCENT" ) == 0 )
+      if ( bdf_get_font_property( p->font, "FONT_ASCENT" ) == 0 )
       {
         p->font->font_ascent = p->font->bbx.ascent;
         ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
@@ -1894,7 +1894,7 @@
         p->font->modified = 1;
       }
 
-      if ( bdf_get_font_property( p->font, (char *)"FONT_DESCENT" ) == 0 )
+      if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 )
       {
         p->font->font_descent = p->font->bbx.descent;
         ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
@@ -2418,7 +2418,7 @@
 
   FT_LOCAL_DEF( bdf_property_t * )
   bdf_get_font_property( bdf_font_t*  font,
-                         char*        name )
+                         const char*  name )
   {
     hashnode  hn;
 
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 6c5c5d9..0d75d89 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2374,8 +2374,8 @@
 
 
       metrics.bearing_x = decoder.builder.left_bearing.x;
-	  metrics.bearing_y = decoder.builder.left_bearing.y;
-	  metrics.advance   = decoder.builder.advance.x;
+      metrics.bearing_y = decoder.builder.left_bearing.y;
+      metrics.advance   = decoder.builder.advance.x;
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
                 face->root.internal->incremental_interface->object,
                 glyph_index, FALSE, &metrics );
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 9d953d5..6de7fd9 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -166,8 +166,8 @@
 
 
       metrics.bearing_x = decoder->builder.left_bearing.x;
-	  metrics.bearing_y = decoder->builder.left_bearing.y;
-	  metrics.advance   = decoder->builder.advance.x;
+      metrics.bearing_y = decoder->builder.left_bearing.y;
+      metrics.advance   = decoder->builder.advance.x;
       error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
                 face->root.internal->incremental_interface->object,
                 glyph_index, FALSE, &metrics );
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index ac5f16e..acccd16 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    CID objects manager (body).                                          */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -361,8 +361,10 @@
             full++;
           }
 
-          root->style_name = ( *full == ' ' ) ? full + 1
-                                              : (char *)"Regular";
+          if ( *full == ' ' || *full == '-' )
+            root->style_name = full + 1;
+          else
+            root->style_name = (char *)"Regular";
         }
         else
         {
diff --git a/src/gzip/ftgzip.c b/src/gzip/ftgzip.c
index c9bd4a5..d495800 100644
--- a/src/gzip/ftgzip.c
+++ b/src/gzip/ftgzip.c
@@ -48,12 +48,23 @@
 #include "zlib.h"
 
 #undef  SLOW
-#define SLOW  1  /* we can't use asm-optimized sources here !! */
-
+#define SLOW  1  /* we can't use asm-optimized sources here! */
+
+  /* Urgh.  `inflate_mask' must not be declared twice -- C++ doesn't like
+     this.  We temporarily rename it and load all necessary header files. */
+#define inflate_mask ft_gzip_dummy
+#include "zutil.h"
+#include "inftrees.h"
+#include "infblock.h"
+#include "infcodes.h"
+#include "infutil.h"
+#undef  inflate_mask
+
+  /* infutil.c must be included before infcodes.c */
 #include "zutil.c"
 #include "inftrees.c"
-#include "infcodes.c"
 #include "infutil.c"
+#include "infcodes.c"
 #include "infblock.c"
 #include "inflate.c"
 #include "adler32.c"
@@ -102,14 +113,14 @@
             unsigned  items,
             unsigned  size )
   {
-    return ft_gzip_alloc( opaque, items, size );
+    return ft_gzip_alloc( (FT_Memory)opaque, items, size );
   }
 
   local void
   zcfree( voidpf  opaque,
           voidpf  ptr )
   {
-    ft_gzip_free( opaque, ptr );
+    ft_gzip_free( (FT_Memory)opaque, ptr );
   }
 
 #endif /* !SYSTEM_ZLIB */
@@ -502,7 +513,7 @@
   static void
   ft_gzip_stream_close( FT_Stream  stream )
   {
-    FT_GZipFile  zip    = stream->descriptor.pointer;
+    FT_GZipFile  zip    = (FT_GZipFile)stream->descriptor.pointer;
     FT_Memory    memory = stream->memory;
 
 
@@ -524,7 +535,7 @@
                      FT_Byte*   buffer,
                      FT_ULong   count )
   {
-    FT_GZipFile  zip = stream->descriptor.pointer;
+    FT_GZipFile  zip = (FT_GZipFile)stream->descriptor.pointer;
 
 
     return ft_gzip_file_io( zip, pos, buffer, count );
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index 269a088..2d46c20 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -478,7 +478,7 @@ THE SOFTWARE.
       }
       else
       {
-        /* apparently, the PCF driver loads all properties as signed integers!
+        /* Apparently, the PCF driver loads all properties as signed integers!
          * This really doesn't seem to be a problem, because this is
          * sufficient for any meaningful values.
          */
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index ff11a86..10c8260 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -972,12 +972,12 @@ THE SOFTWARE.
       else
         root->family_name = 0;
 
-     /* note: we shift all glyph indices by +1 since we must
-      * respect the convention that glyph 0 always correspond
-      * to the "missing glyph".
-      *
-      * this implies bumping the number of "available" glyphs by 1
-      */
+      /* Note: We shift all glyph indices by +1 since we must
+       * respect the convention that glyph 0 always corresponds
+       * to the "missing glyph".
+       *
+       * This implies bumping the number of "available" glyphs by 1.
+       */
       root->num_glyphs = face->nmetrics + 1;
 
       root->num_fixed_sizes = 1;
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 5933adf..bd4f431 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -355,8 +355,10 @@
             full++;
           }
 
-          root->style_name = ( *full == ' ' ? full + 1
-                                            : (char *)"Regular" );
+          if ( *full == ' ' || *full == '-' )
+            root->style_name = full + 1;
+          else
+            root->style_name = (char *)"Regular";
         }
         else
           root->style_name = (char *)"Regular";
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index af42379..88d2fac 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -223,8 +223,10 @@
           full++;
         }
 
-        root->style_name = ( *full == ' ' ? full + 1
-                                          : (char *)"Regular" );
+        if ( *full == ' ' || *full == '-' )
+          root->style_name = full + 1;
+        else
+          root->style_name = (char *)"Regular";
       }
       else
         root->style_name = (char *)"Regular";