Commit 4b29d58761b6ad46eff097db54ab94d3925963ca

David Turner 2002-03-25T17:02:26

removing compiler warnings

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
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index bc42877..a2385a8 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -215,7 +215,7 @@ FT_BEGIN_HEADER
 #define FT_LOCAL_DEF(x)  extern "C" x
 #else
 #define FT_LOCAL(x)      extern x
-#define FT_LOCAL_DEF(x)  extern x
+#define FT_LOCAL_DEF(x)  x
 #endif
 
 #endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index 97590ca..04377fb 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -299,7 +299,6 @@ THE SOFTWARE.
     /* set-up charmap */
     {
       FT_String   *charset_registry, *charset_encoding;
-      FT_Face      root = FT_FACE(face);
       FT_Bool      unicode_charmap  = 0;
 
 
@@ -547,7 +546,7 @@ THE SOFTWARE.
 #ifndef FT_CONFIG_OPTION_USE_CMAPS    
     (FT_CharMap_CharIndexFunc) PCF_Char_Get_Index,
 #else
-    (FT_CharMap_CharNextFunc)  0,
+    (FT_CharMap_CharIndexFunc)  0,
 #endif
 
     (FT_Face_GetKerningFunc)   0,
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index cfe555d..59bf1a8 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1014,7 +1014,6 @@ THE SOFTWARE.
       /* set-up charset */
       {
         PCF_Property  charset_registry = 0, charset_encoding = 0;
-        FT_Bool       unicode_charmap  = 0;
   
   
         charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );
diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c
index 67026b6..94edd6d 100644
--- a/src/psaux/t1cmap.c
+++ b/src/psaux/t1cmap.c
@@ -19,7 +19,7 @@
     PSNames_Service  psnames = face->psnames;
 
     cmap->num_glyphs    = face->type1.num_glyphs;
-    cmap->glyph_names   = face->type1.glyph_names;
+    cmap->glyph_names   = (const char* const*)face->type1.glyph_names;
     cmap->sid_to_string = psnames->adobe_std_strings;
     cmap->code_to_sid   = is_expert ? psnames->adobe_expert_encoding
                                     : psnames->adobe_std_encoding;
@@ -416,7 +416,7 @@
   }
 
 
-  FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
+  FT_LOCAL_DEF( const FT_CMap_ClassRec )
   t1_cmap_unicode_class_rec =
   {
     sizeof( T1_CMapUnicodeRec ),
@@ -428,6 +428,3 @@
 
 
 
-  FT_LOCAL_DEF( const FT_CMap_Class )
-  t1_cmap_unicode_class = &t1_cmap_unicode_class_rec;
-
diff --git a/src/psaux/t1cmap.h b/src/psaux/t1cmap.h
index 55ce2c1..6101f56 100644
--- a/src/psaux/t1cmap.h
+++ b/src/psaux/t1cmap.h
@@ -32,9 +32,9 @@ FT_BEGIN_HEADER
   } T1_CMapStdRec;
 
 
-  FT_LOCAL( const FT_CMap_ClassRec )   t1_cmap_standard_class_rec;
+  FT_LOCAL( const FT_CMap_ClassRec )  t1_cmap_standard_class_rec;
   
-  FT_LOCAL( const FT_CMap_ClassRec )   t1_cmap_expert_class_rec;
+  FT_LOCAL( const FT_CMap_ClassRec )  t1_cmap_expert_class_rec;
   
  /***************************************************************************/
  /***************************************************************************/
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index a2333b1..45d34ac 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -825,39 +825,6 @@
   }
 
 
