Commit c219a5e8c47a54f0b0a63776413ad6ba77193207

Werner Lemberg 2002-09-28T16:40:57

* src/include/freetype/internal/tttypes.h (num_sbit_strikes, num_sbit_scales): Use `FT_ULong'. * src/sfnt/sfobjs.c (sfnt_load_face): Updated accordingly. * src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Ditto. (find_sbit_image): Remove cast. * src/raster/ftrend1.c (ft_raster1_render): Fix cast. * src/sfnt/ttload.c (tt_face_load_names): Use cast. * src/sfnt/ttcmap.c (code_to_next2): Use long constant. (code_to_index4): Use cast. (code_to_index8_12): Fix cast. * src/sfnt/ttcmap0.c (tt_cmap4_char_next, tt_cmap8_char_index, tt_cmap12_char_index): Use cast for `result'. (tt_face_build_cmaps): Use cast. * src/sfnt/sfobjs.c (tt_name_entry_ascii_from_ucs4): Use cast for `code'. (sfnt_load_face): Use FT_Int32 for `flags'. * src/smooth/ftgrays.c (gray_render_scanline, gray_render_line, gray_compute_cbox, gray_convert_glyph, gray_raster_reset): Add casts to `TCoord' and `int'. More 16bit fixes. s/FT_Pos/TPos/. * src/smooth/ftsmooth.c (ft_smooth_render_generic): Add casts.

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
diff --git a/ChangeLog b/ChangeLog
index a5ba6f9..9fde1eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2002-09-27  Werner Lemberg  <wl@gnu.org>
+
+	* src/include/freetype/internal/tttypes.h (num_sbit_strikes,
+	num_sbit_scales): Use `FT_ULong'.
+	* src/sfnt/sfobjs.c (sfnt_load_face): Updated accordingly.
+	* src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Ditto.
+	(find_sbit_image): Remove cast.
+	* src/raster/ftrend1.c (ft_raster1_render): Fix cast.
+
+2002-09-27  Wolfgang Domröse  <porthos.domroese@harz.de>
+
+	* src/sfnt/ttload.c (tt_face_load_names): Use cast.
+	* src/sfnt/ttcmap.c (code_to_next2): Use long constant.
+	(code_to_index4): Use cast.
+	(code_to_index8_12): Fix cast.
+	* src/sfnt/ttcmap0.c (tt_cmap4_char_next, tt_cmap8_char_index,
+	tt_cmap12_char_index): Use cast for `result'.
+	(tt_face_build_cmaps): Use cast.
+	* src/sfnt/sfobjs.c (tt_name_entry_ascii_from_ucs4): Use cast for
+	`code'.
+	(sfnt_load_face): Use FT_Int32 for `flags'.
+
+	* src/smooth/ftgrays.c (gray_render_scanline, gray_render_line,
+	gray_compute_cbox, gray_convert_glyph, gray_raster_reset): Add casts
+	to `TCoord' and `int'.
+	More 16bit fixes.
+	s/FT_Pos/TPos/.
+	* src/smooth/ftsmooth.c (ft_smooth_render_generic): Add casts.
+
 2002-09-26  Werner Lemberg  <wl@gnu.org>
 
 	* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index 94a8905..4097ac8 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1518,10 +1518,10 @@ FT_BEGIN_HEADER
     TT_PCLT               pclt;
 
     /* embedded bitmaps support */
-    FT_Int                num_sbit_strikes;
+    FT_ULong              num_sbit_strikes;
     TT_SBit_Strike        sbit_strikes;
 
-    FT_Int                num_sbit_scales;
+    FT_ULong              num_sbit_scales;
     TT_SBit_Scale         sbit_scales;
 
     /* postscript names table */
diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c
index d7ab6e4..86b170c 100644
--- a/src/raster/ftrend1.c
+++ b/src/raster/ftrend1.c
@@ -200,8 +200,8 @@
       goto Exit;
 
     slot->format      = FT_GLYPH_FORMAT_BITMAP;
