OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* pshrec.c */ | 3 /* pshrec.c */ |
4 /* */ | 4 /* */ |
5 /* FreeType PostScript hints recorder (body). */ | 5 /* FreeType PostScript hints recorder (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2001, 2002, 2003, 2004, 2007, 2009 by */ | 7 /* Copyright 2001-2004, 2007, 2009, 2013 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 | 58 |
59 /* ensure that a table can contain "count" elements */ | 59 /* ensure that a table can contain "count" elements */ |
60 static FT_Error | 60 static FT_Error |
61 ps_hint_table_ensure( PS_Hint_Table table, | 61 ps_hint_table_ensure( PS_Hint_Table table, |
62 FT_UInt count, | 62 FT_UInt count, |
63 FT_Memory memory ) | 63 FT_Memory memory ) |
64 { | 64 { |
65 FT_UInt old_max = table->max_hints; | 65 FT_UInt old_max = table->max_hints; |
66 FT_UInt new_max = count; | 66 FT_UInt new_max = count; |
67 FT_Error error = PSH_Err_Ok; | 67 FT_Error error = FT_Err_Ok; |
68 | 68 |
69 | 69 |
70 if ( new_max > old_max ) | 70 if ( new_max > old_max ) |
71 { | 71 { |
72 /* try to grow the table */ | 72 /* try to grow the table */ |
73 new_max = FT_PAD_CEIL( new_max, 8 ); | 73 new_max = FT_PAD_CEIL( new_max, 8 ); |
74 if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) ) | 74 if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) ) |
75 table->max_hints = new_max; | 75 table->max_hints = new_max; |
76 } | 76 } |
77 return error; | 77 return error; |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 static FT_Error | 81 static FT_Error |
82 ps_hint_table_alloc( PS_Hint_Table table, | 82 ps_hint_table_alloc( PS_Hint_Table table, |
83 FT_Memory memory, | 83 FT_Memory memory, |
84 PS_Hint *ahint ) | 84 PS_Hint *ahint ) |
85 { | 85 { |
86 FT_Error error = PSH_Err_Ok; | 86 FT_Error error = FT_Err_Ok; |
87 FT_UInt count; | 87 FT_UInt count; |
88 PS_Hint hint = 0; | 88 PS_Hint hint = 0; |
89 | 89 |
90 | 90 |
91 count = table->num_hints; | 91 count = table->num_hints; |
92 count++; | 92 count++; |
93 | 93 |
94 if ( count >= table->max_hints ) | 94 if ( count >= table->max_hints ) |
95 { | 95 { |
96 error = ps_hint_table_ensure( table, count, memory ); | 96 error = ps_hint_table_ensure( table, count, memory ); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 | 133 |
134 /* ensure that a mask can contain "count" bits */ | 134 /* ensure that a mask can contain "count" bits */ |
135 static FT_Error | 135 static FT_Error |
136 ps_mask_ensure( PS_Mask mask, | 136 ps_mask_ensure( PS_Mask mask, |
137 FT_UInt count, | 137 FT_UInt count, |
138 FT_Memory memory ) | 138 FT_Memory memory ) |
139 { | 139 { |
140 FT_UInt old_max = ( mask->max_bits + 7 ) >> 3; | 140 FT_UInt old_max = ( mask->max_bits + 7 ) >> 3; |
141 FT_UInt new_max = ( count + 7 ) >> 3; | 141 FT_UInt new_max = ( count + 7 ) >> 3; |
142 FT_Error error = PSH_Err_Ok; | 142 FT_Error error = FT_Err_Ok; |
143 | 143 |
144 | 144 |
145 if ( new_max > old_max ) | 145 if ( new_max > old_max ) |
146 { | 146 { |
147 new_max = FT_PAD_CEIL( new_max, 8 ); | 147 new_max = FT_PAD_CEIL( new_max, 8 ); |
148 if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) ) | 148 if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) ) |
149 mask->max_bits = new_max * 8; | 149 mask->max_bits = new_max * 8; |
150 } | 150 } |
151 return error; | 151 return error; |
152 } | 152 } |
(...skipping 26 matching lines...) Expand all Loading... |
179 p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) ); | 179 p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) ); |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 /* set a given bit, possibly grow the mask */ | 183 /* set a given bit, possibly grow the mask */ |
184 static FT_Error | 184 static FT_Error |
185 ps_mask_set_bit( PS_Mask mask, | 185 ps_mask_set_bit( PS_Mask mask, |
186 FT_Int idx, | 186 FT_Int idx, |
187 FT_Memory memory ) | 187 FT_Memory memory ) |
188 { | 188 { |
189 FT_Error error = PSH_Err_Ok; | 189 FT_Error error = FT_Err_Ok; |
190 FT_Byte* p; | 190 FT_Byte* p; |
191 | 191 |
192 | 192 |
193 if ( idx < 0 ) | 193 if ( idx < 0 ) |
194 goto Exit; | 194 goto Exit; |
195 | 195 |
196 if ( (FT_UInt)idx >= mask->num_bits ) | 196 if ( (FT_UInt)idx >= mask->num_bits ) |
197 { | 197 { |
198 error = ps_mask_ensure( mask, idx + 1, memory ); | 198 error = ps_mask_ensure( mask, idx + 1, memory ); |
199 if ( error ) | 199 if ( error ) |
(...skipping 29 matching lines...) Expand all Loading... |
229 | 229 |
230 | 230 |
231 /* ensure that a mask table can contain "count" masks */ | 231 /* ensure that a mask table can contain "count" masks */ |
232 static FT_Error | 232 static FT_Error |
233 ps_mask_table_ensure( PS_Mask_Table table, | 233 ps_mask_table_ensure( PS_Mask_Table table, |
234 FT_UInt count, | 234 FT_UInt count, |
235 FT_Memory memory ) | 235 FT_Memory memory ) |
236 { | 236 { |
237 FT_UInt old_max = table->max_masks; | 237 FT_UInt old_max = table->max_masks; |
238 FT_UInt new_max = count; | 238 FT_UInt new_max = count; |
239 FT_Error error = PSH_Err_Ok; | 239 FT_Error error = FT_Err_Ok; |
240 | 240 |
241 | 241 |
242 if ( new_max > old_max ) | 242 if ( new_max > old_max ) |
243 { | 243 { |
244 new_max = FT_PAD_CEIL( new_max, 8 ); | 244 new_max = FT_PAD_CEIL( new_max, 8 ); |
245 if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) ) | 245 if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) ) |
246 table->max_masks = new_max; | 246 table->max_masks = new_max; |
247 } | 247 } |
248 return error; | 248 return error; |
249 } | 249 } |
250 | 250 |
251 | 251 |
252 /* allocate a new mask in a table */ | 252 /* allocate a new mask in a table */ |
253 static FT_Error | 253 static FT_Error |
254 ps_mask_table_alloc( PS_Mask_Table table, | 254 ps_mask_table_alloc( PS_Mask_Table table, |
255 FT_Memory memory, | 255 FT_Memory memory, |
256 PS_Mask *amask ) | 256 PS_Mask *amask ) |
257 { | 257 { |
258 FT_UInt count; | 258 FT_UInt count; |
259 FT_Error error = PSH_Err_Ok; | 259 FT_Error error = FT_Err_Ok; |
260 PS_Mask mask = 0; | 260 PS_Mask mask = 0; |
261 | 261 |
262 | 262 |
263 count = table->num_masks; | 263 count = table->num_masks; |
264 count++; | 264 count++; |
265 | 265 |
266 if ( count > table->max_masks ) | 266 if ( count > table->max_masks ) |
267 { | 267 { |
268 error = ps_mask_table_ensure( table, count, memory ); | 268 error = ps_mask_table_ensure( table, count, memory ); |
269 if ( error ) | 269 if ( error ) |
(...skipping 10 matching lines...) Expand all Loading... |
280 return error; | 280 return error; |
281 } | 281 } |
282 | 282 |
283 | 283 |
284 /* return last hint mask in a table, create one if the table is empty */ | 284 /* return last hint mask in a table, create one if the table is empty */ |
285 static FT_Error | 285 static FT_Error |
286 ps_mask_table_last( PS_Mask_Table table, | 286 ps_mask_table_last( PS_Mask_Table table, |
287 FT_Memory memory, | 287 FT_Memory memory, |
288 PS_Mask *amask ) | 288 PS_Mask *amask ) |
289 { | 289 { |
290 FT_Error error = PSH_Err_Ok; | 290 FT_Error error = FT_Err_Ok; |
291 FT_UInt count; | 291 FT_UInt count; |
292 PS_Mask mask; | 292 PS_Mask mask; |
293 | 293 |
294 | 294 |
295 count = table->num_masks; | 295 count = table->num_masks; |
296 if ( count == 0 ) | 296 if ( count == 0 ) |
297 { | 297 { |
298 error = ps_mask_table_alloc( table, memory, &mask ); | 298 error = ps_mask_table_alloc( table, memory, &mask ); |
299 if ( error ) | 299 if ( error ) |
300 goto Exit; | 300 goto Exit; |
301 } | 301 } |
302 else | 302 else |
303 mask = table->masks + count - 1; | 303 mask = table->masks + count - 1; |
304 | 304 |
305 Exit: | 305 Exit: |
306 *amask = mask; | 306 *amask = mask; |
307 return error; | 307 return error; |
308 } | 308 } |
309 | 309 |
310 | 310 |
311 /* set a new mask to a given bit range */ | 311 /* set a new mask to a given bit range */ |
312 static FT_Error | 312 static FT_Error |
313 ps_mask_table_set_bits( PS_Mask_Table table, | 313 ps_mask_table_set_bits( PS_Mask_Table table, |
314 const FT_Byte* source, | 314 const FT_Byte* source, |
315 FT_UInt bit_pos, | 315 FT_UInt bit_pos, |
316 FT_UInt bit_count, | 316 FT_UInt bit_count, |
317 FT_Memory memory ) | 317 FT_Memory memory ) |
318 { | 318 { |
319 FT_Error error = PSH_Err_Ok; | 319 FT_Error error; |
320 PS_Mask mask; | 320 PS_Mask mask; |
321 | 321 |
322 | 322 |
323 error = ps_mask_table_last( table, memory, &mask ); | 323 error = ps_mask_table_last( table, memory, &mask ); |
324 if ( error ) | 324 if ( error ) |
325 goto Exit; | 325 goto Exit; |
326 | 326 |
327 error = ps_mask_ensure( mask, bit_count, memory ); | 327 error = ps_mask_ensure( mask, bit_count, memory ); |
328 if ( error ) | 328 if ( error ) |
329 goto Exit; | 329 goto Exit; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 { | 377 { |
378 PS_Mask mask1 = table->masks + index1; | 378 PS_Mask mask1 = table->masks + index1; |
379 PS_Mask mask2 = table->masks + index2; | 379 PS_Mask mask2 = table->masks + index2; |
380 FT_Byte* p1 = mask1->bytes; | 380 FT_Byte* p1 = mask1->bytes; |
381 FT_Byte* p2 = mask2->bytes; | 381 FT_Byte* p2 = mask2->bytes; |
382 FT_UInt count1 = mask1->num_bits; | 382 FT_UInt count1 = mask1->num_bits; |
383 FT_UInt count2 = mask2->num_bits; | 383 FT_UInt count2 = mask2->num_bits; |
384 FT_UInt count; | 384 FT_UInt count; |
385 | 385 |
386 | 386 |
387 count = ( count1 <= count2 ) ? count1 : count2; | 387 count = FT_MIN( count1, count2 ); |
388 for ( ; count >= 8; count -= 8 ) | 388 for ( ; count >= 8; count -= 8 ) |
389 { | 389 { |
390 if ( p1[0] & p2[0] ) | 390 if ( p1[0] & p2[0] ) |
391 return 1; | 391 return 1; |
392 | 392 |
393 p1++; | 393 p1++; |
394 p2++; | 394 p2++; |
395 } | 395 } |
396 | 396 |
397 if ( count == 0 ) | 397 if ( count == 0 ) |
398 return 0; | 398 return 0; |
399 | 399 |
400 return ( p1[0] & p2[0] ) & ~( 0xFF >> count ); | 400 return ( p1[0] & p2[0] ) & ~( 0xFF >> count ); |
401 } | 401 } |
402 | 402 |
403 | 403 |
404 /* merge two masks, used by ps_mask_table_merge_all */ | 404 /* merge two masks, used by ps_mask_table_merge_all */ |
405 static FT_Error | 405 static FT_Error |
406 ps_mask_table_merge( PS_Mask_Table table, | 406 ps_mask_table_merge( PS_Mask_Table table, |
407 FT_Int index1, | 407 FT_Int index1, |
408 FT_Int index2, | 408 FT_Int index2, |
409 FT_Memory memory ) | 409 FT_Memory memory ) |
410 { | 410 { |
411 FT_UInt temp; | 411 FT_UInt temp; |
412 FT_Error error = PSH_Err_Ok; | 412 FT_Error error = FT_Err_Ok; |
413 | 413 |
414 | 414 |
415 /* swap index1 and index2 so that index1 < index2 */ | 415 /* swap index1 and index2 so that index1 < index2 */ |
416 if ( index1 > index2 ) | 416 if ( index1 > index2 ) |
417 { | 417 { |
418 temp = index1; | 418 temp = index1; |
419 index1 = index2; | 419 index1 = index2; |
420 index2 = temp; | 420 index2 = temp; |
421 } | 421 } |
422 | 422 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 | 493 |
494 /* Try to merge all masks in a given table. This is used to merge */ | 494 /* Try to merge all masks in a given table. This is used to merge */ |
495 /* all counter masks into independent counter "paths". */ | 495 /* all counter masks into independent counter "paths". */ |
496 /* */ | 496 /* */ |
497 static FT_Error | 497 static FT_Error |
498 ps_mask_table_merge_all( PS_Mask_Table table, | 498 ps_mask_table_merge_all( PS_Mask_Table table, |
499 FT_Memory memory ) | 499 FT_Memory memory ) |
500 { | 500 { |
501 FT_Int index1, index2; | 501 FT_Int index1, index2; |
502 FT_Error error = PSH_Err_Ok; | 502 FT_Error error = FT_Err_Ok; |
503 | 503 |
504 | 504 |
505 for ( index1 = table->num_masks - 1; index1 > 0; index1-- ) | 505 for ( index1 = table->num_masks - 1; index1 > 0; index1-- ) |
506 { | 506 { |
507 for ( index2 = index1 - 1; index2 >= 0; index2-- ) | 507 for ( index2 = index1 - 1; index2 >= 0; index2-- ) |
508 { | 508 { |
509 if ( ps_mask_table_test_intersect( table, index1, index2 ) ) | 509 if ( ps_mask_table_test_intersect( table, index1, index2 ) ) |
510 { | 510 { |
511 error = ps_mask_table_merge( table, index2, index1, memory ); | 511 error = ps_mask_table_merge( table, index2, index1, memory ); |
512 if ( error ) | 512 if ( error ) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 554 |
555 #if 0 | 555 #if 0 |
556 | 556 |
557 /* set a bit at a given index in the current hint mask */ | 557 /* set a bit at a given index in the current hint mask */ |
558 static FT_Error | 558 static FT_Error |
559 ps_dimension_set_mask_bit( PS_Dimension dim, | 559 ps_dimension_set_mask_bit( PS_Dimension dim, |
560 FT_UInt idx, | 560 FT_UInt idx, |
561 FT_Memory memory ) | 561 FT_Memory memory ) |
562 { | 562 { |
563 PS_Mask mask; | 563 PS_Mask mask; |
564 FT_Error error = PSH_Err_Ok; | 564 FT_Error error = FT_Err_Ok; |
565 | 565 |
566 | 566 |
567 /* get last hint mask */ | 567 /* get last hint mask */ |
568 error = ps_mask_table_last( &dim->masks, memory, &mask ); | 568 error = ps_mask_table_last( &dim->masks, memory, &mask ); |
569 if ( error ) | 569 if ( error ) |
570 goto Exit; | 570 goto Exit; |
571 | 571 |
572 error = ps_mask_set_bit( mask, idx, memory ); | 572 error = ps_mask_set_bit( mask, idx, memory ); |
573 | 573 |
574 Exit: | 574 Exit: |
575 return error; | 575 return error; |
576 } | 576 } |
577 | 577 |
578 #endif | 578 #endif |
579 | 579 |
580 /* set the end point in a mask, called from "End" & "Reset" methods */ | 580 /* set the end point in a mask, called from "End" & "Reset" methods */ |
581 static void | 581 static void |
582 ps_dimension_end_mask( PS_Dimension dim, | 582 ps_dimension_end_mask( PS_Dimension dim, |
583 FT_UInt end_point ) | 583 FT_UInt end_point ) |
584 { | 584 { |
585 FT_UInt count = dim->masks.num_masks; | 585 FT_UInt count = dim->masks.num_masks; |
586 PS_Mask mask; | |
587 | 586 |
588 | 587 |
589 if ( count > 0 ) | 588 if ( count > 0 ) |
590 { | 589 { |
591 mask = dim->masks.masks + count - 1; | 590 PS_Mask mask = dim->masks.masks + count - 1; |
| 591 |
| 592 |
592 mask->end_point = end_point; | 593 mask->end_point = end_point; |
593 } | 594 } |
594 } | 595 } |
595 | 596 |
596 | 597 |
597 /* set the end point in the current mask, then create a new empty one */ | 598 /* set the end point in the current mask, then create a new empty one */ |
598 /* (called by "Reset" method) */ | 599 /* (called by "Reset" method) */ |
599 static FT_Error | 600 static FT_Error |
600 ps_dimension_reset_mask( PS_Dimension dim, | 601 ps_dimension_reset_mask( PS_Dimension dim, |
601 FT_UInt end_point, | 602 FT_UInt end_point, |
(...skipping 12 matching lines...) Expand all Loading... |
614 | 615 |
615 /* set a new mask, called from the "T2Stem" method */ | 616 /* set a new mask, called from the "T2Stem" method */ |
616 static FT_Error | 617 static FT_Error |
617 ps_dimension_set_mask_bits( PS_Dimension dim, | 618 ps_dimension_set_mask_bits( PS_Dimension dim, |
618 const FT_Byte* source, | 619 const FT_Byte* source, |
619 FT_UInt source_pos, | 620 FT_UInt source_pos, |
620 FT_UInt source_bits, | 621 FT_UInt source_bits, |
621 FT_UInt end_point, | 622 FT_UInt end_point, |
622 FT_Memory memory ) | 623 FT_Memory memory ) |
623 { | 624 { |
624 FT_Error error = PSH_Err_Ok; | 625 FT_Error error; |
625 | 626 |
626 | 627 |
627 /* reset current mask, if any */ | 628 /* reset current mask, if any */ |
628 error = ps_dimension_reset_mask( dim, end_point, memory ); | 629 error = ps_dimension_reset_mask( dim, end_point, memory ); |
629 if ( error ) | 630 if ( error ) |
630 goto Exit; | 631 goto Exit; |
631 | 632 |
632 /* set bits in new mask */ | 633 /* set bits in new mask */ |
633 error = ps_mask_table_set_bits( &dim->masks, source, | 634 error = ps_mask_table_set_bits( &dim->masks, source, |
634 source_pos, source_bits, memory ); | 635 source_pos, source_bits, memory ); |
635 | 636 |
636 Exit: | 637 Exit: |
637 return error; | 638 return error; |
638 } | 639 } |
639 | 640 |
640 | 641 |
641 /* add a new single stem (called from "T1Stem" method) */ | 642 /* add a new single stem (called from "T1Stem" method) */ |
642 static FT_Error | 643 static FT_Error |
643 ps_dimension_add_t1stem( PS_Dimension dim, | 644 ps_dimension_add_t1stem( PS_Dimension dim, |
644 FT_Int pos, | 645 FT_Int pos, |
645 FT_Int len, | 646 FT_Int len, |
646 FT_Memory memory, | 647 FT_Memory memory, |
647 FT_Int *aindex ) | 648 FT_Int *aindex ) |
648 { | 649 { |
649 FT_Error error = PSH_Err_Ok; | 650 FT_Error error = FT_Err_Ok; |
650 FT_UInt flags = 0; | 651 FT_UInt flags = 0; |
651 | 652 |
652 | 653 |
653 /* detect ghost stem */ | 654 /* detect ghost stem */ |
654 if ( len < 0 ) | 655 if ( len < 0 ) |
655 { | 656 { |
656 flags |= PS_HINT_FLAG_GHOST; | 657 flags |= PS_HINT_FLAG_GHOST; |
657 if ( len == -21 ) | 658 if ( len == -21 ) |
658 { | 659 { |
659 flags |= PS_HINT_FLAG_BOTTOM; | 660 flags |= PS_HINT_FLAG_BOTTOM; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 711 |
711 | 712 |
712 /* add a "hstem3/vstem3" counter to our dimension table */ | 713 /* add a "hstem3/vstem3" counter to our dimension table */ |
713 static FT_Error | 714 static FT_Error |
714 ps_dimension_add_counter( PS_Dimension dim, | 715 ps_dimension_add_counter( PS_Dimension dim, |
715 FT_Int hint1, | 716 FT_Int hint1, |
716 FT_Int hint2, | 717 FT_Int hint2, |
717 FT_Int hint3, | 718 FT_Int hint3, |
718 FT_Memory memory ) | 719 FT_Memory memory ) |
719 { | 720 { |
720 FT_Error error = PSH_Err_Ok; | 721 FT_Error error = FT_Err_Ok; |
721 FT_UInt count = dim->counters.num_masks; | 722 FT_UInt count = dim->counters.num_masks; |
722 PS_Mask counter = dim->counters.masks; | 723 PS_Mask counter = dim->counters.masks; |
723 | 724 |
724 | 725 |
725 /* try to find an existing counter mask that already uses */ | 726 /* try to find an existing counter mask that already uses */ |
726 /* one of these stems here */ | 727 /* one of these stems here */ |
727 for ( ; count > 0; count--, counter++ ) | 728 for ( ; count > 0; count--, counter++ ) |
728 { | 729 { |
729 if ( ps_mask_test_bit( counter, hint1 ) || | 730 if ( ps_mask_test_bit( counter, hint1 ) || |
730 ps_mask_test_bit( counter, hint2 ) || | 731 ps_mask_test_bit( counter, hint2 ) || |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 /* destroy hints */ | 785 /* destroy hints */ |
785 FT_LOCAL( void ) | 786 FT_LOCAL( void ) |
786 ps_hints_done( PS_Hints hints ) | 787 ps_hints_done( PS_Hints hints ) |
787 { | 788 { |
788 FT_Memory memory = hints->memory; | 789 FT_Memory memory = hints->memory; |
789 | 790 |
790 | 791 |
791 ps_dimension_done( &hints->dimension[0], memory ); | 792 ps_dimension_done( &hints->dimension[0], memory ); |
792 ps_dimension_done( &hints->dimension[1], memory ); | 793 ps_dimension_done( &hints->dimension[1], memory ); |
793 | 794 |
794 hints->error = PSH_Err_Ok; | 795 hints->error = FT_Err_Ok; |
795 hints->memory = 0; | 796 hints->memory = 0; |
796 } | 797 } |
797 | 798 |
798 | 799 |
799 FT_LOCAL( FT_Error ) | 800 FT_LOCAL( FT_Error ) |
800 ps_hints_init( PS_Hints hints, | 801 ps_hints_init( PS_Hints hints, |
801 FT_Memory memory ) | 802 FT_Memory memory ) |
802 { | 803 { |
803 FT_MEM_ZERO( hints, sizeof ( *hints ) ); | 804 FT_MEM_ZERO( hints, sizeof ( *hints ) ); |
804 hints->memory = memory; | 805 hints->memory = memory; |
805 return PSH_Err_Ok; | 806 return FT_Err_Ok; |
806 } | 807 } |
807 | 808 |
808 | 809 |
809 /* initialize a hints for a new session */ | 810 /* initialize a hints for a new session */ |
810 static void | 811 static void |
811 ps_hints_open( PS_Hints hints, | 812 ps_hints_open( PS_Hints hints, |
812 PS_Hint_Type hint_type ) | 813 PS_Hint_Type hint_type ) |
813 { | 814 { |
814 switch ( hint_type ) | 815 switch ( hint_type ) |
815 { | 816 { |
816 case PS_HINT_TYPE_1: | 817 case PS_HINT_TYPE_1: |
817 case PS_HINT_TYPE_2: | 818 case PS_HINT_TYPE_2: |
818 hints->error = PSH_Err_Ok; | 819 hints->error = FT_Err_Ok; |
819 hints->hint_type = hint_type; | 820 hints->hint_type = hint_type; |
820 | 821 |
821 ps_dimension_init( &hints->dimension[0] ); | 822 ps_dimension_init( &hints->dimension[0] ); |
822 ps_dimension_init( &hints->dimension[1] ); | 823 ps_dimension_init( &hints->dimension[1] ); |
823 break; | 824 break; |
824 | 825 |
825 default: | 826 default: |
826 hints->error = PSH_Err_Invalid_Argument; | 827 hints->error = FT_THROW( Invalid_Argument ); |
827 hints->hint_type = hint_type; | 828 hints->hint_type = hint_type; |
828 | 829 |
829 FT_TRACE0(( "ps_hints_open: invalid charstring type\n" )); | 830 FT_TRACE0(( "ps_hints_open: invalid charstring type\n" )); |
830 break; | 831 break; |
831 } | 832 } |
832 } | 833 } |
833 | 834 |
834 | 835 |
835 /* add one or more stems to the current hints table */ | 836 /* add one or more stems to the current hints table */ |
836 static void | 837 static void |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 } | 888 } |
888 } | 889 } |
889 | 890 |
890 | 891 |
891 /* add one Type1 counter stem to the current hints table */ | 892 /* add one Type1 counter stem to the current hints table */ |
892 static void | 893 static void |
893 ps_hints_t1stem3( PS_Hints hints, | 894 ps_hints_t1stem3( PS_Hints hints, |
894 FT_Int dimension, | 895 FT_Int dimension, |
895 FT_Fixed* stems ) | 896 FT_Fixed* stems ) |
896 { | 897 { |
897 FT_Error error = PSH_Err_Ok; | 898 FT_Error error = FT_Err_Ok; |
898 | 899 |
899 | 900 |
900 if ( !hints->error ) | 901 if ( !hints->error ) |
901 { | 902 { |
902 PS_Dimension dim; | 903 PS_Dimension dim; |
903 FT_Memory memory = hints->memory; | 904 FT_Memory memory = hints->memory; |
904 FT_Int count; | 905 FT_Int count; |
905 FT_Int idx[3]; | 906 FT_Int idx[3]; |
906 | 907 |
907 | 908 |
(...skipping 23 matching lines...) Expand all Loading... |
931 | 932 |
932 /* now, add the hints to the counters table */ | 933 /* now, add the hints to the counters table */ |
933 error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2], | 934 error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2], |
934 memory ); | 935 memory ); |
935 if ( error ) | 936 if ( error ) |
936 goto Fail; | 937 goto Fail; |
937 } | 938 } |
938 else | 939 else |
939 { | 940 { |
940 FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" )); | 941 FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" )); |
941 error = PSH_Err_Invalid_Argument; | 942 error = FT_THROW( Invalid_Argument ); |
942 goto Fail; | 943 goto Fail; |
943 } | 944 } |
944 } | 945 } |
945 | 946 |
946 return; | 947 return; |
947 | 948 |
948 Fail: | 949 Fail: |
949 FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" )); | 950 FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" )); |
950 hints->error = error; | 951 hints->error = error; |
951 } | 952 } |
952 | 953 |
953 | 954 |
954 /* reset hints (only with Type 1 hints) */ | 955 /* reset hints (only with Type 1 hints) */ |
955 static void | 956 static void |
956 ps_hints_t1reset( PS_Hints hints, | 957 ps_hints_t1reset( PS_Hints hints, |
957 FT_UInt end_point ) | 958 FT_UInt end_point ) |
958 { | 959 { |
959 FT_Error error = PSH_Err_Ok; | 960 FT_Error error = FT_Err_Ok; |
960 | 961 |
961 | 962 |
962 if ( !hints->error ) | 963 if ( !hints->error ) |
963 { | 964 { |
964 FT_Memory memory = hints->memory; | 965 FT_Memory memory = hints->memory; |
965 | 966 |
966 | 967 |
967 if ( hints->hint_type == PS_HINT_TYPE_1 ) | 968 if ( hints->hint_type == PS_HINT_TYPE_1 ) |
968 { | 969 { |
969 error = ps_dimension_reset_mask( &hints->dimension[0], | 970 error = ps_dimension_reset_mask( &hints->dimension[0], |
970 end_point, memory ); | 971 end_point, memory ); |
971 if ( error ) | 972 if ( error ) |
972 goto Fail; | 973 goto Fail; |
973 | 974 |
974 error = ps_dimension_reset_mask( &hints->dimension[1], | 975 error = ps_dimension_reset_mask( &hints->dimension[1], |
975 end_point, memory ); | 976 end_point, memory ); |
976 if ( error ) | 977 if ( error ) |
977 goto Fail; | 978 goto Fail; |
978 } | 979 } |
979 else | 980 else |
980 { | 981 { |
981 /* invalid hint type */ | 982 /* invalid hint type */ |
982 error = PSH_Err_Invalid_Argument; | 983 error = FT_THROW( Invalid_Argument ); |
983 goto Fail; | 984 goto Fail; |
984 } | 985 } |
985 } | 986 } |
986 return; | 987 return; |
987 | 988 |
988 Fail: | 989 Fail: |
989 hints->error = error; | 990 hints->error = error; |
990 } | 991 } |
991 | 992 |
992 | 993 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 funcs->open = (T2_Hints_OpenFunc) t2_hints_open; | 1216 funcs->open = (T2_Hints_OpenFunc) t2_hints_open; |
1216 funcs->close = (T2_Hints_CloseFunc) ps_hints_close; | 1217 funcs->close = (T2_Hints_CloseFunc) ps_hints_close; |
1217 funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems; | 1218 funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems; |
1218 funcs->hintmask= (T2_Hints_MaskFunc) ps_hints_t2mask; | 1219 funcs->hintmask= (T2_Hints_MaskFunc) ps_hints_t2mask; |
1219 funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter; | 1220 funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter; |
1220 funcs->apply = (T2_Hints_ApplyFunc) ps_hints_apply; | 1221 funcs->apply = (T2_Hints_ApplyFunc) ps_hints_apply; |
1221 } | 1222 } |
1222 | 1223 |
1223 | 1224 |
1224 /* END */ | 1225 /* END */ |
OLD | NEW |