- /* return length of given vector */
-#ifdef FT_CONFIG_OPTION_OLD_CALCS
-
-  static FT_F26Dot6
-  Norm( FT_F26Dot6  X,
-        FT_F26Dot6  Y )
-  {
-    TT_INT64  T1, T2;
-
-
-    MUL_64( X, X, T1 );
-    MUL_64( Y, Y, T2 );
-
-    ADD_64( T1, T2, T1 );
-
-    return (FT_F26Dot6)SQRT_64( T1 );
-  }
-
-#else  /* !FT_CONFIG_OPTION_OLD_CALCS */
-
-  static FT_F26Dot6
-  Norm( FT_F26Dot6  X,
-        FT_F26Dot6  Y )
-  {
-    FT_Vector  v;
-
-    v.x = X;
-    v.y = Y;
-    return FT_Vector_Length( &v );
-  }
-
-#endif /* FT_CONFIG_OPTION_OLD_CALCS */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -1201,6 +1168,153 @@
 #define NULL_Vector  (FT_Vector*)&Null_Vector
 
 
+ /* compute (a*b)/2^14 with maximal accuracy and rounding */
+  static FT_Int32
+  TT_MulFix14( FT_Int32  a, FT_Int  b )
+  {
+    FT_Int32   m, s, hi;
+    FT_UInt32  l, lo;
+    
+    /* compute ax*bx as 64-bit value */
+    l  = (FT_UInt32)( (a & 0xFFFF)*b );
+    m  = (a >> 16)*b;
+    
+    lo = l + (FT_UInt32)(m << 16);
+    hi = (m >> 16) + ((FT_Int32)l >> 31) + (lo < l);
+    
+    /* divide the result by 2^14 with rounding */
+    s   = (hi >> 31);
+    l   = lo + (FT_UInt32)s;
+    hi += s + (l < lo);
+    lo  = l;
+
+    l   = lo + 0x2000U;
+    hi += (l < lo);
+    
+    return ( (hi << 18) | (l >> 14) );
+  }
+
+
+ /* compute (ax*bx+ay*by)/2^14 with maximal accuracy and rounding */
+  static FT_Int32
+  TT_DotFix14( FT_Int32  ax, FT_Int32  ay, FT_Int  bx, FT_Int  by )
+  {
+    FT_Int32   m, s, hi1, hi2, hi;
+    FT_UInt32  l, lo1, lo2, lo;
+    
+    /* compute ax*bx as 64-bit value */
+    l = (FT_UInt32)( (ax & 0xFFFF)*bx );
+    m = (ax >> 16)*bx;
+    
+    lo1 = l + (FT_UInt32)(m << 16);
+    hi1 = (m >> 16) + ((FT_Int32)l >> 31) + (lo1 < l);
+    
+    /* compute ay*by as 64-bit value */
+    l = (FT_UInt32)( (ay & 0xFFFF)*by );
+    m = (ay >> 16)*by;
+    
+    lo2 = l + (FT_UInt32)(m << 16);
+    hi2 = (m >> 16) + ((FT_Int32)l >> 31) + (lo2 < l);
+    
+    /* add them */
+    lo = lo1 + lo2;
+    hi = hi1 + hi2 + (lo < lo1);
+    
+    /* divide the result by 2^14 with rounding */
+    s   = (hi >> 31);
+    l   = lo + (FT_UInt32)s;
+    hi += s + (l < lo);
+    lo  = l;
+
+    l   = lo + 0x2000U;
+    hi += (l < lo);
+    
+    return ( (hi << 18) | (l >> 14) );
+  }
+
+ /* return length of given vector */
+#if 0
+
+  static FT_Int32
+  TT_VecLen( FT_Int32  x, FT_Int32  y )
+  {
+    FT_Int32  m, hi1, hi2, hi;
+    FT_UInt32 l, lo1, lo2, lo;
+    
+    /* compute x*x as 64-bit value */
+    lo = (FT_UInt32)(x & 0xFFFF);
+    hi = (x >> 16);
+    
+    l  = lo*lo;
+    m  = hi*lo;
+    hi = hi*hi;
+    
+    lo1 = l + (FT_UInt32)(m << 17);
+    hi1 = hi + (m >> 15) + (lo1 < l);
+    
+    /* compute y*y as 64-bit value */
+    lo = (FT_UInt32)( y & 0xFFFF );
+    hi = (y >> 16);
+    
+    l  = lo*lo;
+    m  = hi*lo;
+    hi = hi*hi;
+    
+    lo2 = l + (FT_UInt32)(m << 17);
+    hi2 = hi + (m >> 15) + (lo2 < l);
+    
+    /* add them to get 'x*x+y*y' as 64-bit value */
+    lo = lo1 + lo2;
+    hi = hi1 + hi2 + (lo < lo1);
+    
+    /* compute the square root of this value */
+    {
+      FT_UInt32  root, rem, test_div;
+      FT_Int     count;
+
+
+      root = 0;
+
+      {
+        rem   = 0;
+        count = 32;
+        do
+        {
+          rem      = ( rem << 2 ) | ( (FT_UInt32)hi  >> 30 );
+          hi       = (  hi << 2 ) | ( lo >> 30 );
+          lo     <<= 2;
+          root   <<= 1;
+          test_div = ( root << 1 ) + 1;
+
+          if ( rem >= test_div )
+          {
+            rem  -= test_div;
+            root += 1;
+          }
+        } while ( --count );
+      }
+      
+      return (FT_Int32)root;
+    }
+  }
+#else
+ 
+ /* this version uses FT_Vector_Length which computes the same value */
+ /* much, much faster..                                              */
+ /*                                                                  */
+  static FT_F26Dot6
+  TT_VecLen( FT_F26Dot6  X,
+             FT_F26Dot6  Y )
+  {
+    FT_Vector  v;
+
+    v.x = X;
+    v.y = Y;
+    return FT_Vector_Length( &v );
+  }
+  
+#endif
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -1231,7 +1345,7 @@
 
       x = TT_MULDIV( CUR.GS.projVector.x, CUR.tt_metrics.x_ratio, 0x4000 );
       y = TT_MULDIV( CUR.GS.projVector.y, CUR.tt_metrics.y_ratio, 0x4000 );