-    slot->bitmap_left = (FT_UInt)( cbox.xMin >> 6 );
-    slot->bitmap_top  = (FT_UInt)( cbox.yMax >> 6 );
+    slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 );
+    slot->bitmap_top  = (FT_Int)( cbox.yMax >> 6 );
 
   Exit:
     return error;
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index dac6c18..adaca24 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -86,7 +86,7 @@
 
     for ( n = 0; n < len; n++ )
     {
-      code = FT_NEXT_ULONG( read );
+      code = (FT_UInt)FT_NEXT_ULONG( read );
       if ( code < 32 || code > 127 )
         code = '?';
 
@@ -515,7 +515,7 @@
     /* now set up root fields */
     {
       FT_Face    root = &face->root;
-      FT_Int     flags = 0;
+      FT_Int32   flags = 0;
       FT_Memory  memory;
 
 
@@ -617,7 +617,7 @@
 
       if ( face->num_sbit_strikes )
       {
-        FT_Int  n;
+        FT_ULong  n;
 
 
         root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index a5f9cd1..f6aabfe 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -629,7 +629,7 @@
      * This is relatively simplistic -- look for a subHeader containing
      * glyphs and then walk to the first glyph in that subHeader.
      */
-    while ( charCode < 0x10000 )
+    while ( charCode < 0x10000L )
     {
       char_lo = (FT_UInt)( charCode & 0xFF );
       char_hi = charCode >> 8;
@@ -746,7 +746,7 @@
     /* directly                                                  */
 
     if ( seg4->idRangeOffset == 0 )
-      result = ( charCode + seg4->idDelta ) & 0xFFFFU;
+      result = (FT_UInt)( charCode + seg4->idDelta ) & 0xFFFFU;
     else
     {
       /* otherwise, we must use the glyphIdArray to do it */
@@ -971,7 +971,8 @@
     cmap8_12->last_group = group;
 
   Found1:
-    return group->startGlyphID + (FT_UInt)( charCode - group->startCharCode );
+    return (FT_UInt)( group->startGlyphID +
+                      ( charCode - group->startCharCode ) );
   }
 
 
diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c
index 3b9e6fb..5a024ec 100644
--- a/src/sfnt/ttcmap0.c
+++ b/src/sfnt/ttcmap0.c
@@ -940,7 +940,7 @@
 
       code++;
     }
-    return result;
+    return (FT_UInt)result;
 
   Exit:
     *pchar_code = result;
@@ -1281,7 +1281,7 @@
 
       if ( char_code <= end )
       {
-        result = start_id + char_code - start;
+        result = (FT_UInt)( start_id + char_code - start );
         break;
       }
     }
@@ -1588,7 +1588,7 @@
 
       if ( char_code <= end )
       {
-        result = start_id + char_code - start;
+        result = (FT_UInt)( start_id + char_code - start );
         break;
       }
     }
@@ -1747,7 +1747,7 @@
             ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
                                FT_VALIDATE_DEFAULT );
 
-            valid.num_glyphs = face->root.num_glyphs;
+            valid.num_glyphs = (FT_UInt)face->root.num_glyphs;
 
             if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 )
             {
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 603e490..669f365 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -1139,7 +1139,7 @@
         entry++;
       }
 