-      CUR.tt_metrics.ratio = Norm( x, y );
+      CUR.tt_metrics.ratio = TT_VecLen( x, y );
     }
 
     return CUR.tt_metrics.ratio;
@@ -1982,8 +2096,10 @@
   Project( EXEC_OP_ FT_Vector*  v1,
                     FT_Vector*  v2 )
   {
-    return TT_MULDIV( v1->x - v2->x, CUR.GS.projVector.x, 0x4000 ) +
-           TT_MULDIV( v1->y - v2->y, CUR.GS.projVector.y, 0x4000 );
+    return TT_DotFix14( v1->x - v2->x,
+                        v1->y - v2->y,
+                        CUR.GS.projVector.x,
+                        CUR.GS.projVector.y );
   }
 
 
@@ -2007,8 +2123,10 @@
   Dual_Project( EXEC_OP_ FT_Vector*  v1,
                          FT_Vector*  v2 )
   {
-    return TT_MULDIV( v1->x - v2->x, CUR.GS.dualVector.x, 0x4000 ) +
-           TT_MULDIV( v1->y - v2->y, CUR.GS.dualVector.y, 0x4000 );
+    return TT_DotFix14( v1->x - v2->x,
+                        v1->y - v2->y,
+                        CUR.GS.dualVector.x,
+                        CUR.GS.dualVector.y );
   }
 
 
@@ -2032,8 +2150,10 @@
   Free_Project( EXEC_OP_ FT_Vector*  v1,
                          FT_Vector*  v2 )
   {
-    return TT_MULDIV( v1->x - v2->x, CUR.GS.freeVector.x, 0x4000 ) +
-           TT_MULDIV( v1->y - v2->y, CUR.GS.freeVector.y, 0x4000 );
+    return TT_DotFix14( v1->x - v2->x,
+                        v1->y - v2->y,
+                        CUR.GS.freeVector.x,
+                        CUR.GS.freeVector.y );
   }
 
 
@@ -2188,7 +2308,6 @@
   /*    R is undefined.                                                    */
   /*                                                                       */
 