-      table->numNameRecords = entry - table->names;
+      table->numNameRecords = (FT_UInt)( entry - table->names );
     }
 
     FT_FRAME_EXIT();
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 51513ea..a554060 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -626,7 +626,7 @@
                            FT_Int     y_ppem,
                            FT_ULong  *astrike_index )
   {
-    FT_Int  i;
+    FT_ULong  i;
 
 
     if ( x_ppem < 0 || x_ppem > 255 ||
@@ -791,8 +791,8 @@
     TT_SBit_Strike  strike;
 
 
-    if ( !face->sbit_strikes                                ||
-         ( face->num_sbit_strikes <= (FT_Int)strike_index ) )
+    if ( !face->sbit_strikes                        ||
+         ( face->num_sbit_strikes <= strike_index ) )
       goto Fail;
 
     strike = &face->sbit_strikes[strike_index];
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index f519d31..0733d34 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -367,8 +367,8 @@
       return;
     }
 
-    ras.min_ex = ras.max_ex = vec->x;
-    ras.min_ey = ras.max_ey = vec->y;
+    ras.min_ex = ras.max_ex = (TCoord)vec->x;
+    ras.min_ey = ras.max_ey = (TCoord)vec->y;
 
     vec++;
 
@@ -378,10 +378,10 @@
       TPos  y = vec->y;
 
 
-      if ( x < ras.min_ex ) ras.min_ex = x;
-      if ( x > ras.max_ex ) ras.max_ex = x;
-      if ( y < ras.min_ey ) ras.min_ey = y;
-      if ( y > ras.max_ey ) ras.max_ey = y;
+      if ( x < ras.min_ex ) ras.min_ex = (TCoord)x;
+      if ( x > ras.max_ex ) ras.max_ex = (TCoord)x;
+      if ( y < ras.min_ey ) ras.min_ey = (TCoord)y;
+      if ( y > ras.max_ey ) ras.max_ey = (TCoord)y;
     }
 
     /* truncate the bounding box to integer pixels */
@@ -513,10 +513,10 @@
 
     dx = x2 - x1;
 
-    ex1 = TRUNC( x1 ); /* if (ex1 >= ras.max_ex) ex1 = ras.max_ex-1; */
-    ex2 = TRUNC( x2 ); /* if (ex2 >= ras.max_ex) ex2 = ras.max_ex-1; */
-    fx1 = x1 - SUBPIXELS( ex1 );
-    fx2 = x2 - SUBPIXELS( ex2 );
+    ex1 = (TCoord)TRUNC( x1 ); /* if (ex1 >= ras.max_ex) ex1 = ras.max_ex-1; */
+    ex2 = (TCoord)TRUNC( x2 ); /* if (ex2 >= ras.max_ex) ex2 = ras.max_ex-1; */
+    fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
+    fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
 
     /* trivial case.  Happens often */
     if ( y1 == y2 )
@@ -550,12 +550,12 @@
       dx    = -dx;
     }
 
-    delta = p / dx;
-    mod   = p % dx;
+    delta = (TCoord)( p / dx );
+    mod   = (TCoord)( p % dx );
     if ( mod < 0 )
     {
       delta--;
-      mod += dx;
+      mod += (TCoord)dx;
     }
 
     ras.area  += (TArea)( fx1 + first ) * delta;
@@ -568,12 +568,12 @@
     if ( ex1 != ex2 )
     {
       p     = ONE_PIXEL * ( y2 - y1 + delta );
-      lift  = p / dx;
-      rem   = p % dx;
+      lift  = (TCoord)( p / dx );
+      rem   = (TCoord)( p % dx );
       if ( rem < 0 )
       {
         lift--;
-        rem += dx;
+        rem += (TCoord)dx;
       }
 
       mod -= dx;
@@ -584,7 +584,7 @@
         mod  += rem;
         if ( mod >= 0 )
         {
-          mod -= dx;
+          mod -= (TCoord)dx;
           delta++;
         }
 
@@ -612,13 +612,14 @@
   {
     TCoord  ey1, ey2, fy1, fy2;
     TPos    dx, dy, x, x2;
-    int     p, rem, mod, lift, delta, first, incr;
+    long    p, first;
+    int     delta, rem, mod, lift, incr;
 
 
-    ey1 = TRUNC( ras.last_ey );
-    ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
-    fy1 = ras.y - ras.last_ey;
-    fy2 = to_y - SUBPIXELS( ey2 );
+    ey1 = (TCoord)TRUNC( ras.last_ey );
+    ey2 = (TCoord)TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
+    fy1 = (TCoord)( ras.y - ras.last_ey );
+    fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
 
     dx = to_x - ras.x;
     dy = to_y - ras.y;
@@ -654,8 +655,8 @@
 
     if ( dx == 0 )
     {
-      TCoord  ex     = TRUNC( ras.x );
-      TCoord  two_fx = ( ras.x - SUBPIXELS( ex ) ) << 1;
+      TCoord  ex     = (TCoord)TRUNC( ras.x );
+      TCoord  two_fx = (TCoord)( ( ras.x - SUBPIXELS( (TPos)ex ) ) << 1 );
       TPos    area;
 
 
@@ -666,16 +667,16 @@
         incr  = -1;
       }
 
-      delta      = first - fy1;
+      delta      = (int)( first - fy1 );
       ras.area  += (TArea)two_fx * delta;
       ras.cover += delta;
       ey1       += incr;
 
       gray_set_cell( raster, ex, ey1 );
 
-      delta = first + first - ONE_PIXEL;
+      delta = (int)( first + first - ONE_PIXEL );
       area  = (TArea)two_fx * delta;
-      while( ey1 != ey2 )
+      while ( ey1 != ey2 )
       {
         ras.area  += area;
         ras.cover += delta;
@@ -683,50 +684,50 @@
         gray_set_cell( raster, ex, ey1 );
       }
 
-      delta      = fy2 - ONE_PIXEL + first;
+      delta      = (int)( fy2 - ONE_PIXEL + first );
       ras.area  += (TArea)two_fx * delta;
       ras.cover += delta;
       goto End;
     }
 
     /* ok, we have to render several scanlines */
-    p     = ( ONE_PIXEL - fy1 ) * dx;
-    first = ONE_PIXEL;
+    p     = (int)( ( ONE_PIXEL - fy1 ) * dx );
+    first = (int)ONE_PIXEL;
     incr  = 1;
 
     if ( dy < 0 )
     {
-      p     = fy1 * dx;
+      p     = fy1 * (int)dx;
       first = 0;
       incr  = -1;
       dy    = -dy;
     }
 
-    delta = p / dy;
-    mod   = p % dy;
+    delta = (int)( p / dy );
+    mod   = (int)( p % dy );
     if ( mod < 0 )
     {
       delta--;
-      mod += dy;
+      mod += (TCoord)dy;
     }
 
     x = ras.x + delta;
     gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, first );
 
     ey1 += incr;
-    gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
+    gray_set_cell( RAS_VAR_ (TCoord)TRUNC( x ), ey1 );
 
     if ( ey1 != ey2 )
     {
-      p     = ONE_PIXEL * dx;
-      lift  = p / dy;
-      rem   = p % dy;
+      p     = (int)( ONE_PIXEL * dx );
+      lift  = (int)( p / dy );
+      rem   = (int)( p % dy );
       if ( rem < 0 )
       {
         lift--;
-        rem += dy;
+        rem += (int)dy;
       }
-      mod -= dy;
+      mod -= (int)dy;
 
       while ( ey1 != ey2 )
       {
@@ -734,12 +735,14 @@
         mod  += rem;
         if ( mod >= 0 )
         {
-          mod -= dy;
+          mod -= (int)dy;
           delta++;
         }
 
         x2 = x + delta;
-        gray_render_scanline( RAS_VAR_ ey1, x, ONE_PIXEL - first, x2, first );
+        gray_render_scanline( RAS_VAR_ ey1, x,
+                                       (TCoord)( ONE_PIXEL - first ), x2,
+                                       first );
         x = x2;
 
         ey1 += incr;
@@ -747,7 +750,9 @@
       }
     }
 
-    gray_render_scanline( RAS_VAR_ ey1, x, ONE_PIXEL - first, to_x, fy2 );
+    gray_render_scanline( RAS_VAR_ ey1, x,
+                                   (TCoord)( ONE_PIXEL - first ), to_x,
+                                   fy2 );
 
   End:
     ras.x       = to_x;