-#ifdef FT_CONFIG_OPTION_OLD_CALCS
 
   static FT_Bool
   Normalize( EXEC_OP_ FT_F26Dot6      Vx,
@@ -2206,7 +2325,7 @@
       Vx *= 0x100;
       Vy *= 0x100;
 
-      W = Norm( Vx, Vy );
+      W = TT_VecLen( Vx, Vy );
 
       if ( W == 0 )
       {
@@ -2221,7 +2340,7 @@
       return SUCCESS;
     }
 
-    W = Norm( Vx, Vy );
+    W = TT_VecLen( Vx, Vy );
 
     Vx = FT_MulDiv( Vx, 0x4000L, W );
     Vy = FT_MulDiv( Vy, 0x4000L, W );
@@ -2284,30 +2403,6 @@
     return SUCCESS;
   }
 
-#else
-
-  static FT_Bool
-  Normalize( EXEC_OP_ FT_F26Dot6      Vx,
-                      FT_F26Dot6      Vy,
-                      FT_UnitVector*  R )
-  {
-    FT_Vector  v;
-    FT_Angle   angle;
-
-    FT_UNUSED_EXEC;
-
-    angle = FT_Atan2( Vx, Vy );
-
-    FT_Vector_Unit( &v, angle );
-
-    R->x = (short)(v.x >> 2);
-    R->y = (short)(v.y >> 2);
-
-    return SUCCESS;
-  }
-
-#endif /* FT_CONFIG_OPTION_OLD_CALCS */
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -5016,8 +5111,8 @@
 
 #ifdef NO_APPLE_PATENT
 
-    *x = TT_MULDIV( d, CUR.GS.freeVector.x, 0x4000 );
-    *y = TT_MULDIV( d, CUR.GS.freeVector.y, 0x4000 );
+    *x = TT_MulFix14( d, CUR.GS.freeVector.x );
+    *y = TT_MulFix14( d, CUR.GS.freeVector.y );
 
 #else
 
@@ -5225,12 +5320,8 @@
       return;
     }
 
-    dx = TT_MULDIV( args[0],
-                    (FT_Long)CUR.GS.freeVector.x,
-                    0x4000 );
-    dy = TT_MULDIV( args[0],
-                    (FT_Long)CUR.GS.freeVector.y,
-                    0x4000 );
+    dx = TT_MulFix14( args[0], CUR.GS.freeVector.x );
+    dy = TT_MulFix14( args[0], CUR.GS.freeVector.y );
 
     while ( CUR.GS.loop > 0 )
     {
@@ -5393,11 +5484,9 @@
 
     if ( CUR.GS.gep0 == 0 )   /* If in twilight zone */
     {
-      CUR.zp0.org[point].x = TT_MULDIV( CUR.GS.freeVector.x,
-                                        distance, 0x4000 );
-      CUR.zp0.org[point].y = TT_MULDIV( CUR.GS.freeVector.y,
-                                        distance, 0x4000 );
-      CUR.zp0.cur[point] = CUR.zp0.org[point];
+      CUR.zp0.org[point].x = TT_MulFix14( distance, CUR.GS.freeVector.x );
+      CUR.zp0.org[point].y = TT_MulFix14( distance, CUR.GS.freeVector.y ),
+      CUR.zp0.cur[point]   = CUR.zp0.org[point];
     }
 
     org_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
@@ -5550,14 +5639,10 @@
     if ( CUR.GS.gep1 == 0 )
     {
       CUR.zp1.org[point].x = CUR.zp0.org[CUR.GS.rp0].x +
-                             TT_MULDIV( cvt_dist,
-                                        CUR.GS.freeVector.x,
-                                        0x4000 );
+                             TT_MulFix14( cvt_dist, CUR.GS.freeVector.x );
 
       CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y +
-                             TT_MULDIV( cvt_dist,
-                                        CUR.GS.freeVector.y,
-                                        0x4000 );
+                             TT_MulFix14( cvt_dist, CUR.GS.freeVector.y );
 
       CUR.zp1.cur[point] = CUR.zp1.org[point];
     }