@@ -1237,7 +1242,8 @@
     x = UPSCALE( to->x );
     y = UPSCALE( to->y );
 
-    gray_start_cell( (PRaster)raster, TRUNC( x ), TRUNC( y ) );
+    gray_start_cell( (PRaster)raster,
+                     (TCoord)TRUNC( x ), (TCoord)TRUNC( y ) );
 
     ((PRaster)raster)->x = x;
     ((PRaster)raster)->y = y;
@@ -1361,8 +1367,8 @@
     /*                                                           */
     /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
     /*                                                           */
-    coverage = area >> ( PIXEL_BITS * 2 + 1 - 8);  /* use range 0..256 */
-
+    coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) );
+                                                    /* use range 0..256 */
     if ( coverage < 0 )
       coverage = -coverage;
 
@@ -1593,14 +1599,14 @@
     FT_Vector*  limit;
     char*       tags;
 
-    int     n;         /* index of contour in outline     */
-    int     first;     /* index of first point in contour */
-    int     error;
-    char    tag;       /* current point's state           */
+    int   n;         /* index of contour in outline     */
+    int   first;     /* index of first point in contour */
+    int   error;
+    char  tag;       /* current point's state           */
 
 #if 0
-    int     shift = func_interface->shift;
-    FT_Pos  delta = func_interface->delta;
+    int   shift = func_interface->shift;
+    TPos  delta = func_interface->delta;
 #endif
 
 
@@ -1784,7 +1790,7 @@
 
   typedef struct  TBand_
   {
-    FT_Pos  min, max;
+    TPos  min, max;
 
   } TBand;
 
@@ -1839,11 +1845,11 @@
          ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
       return 0;
 
-    if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin;
-    if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin;
+    if ( ras.min_ex < clip->xMin ) ras.min_ex = (TCoord)clip->xMin;
+    if ( ras.min_ey < clip->yMin ) ras.min_ey = (TCoord)clip->yMin;
 
-    if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax;
-    if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax;
+    if ( ras.max_ex > clip->xMax ) ras.max_ex = (TCoord)clip->xMax;
+    if ( ras.max_ey > clip->yMax ) ras.max_ey = (TCoord)clip->yMax;
 
     /* simple heuristic used to speed-up the bezier decomposition -- see */
     /* the code in gray_render_conic() and gray_render_cubic() for more  */
@@ -1886,14 +1892,14 @@
 
       while ( band >= bands )
       {
-        FT_Pos  bottom, top, middle;
-        int     error;
+        TPos  bottom, top, middle;
+        int   error;
 
 
         ras.num_cells = 0;
         ras.invalid   = 1;
-        ras.min_ey    = band->min;
-        ras.max_ey    = band->max;
+        ras.min_ey    = (TCoord)band->min;
+        ras.max_ey    = (TCoord)band->max;
 
 #if 1
         error = gray_convert_glyph_inner( RAS_VAR );
@@ -2136,7 +2142,7 @@
     if ( raster && pool_base && pool_size >= 4096 )
       gray_init_cells( rast, (char*)pool_base, pool_size );
 
-    rast->band_size  = ( pool_size / sizeof ( TCell ) ) / 8;
+    rast->band_size  = (int)( ( pool_size / sizeof ( TCell ) ) / 8 );
   }
 
 
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 199b94a..131b17e 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -218,8 +218,8 @@
       goto Exit;
 
     slot->format      = FT_GLYPH_FORMAT_BITMAP;
-    slot->bitmap_left = cbox.xMin >> 6;
-    slot->bitmap_top  = cbox.yMax >> 6;
+    slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 );
+    slot->bitmap_top  = (FT_Int)( cbox.yMax >> 6 );
 
   Exit:
     if ( outline && origin )