Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/freetype/src/truetype/ttgload.c

Issue 1413673003: Update bundled freetype to 2.6.1 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: DEPS for corpus Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* ttgload.c */ 3 /* ttgload.c */
4 /* */ 4 /* */
5 /* TrueType Glyph Loader (body). */ 5 /* TrueType Glyph Loader (body). */
6 /* */ 6 /* */
7 /* Copyright 1996-2014 */ 7 /* Copyright 1996-2015 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 FT_Pos yMax, 93 FT_Pos yMax,
94 FT_Short* tsb, 94 FT_Short* tsb,
95 FT_UShort* ah ) 95 FT_UShort* ah )
96 { 96 {
97 if ( face->vertical_info ) 97 if ( face->vertical_info )
98 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah ); 98 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
99 99
100 else if ( face->os2.version != 0xFFFFU ) 100 else if ( face->os2.version != 0xFFFFU )
101 { 101 {
102 *tsb = (FT_Short)( face->os2.sTypoAscender - yMax ); 102 *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
103 *ah = face->os2.sTypoAscender - face->os2.sTypoDescender; 103 *ah = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
104 face->os2.sTypoDescender );
104 } 105 }
105 106
106 else 107 else
107 { 108 {
108 *tsb = (FT_Short)( face->horizontal.Ascender - yMax ); 109 *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
109 *ah = face->horizontal.Ascender - face->horizontal.Descender; 110 *ah = (FT_UShort)FT_ABS( face->horizontal.Ascender -
111 face->horizontal.Descender );
110 } 112 }
111 113
112 FT_TRACE5(( " advance height (font units): %d\n", *ah )); 114 FT_TRACE5(( " advance height (font units): %d\n", *ah ));
113 FT_TRACE5(( " top side bearing (font units): %d\n", *tsb )); 115 FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
114 } 116 }
115 117
116 118
117 static FT_Error 119 static FT_Error
118 tt_get_metrics( TT_Loader loader, 120 tt_get_metrics( TT_Loader loader,
119 FT_UInt glyph_index ) 121 FT_UInt glyph_index )
120 { 122 {
121 TT_Face face = (TT_Face)loader->face; 123 TT_Face face = loader->face;
122 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 124 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
123 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); 125 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
124 #endif 126 #endif
125 127
126 FT_Error error; 128 FT_Error error;
127 FT_Stream stream = loader->stream; 129 FT_Stream stream = loader->stream;
128 130
129 FT_Short left_bearing = 0, top_bearing = 0; 131 FT_Short left_bearing = 0, top_bearing = 0;
130 FT_UShort advance_width = 0, advance_height = 0; 132 FT_UShort advance_width = 0, advance_height = 0;
131 133
(...skipping 12 matching lines...) Expand all
144 146
145 if ( FT_STREAM_SEEK( pos ) ) 147 if ( FT_STREAM_SEEK( pos ) )
146 return error; 148 return error;
147 149
148 loader->left_bearing = left_bearing; 150 loader->left_bearing = left_bearing;
149 loader->advance = advance_width; 151 loader->advance = advance_width;
150 loader->top_bearing = top_bearing; 152 loader->top_bearing = top_bearing;
151 loader->vadvance = advance_height; 153 loader->vadvance = advance_height;
152 154
153 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 155 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
154 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 ) 156 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 &&
157 loader->exec )
155 { 158 {
156 if ( loader->exec ) 159 loader->exec->sph_tweak_flags = 0;
157 loader->exec->sph_tweak_flags = 0;
158 160
159 /* this may not be the right place for this, but it works */ 161 /* This may not be the right place for this, but it works... */
160 if ( loader->exec && loader->exec->ignore_x_mode ) 162 /* Note that we have to unconditionally load the tweaks since */
161 sph_set_tweaks( loader, glyph_index ); 163 /* it is possible that glyphs individually switch ClearType's */
164 /* backwards compatibility mode on and off. */
165 sph_set_tweaks( loader, glyph_index );
162 } 166 }
163 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ 167 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
164 168
165 if ( !loader->linear_def ) 169 if ( !loader->linear_def )
166 { 170 {
167 loader->linear_def = 1; 171 loader->linear_def = 1;
168 loader->linear = advance_width; 172 loader->linear = advance_width;
169 } 173 }
170 174
171 return FT_Err_Ok; 175 return FT_Err_Ok;
172 } 176 }
173 177
174 178
175 #ifdef FT_CONFIG_OPTION_INCREMENTAL 179 #ifdef FT_CONFIG_OPTION_INCREMENTAL
176 180
177 static void 181 static void
178 tt_get_metrics_incr_overrides( TT_Loader loader, 182 tt_get_metrics_incr_overrides( TT_Loader loader,
179 FT_UInt glyph_index ) 183 FT_UInt glyph_index )
180 { 184 {
181 TT_Face face = (TT_Face)loader->face; 185 TT_Face face = loader->face;
182 186
183 FT_Short left_bearing = 0, top_bearing = 0; 187 FT_Short left_bearing = 0, top_bearing = 0;
184 FT_UShort advance_width = 0, advance_height = 0; 188 FT_UShort advance_width = 0, advance_height = 0;
185 189
186 190
187 /* If this is an incrementally loaded font check whether there are */ 191 /* If this is an incrementally loaded font check whether there are */
188 /* overriding metrics for this glyph. */ 192 /* overriding metrics for this glyph. */
189 if ( face->root.internal->incremental_interface && 193 if ( face->root.internal->incremental_interface &&
190 face->root.internal->incremental_interface->funcs->get_glyph_metrics ) 194 face->root.internal->incremental_interface->funcs->get_glyph_metrics )
191 { 195 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 243
240 Exit: 244 Exit:
241 return; 245 return;
242 } 246 }
243 247
244 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ 248 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
245 249
246 250
247 /*************************************************************************/ 251 /*************************************************************************/
248 /* */ 252 /* */
249 /* Translates an array of coordinates. */
250 /* */
251 static void
252 translate_array( FT_UInt n,
253 FT_Vector* coords,
254 FT_Pos delta_x,
255 FT_Pos delta_y )
256 {
257 FT_UInt k;
258
259
260 if ( delta_x )
261 for ( k = 0; k < n; k++ )
262 coords[k].x += delta_x;
263
264 if ( delta_y )
265 for ( k = 0; k < n; k++ )
266 coords[k].y += delta_y;
267 }
268
269
270 /*************************************************************************/
271 /* */
272 /* The following functions are used by default with TrueType fonts. */ 253 /* The following functions are used by default with TrueType fonts. */
273 /* However, they can be replaced by alternatives if we need to support */ 254 /* However, they can be replaced by alternatives if we need to support */
274 /* TrueType-compressed formats (like MicroType) in the future. */ 255 /* TrueType-compressed formats (like MicroType) in the future. */
275 /* */ 256 /* */
276 /*************************************************************************/ 257 /*************************************************************************/
277 258
278 FT_CALLBACK_DEF( FT_Error ) 259 FT_CALLBACK_DEF( FT_Error )
279 TT_Access_Glyph_Frame( TT_Loader loader, 260 TT_Access_Glyph_Frame( TT_Loader loader,
280 FT_UInt glyph_index, 261 FT_UInt glyph_index,
281 FT_ULong offset, 262 FT_ULong offset,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 goto Invalid_Outline; 381 goto Invalid_Outline;
401 } 382 }
402 383
403 /* note that we will add four phantom points later */ 384 /* note that we will add four phantom points later */
404 error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 ); 385 error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
405 if ( error ) 386 if ( error )
406 goto Fail; 387 goto Fail;
407 388
408 /* reading the bytecode instructions */ 389 /* reading the bytecode instructions */
409 load->glyph->control_len = 0; 390 load->glyph->control_len = 0;
410 load->glyph->control_data = 0; 391 load->glyph->control_data = NULL;
411 392
412 if ( p + 2 > limit ) 393 if ( p + 2 > limit )
413 goto Invalid_Outline; 394 goto Invalid_Outline;
414 395
415 n_ins = FT_NEXT_USHORT( p ); 396 n_ins = FT_NEXT_USHORT( p );
416 397
417 FT_TRACE5(( " Instructions size: %u\n", n_ins )); 398 FT_TRACE5(( " Instructions size: %u\n", n_ins ));
418 399
419 /* check it */ 400 /* check it */
420 if ( ( limit - p ) < n_ins ) 401 if ( ( limit - p ) < n_ins )
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 529
549 y = (FT_Pos)FT_NEXT_SHORT( p ); 530 y = (FT_Pos)FT_NEXT_SHORT( p );
550 } 531 }
551 532
552 x += y; 533 x += y;
553 vec->y = x; 534 vec->y = x;
554 /* the cast is for stupid compilers */ 535 /* the cast is for stupid compilers */
555 *flag = (FT_Byte)( f & FT_CURVE_TAG_ON ); 536 *flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
556 } 537 }
557 538
558 outline->n_points = (FT_UShort)n_points; 539 outline->n_points = (FT_Short)n_points;
559 outline->n_contours = (FT_Short) n_contours; 540 outline->n_contours = (FT_Short)n_contours;
560 541
561 load->cursor = p; 542 load->cursor = p;
562 543
563 Fail: 544 Fail:
564 return error; 545 return error;
565 546
566 Invalid_Outline: 547 Invalid_Outline:
567 error = FT_THROW( Invalid_Outline ); 548 error = FT_THROW( Invalid_Outline );
568 goto Fail; 549 goto Fail;
569 } 550 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 count += 2; 593 count += 2;
613 else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE ) 594 else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
614 count += 4; 595 count += 4;
615 else if ( subglyph->flags & WE_HAVE_A_2X2 ) 596 else if ( subglyph->flags & WE_HAVE_A_2X2 )
616 count += 8; 597 count += 8;
617 598
618 if ( p + count > limit ) 599 if ( p + count > limit )
619 goto Invalid_Composite; 600 goto Invalid_Composite;
620 601
621 /* read arguments */ 602 /* read arguments */
622 if ( subglyph->flags & ARGS_ARE_WORDS ) 603 if ( subglyph->flags & ARGS_ARE_XY_VALUES )
623 { 604 {
624 subglyph->arg1 = FT_NEXT_SHORT( p ); 605 if ( subglyph->flags & ARGS_ARE_WORDS )
625 subglyph->arg2 = FT_NEXT_SHORT( p ); 606 {
607 subglyph->arg1 = FT_NEXT_SHORT( p );
608 subglyph->arg2 = FT_NEXT_SHORT( p );
609 }
610 else
611 {
612 subglyph->arg1 = FT_NEXT_CHAR( p );
613 subglyph->arg2 = FT_NEXT_CHAR( p );
614 }
626 } 615 }
627 else 616 else
628 { 617 {
629 subglyph->arg1 = FT_NEXT_CHAR( p ); 618 if ( subglyph->flags & ARGS_ARE_WORDS )
630 subglyph->arg2 = FT_NEXT_CHAR( p ); 619 {
620 subglyph->arg1 = (FT_Int)FT_NEXT_USHORT( p );
621 subglyph->arg2 = (FT_Int)FT_NEXT_USHORT( p );
622 }
623 else
624 {
625 subglyph->arg1 = (FT_Int)FT_NEXT_BYTE( p );
626 subglyph->arg2 = (FT_Int)FT_NEXT_BYTE( p );
627 }
631 } 628 }
632 629
633 /* read transform */ 630 /* read transform */
634 xx = yy = 0x10000L; 631 xx = yy = 0x10000L;
635 xy = yx = 0; 632 xy = yx = 0;
636 633
637 if ( subglyph->flags & WE_HAVE_A_SCALE ) 634 if ( subglyph->flags & WE_HAVE_A_SCALE )
638 { 635 {
639 xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 636 xx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
640 yy = xx; 637 yy = xx;
641 } 638 }
642 else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE ) 639 else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
643 { 640 {
644 xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 641 xx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
645 yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 642 yy = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
646 } 643 }
647 else if ( subglyph->flags & WE_HAVE_A_2X2 ) 644 else if ( subglyph->flags & WE_HAVE_A_2X2 )
648 { 645 {
649 xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 646 xx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
650 yx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 647 yx = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
651 xy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 648 xy = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
652 yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2; 649 yy = (FT_Fixed)FT_NEXT_SHORT( p ) * 4;
653 } 650 }
654 651
655 subglyph->transform.xx = xx; 652 subglyph->transform.xx = xx;
656 subglyph->transform.xy = xy; 653 subglyph->transform.xy = xy;
657 subglyph->transform.yx = yx; 654 subglyph->transform.yx = yx;
658 subglyph->transform.yy = yy; 655 subglyph->transform.yy = yy;
659 656
660 num_subglyphs++; 657 num_subglyphs++;
661 658
662 } while ( subglyph->flags & MORE_COMPONENTS ); 659 } while ( subglyph->flags & MORE_COMPONENTS );
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 face->forget_glyph_frame = TT_Forget_Glyph_Frame; 697 face->forget_glyph_frame = TT_Forget_Glyph_Frame;
701 } 698 }
702 699
703 700
704 static void 701 static void
705 tt_prepare_zone( TT_GlyphZone zone, 702 tt_prepare_zone( TT_GlyphZone zone,
706 FT_GlyphLoad load, 703 FT_GlyphLoad load,
707 FT_UInt start_point, 704 FT_UInt start_point,
708 FT_UInt start_contour ) 705 FT_UInt start_contour )
709 { 706 {
710 zone->n_points = (FT_UShort)( load->outline.n_points - start_point ); 707 zone->n_points = (FT_UShort)load->outline.n_points -
711 zone->n_contours = (FT_Short) ( load->outline.n_contours - 708 (FT_UShort)start_point;
712 start_contour ); 709 zone->n_contours = load->outline.n_contours -
710 (FT_Short)start_contour;
713 zone->org = load->extra_points + start_point; 711 zone->org = load->extra_points + start_point;
714 zone->cur = load->outline.points + start_point; 712 zone->cur = load->outline.points + start_point;
715 zone->orus = load->extra_points2 + start_point; 713 zone->orus = load->extra_points2 + start_point;
716 zone->tags = (FT_Byte*)load->outline.tags + start_point; 714 zone->tags = (FT_Byte*)load->outline.tags + start_point;
717 zone->contours = (FT_UShort*)load->outline.contours + start_contour; 715 zone->contours = (FT_UShort*)load->outline.contours + start_contour;
718 zone->first_point = (FT_UShort)start_point; 716 zone->first_point = (FT_UShort)start_point;
719 } 717 }
720 718
721 719
722 /*************************************************************************/ 720 /*************************************************************************/
723 /* */ 721 /* */
724 /* <Function> */ 722 /* <Function> */
725 /* TT_Hint_Glyph */ 723 /* TT_Hint_Glyph */
726 /* */ 724 /* */
727 /* <Description> */ 725 /* <Description> */
728 /* Hint the glyph using the zone prepared by the caller. Note that */ 726 /* Hint the glyph using the zone prepared by the caller. Note that */
729 /* the zone is supposed to include four phantom points. */ 727 /* the zone is supposed to include four phantom points. */
730 /* */ 728 /* */
731 static FT_Error 729 static FT_Error
732 TT_Hint_Glyph( TT_Loader loader, 730 TT_Hint_Glyph( TT_Loader loader,
733 FT_Bool is_composite ) 731 FT_Bool is_composite )
734 { 732 {
735 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 733 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
736 TT_Face face = (TT_Face)loader->face; 734 TT_Face face = loader->face;
737 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); 735 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
738 #endif 736 #endif
739 737
740 TT_GlyphZone zone = &loader->zone; 738 TT_GlyphZone zone = &loader->zone;
741 739
742 #ifdef TT_USE_BYTECODE_INTERPRETER 740 #ifdef TT_USE_BYTECODE_INTERPRETER
743 FT_UInt n_ins; 741 FT_Long n_ins;
744 #else 742 #else
745 FT_UNUSED( is_composite ); 743 FT_UNUSED( is_composite );
746 #endif 744 #endif
747 745
748 746
749 #ifdef TT_USE_BYTECODE_INTERPRETER 747 #ifdef TT_USE_BYTECODE_INTERPRETER
750 if ( loader->glyph->control_len > 0xFFFFL ) 748 if ( loader->glyph->control_len > 0xFFFFL )
751 { 749 {
752 FT_TRACE1(( "TT_Hint_Glyph: too long instructions" )); 750 FT_TRACE1(( "TT_Hint_Glyph: too long instructions" ));
753 FT_TRACE1(( " (0x%lx byte) is truncated\n", 751 FT_TRACE1(( " (0x%lx byte) is truncated\n",
754 loader->glyph->control_len )); 752 loader->glyph->control_len ));
755 } 753 }
756 n_ins = (FT_UInt)( loader->glyph->control_len ); 754 n_ins = loader->glyph->control_len;
757 755
758 /* save original point position in org */ 756 /* save original point position in org */
759 if ( n_ins > 0 ) 757 if ( n_ins > 0 )
760 FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points ); 758 FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
761 759
762 /* Reset graphics state. */ 760 /* Reset graphics state. */
763 loader->exec->GS = ((TT_Size)loader->size)->GS; 761 loader->exec->GS = loader->size->GS;
764 762
765 /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */ 763 /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
766 /* completely refer to the (already) hinted subglyphs. */ 764 /* completely refer to the (already) hinted subglyphs. */
767 if ( is_composite ) 765 if ( is_composite )
768 { 766 {
769 loader->exec->metrics.x_scale = 1 << 16; 767 loader->exec->metrics.x_scale = 1 << 16;
770 loader->exec->metrics.y_scale = 1 << 16; 768 loader->exec->metrics.y_scale = 1 << 16;
771 769
772 FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points ); 770 FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
773 } 771 }
774 else 772 else
775 { 773 {
776 loader->exec->metrics.x_scale = 774 loader->exec->metrics.x_scale = loader->size->metrics.x_scale;
777 ((TT_Size)loader->size)->metrics.x_scale; 775 loader->exec->metrics.y_scale = loader->size->metrics.y_scale;
778 loader->exec->metrics.y_scale =
779 ((TT_Size)loader->size)->metrics.y_scale;
780 } 776 }
781 #endif 777 #endif
782 778
783 /* round phantom points */ 779 /* round phantom points */
784 zone->cur[zone->n_points - 4].x = 780 zone->cur[zone->n_points - 4].x =
785 FT_PIX_ROUND( zone->cur[zone->n_points - 4].x ); 781 FT_PIX_ROUND( zone->cur[zone->n_points - 4].x );
786 zone->cur[zone->n_points - 3].x = 782 zone->cur[zone->n_points - 3].x =
787 FT_PIX_ROUND( zone->cur[zone->n_points - 3].x ); 783 FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
788 zone->cur[zone->n_points - 2].y = 784 zone->cur[zone->n_points - 2].y =
789 FT_PIX_ROUND( zone->cur[zone->n_points - 2].y ); 785 FT_PIX_ROUND( zone->cur[zone->n_points - 2].y );
790 zone->cur[zone->n_points - 1].y = 786 zone->cur[zone->n_points - 1].y =
791 FT_PIX_ROUND( zone->cur[zone->n_points - 1].y ); 787 FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
792 788
793 #ifdef TT_USE_BYTECODE_INTERPRETER 789 #ifdef TT_USE_BYTECODE_INTERPRETER
794 790
795 if ( n_ins > 0 ) 791 if ( n_ins > 0 )
796 { 792 {
797 FT_Bool debug;
798 FT_Error error; 793 FT_Error error;
799 794
800 FT_GlyphLoader gloader = loader->gloader; 795 FT_GlyphLoader gloader = loader->gloader;
801 FT_Outline current_outline = gloader->current.outline; 796 FT_Outline current_outline = gloader->current.outline;
802 797
803 798
804 TT_Set_CodeRange( loader->exec, tt_coderange_glyph, 799 TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
805 loader->exec->glyphIns, n_ins ); 800 loader->exec->glyphIns, n_ins );
806 801
807 loader->exec->is_composite = is_composite; 802 loader->exec->is_composite = is_composite;
808 loader->exec->pts = *zone; 803 loader->exec->pts = *zone;
809 804
810 debug = FT_BOOL( !( loader->load_flags & FT_LOAD_NO_SCALE ) && 805 error = TT_Run_Context( loader->exec );
811 ((TT_Size)loader->size)->debug );
812
813 error = TT_Run_Context( loader->exec, debug );
814 if ( error && loader->exec->pedantic_hinting ) 806 if ( error && loader->exec->pedantic_hinting )
815 return error; 807 return error;
816 808
817 /* store drop-out mode in bits 5-7; set bit 2 also as a marker */ 809 /* store drop-out mode in bits 5-7; set bit 2 also as a marker */
818 current_outline.tags[0] |= 810 current_outline.tags[0] |=
819 ( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE; 811 ( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
820 } 812 }
821 813
822 #endif 814 #endif
823 815
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 865
874 outline->tags[n_points ] = 0; 866 outline->tags[n_points ] = 0;
875 outline->tags[n_points + 1] = 0; 867 outline->tags[n_points + 1] = 0;
876 outline->tags[n_points + 2] = 0; 868 outline->tags[n_points + 2] = 0;
877 outline->tags[n_points + 3] = 0; 869 outline->tags[n_points + 3] = 0;
878 870
879 n_points += 4; 871 n_points += 4;
880 872
881 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT 873 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
882 874
883 if ( ((TT_Face)loader->face)->doblend ) 875 if ( loader->face->doblend )
884 { 876 {
885 /* Deltas apply to the unscaled data. */ 877 /* Deltas apply to the unscaled data. */
886 FT_Vector* deltas; 878 error = TT_Vary_Apply_Glyph_Deltas( loader->face,
887 FT_Memory memory = loader->face->memory; 879 loader->glyph_index,
888 FT_Int i; 880 outline,
889 881 (FT_UInt)n_points );
890
891 error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
892 loader->glyph_index,
893 &deltas,
894 n_points );
895 if ( error ) 882 if ( error )
896 return error; 883 return error;
897
898 for ( i = 0; i < n_points; ++i )
899 {
900 outline->points[i].x += deltas[i].x;
901 outline->points[i].y += deltas[i].y;
902 }
903
904 FT_FREE( deltas );
905 } 884 }
906 885
907 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ 886 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
908 887
909 if ( IS_HINTED( loader->load_flags ) ) 888 if ( IS_HINTED( loader->load_flags ) )
910 { 889 {
911 tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 ); 890 tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
912 891
913 FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur, 892 FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
914 loader->zone.n_points + 4 ); 893 loader->zone.n_points + 4 );
915 } 894 }
916 895
917 { 896 {
918 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 897 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
919 TT_Face face = (TT_Face)loader->face; 898 TT_Face face = loader->face;
920 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); 899 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
921 900
922 FT_String* family = face->root.family_name; 901 FT_String* family = face->root.family_name;
923 FT_Int ppem = loader->size->metrics.x_ppem; 902 FT_UInt ppem = loader->size->metrics.x_ppem;
924 FT_String* style = face->root.style_name; 903 FT_String* style = face->root.style_name;
925 FT_Int x_scale_factor = 1000; 904 FT_UInt x_scale_factor = 1000;
926 #endif 905 #endif
927 906
928 FT_Vector* vec = outline->points; 907 FT_Vector* vec = outline->points;
929 FT_Vector* limit = outline->points + n_points; 908 FT_Vector* limit = outline->points + n_points;
930 909
931 FT_Fixed x_scale = 0; /* pacify compiler */ 910 FT_Fixed x_scale = 0; /* pacify compiler */
932 FT_Fixed y_scale = 0; 911 FT_Fixed y_scale = 0;
933 912
934 FT_Bool do_scale = FALSE; 913 FT_Bool do_scale = FALSE;
935 914
936 915
937 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 916 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
938 917
939 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 ) 918 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
940 { 919 {
941 /* scale, but only if enabled and only if TT hinting is being used */ 920 /* scale, but only if enabled and only if TT hinting is being used */
942 if ( IS_HINTED( loader->load_flags ) ) 921 if ( IS_HINTED( loader->load_flags ) )
943 x_scale_factor = sph_test_tweak_x_scaling( face, 922 x_scale_factor = sph_test_tweak_x_scaling( face,
944 family, 923 family,
945 ppem, 924 ppem,
946 style, 925 style,
947 loader->glyph_index ); 926 loader->glyph_index );
948 /* scale the glyph */ 927 /* scale the glyph */
949 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 || 928 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ||
950 x_scale_factor != 1000 ) 929 x_scale_factor != 1000 )
951 { 930 {
952 x_scale = FT_MulDiv( ((TT_Size)loader->size)->metrics.x_scale, 931 x_scale = FT_MulDiv( loader->size->metrics.x_scale,
953 x_scale_factor, 1000 ); 932 (FT_Long)x_scale_factor, 1000 );
954 y_scale = ((TT_Size)loader->size)->metrics.y_scale; 933 y_scale = loader->size->metrics.y_scale;
955 934
956 /* compensate for any scaling by de/emboldening; */ 935 /* compensate for any scaling by de/emboldening; */
957 /* the amount was determined via experimentation */ 936 /* the amount was determined via experimentation */
958 if ( x_scale_factor != 1000 && ppem > 11 ) 937 if ( x_scale_factor != 1000 && ppem > 11 )
959 FT_Outline_EmboldenXY( outline, 938 FT_Outline_EmboldenXY( outline,
960 FT_MulFix( 1280 * ppem, 939 FT_MulFix( 1280 * ppem,
961 1000 - x_scale_factor ), 940 1000 - x_scale_factor ),
962 0 ); 941 0 );
963 do_scale = TRUE; 942 do_scale = TRUE;
964 } 943 }
965 } 944 }
966 else 945 else
967 946
968 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ 947 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
969 948
970 { 949 {
971 /* scale the glyph */ 950 /* scale the glyph */
972 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 951 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
973 { 952 {
974 x_scale = ((TT_Size)loader->size)->metrics.x_scale; 953 x_scale = loader->size->metrics.x_scale;
975 y_scale = ((TT_Size)loader->size)->metrics.y_scale; 954 y_scale = loader->size->metrics.y_scale;
976 955
977 do_scale = TRUE; 956 do_scale = TRUE;
978 } 957 }
979 } 958 }
980 959
981 if ( do_scale ) 960 if ( do_scale )
982 { 961 {
983 for ( ; vec < limit; vec++ ) 962 for ( ; vec < limit; vec++ )
984 { 963 {
985 vec->x = FT_MulFix( vec->x, x_scale ); 964 vec->x = FT_MulFix( vec->x, x_scale );
(...skipping 26 matching lines...) Expand all
1012 /* <Description> */ 991 /* <Description> */
1013 /* Once a composite component has been loaded, it needs to be */ 992 /* Once a composite component has been loaded, it needs to be */
1014 /* processed. Usually, this means transforming and translating. */ 993 /* processed. Usually, this means transforming and translating. */
1015 /* */ 994 /* */
1016 static FT_Error 995 static FT_Error
1017 TT_Process_Composite_Component( TT_Loader loader, 996 TT_Process_Composite_Component( TT_Loader loader,
1018 FT_SubGlyph subglyph, 997 FT_SubGlyph subglyph,
1019 FT_UInt start_point, 998 FT_UInt start_point,
1020 FT_UInt num_base_points ) 999 FT_UInt num_base_points )
1021 { 1000 {
1022 FT_GlyphLoader gloader = loader->gloader; 1001 FT_GlyphLoader gloader = loader->gloader;
1023 FT_Vector* base_vec = gloader->base.outline.points; 1002 FT_Outline current;
1024 FT_UInt num_points = gloader->base.outline.n_points;
1025 FT_Bool have_scale; 1003 FT_Bool have_scale;
1026 FT_Pos x, y; 1004 FT_Pos x, y;
1027 1005
1028 1006
1007 current.points = gloader->base.outline.points +
1008 num_base_points;
1009 current.n_points = gloader->base.outline.n_points -
1010 (short)num_base_points;
1011
1029 have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE | 1012 have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE |
1030 WE_HAVE_AN_XY_SCALE | 1013 WE_HAVE_AN_XY_SCALE |
1031 WE_HAVE_A_2X2 ) ); 1014 WE_HAVE_A_2X2 ) );
1032 1015
1033 /* perform the transform required for this subglyph */ 1016 /* perform the transform required for this subglyph */
1034 if ( have_scale ) 1017 if ( have_scale )
1035 { 1018 FT_Outline_Transform( &current, &subglyph->transform );
1036 FT_UInt i;
1037
1038
1039 for ( i = num_base_points; i < num_points; i++ )
1040 FT_Vector_Transform( base_vec + i, &subglyph->transform );
1041 }
1042 1019
1043 /* get offset */ 1020 /* get offset */
1044 if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) ) 1021 if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
1045 { 1022 {
1046 FT_UInt k = subglyph->arg1; 1023 FT_UInt num_points = (FT_UInt)gloader->base.outline.n_points;
1047 FT_UInt l = subglyph->arg2; 1024 FT_UInt k = (FT_UInt)subglyph->arg1;
1025 FT_UInt l = (FT_UInt)subglyph->arg2;
1048 FT_Vector* p1; 1026 FT_Vector* p1;
1049 FT_Vector* p2; 1027 FT_Vector* p2;
1050 1028
1051 1029
1052 /* match l-th point of the newly loaded component to the k-th point */ 1030 /* match l-th point of the newly loaded component to the k-th point */
1053 /* of the previously loaded components. */ 1031 /* of the previously loaded components. */
1054 1032
1055 /* change to the point numbers used by our outline */ 1033 /* change to the point numbers used by our outline */
1056 k += start_point; 1034 k += start_point;
1057 l += num_base_points; 1035 l += num_base_points;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1102
1125 x = FT_MulFix( x, mac_xscale ); 1103 x = FT_MulFix( x, mac_xscale );
1126 y = FT_MulFix( y, mac_yscale ); 1104 y = FT_MulFix( y, mac_yscale );
1127 1105
1128 #endif /* 1 */ 1106 #endif /* 1 */
1129 1107
1130 } 1108 }
1131 1109
1132 if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) 1110 if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
1133 { 1111 {
1134 FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale; 1112 FT_Fixed x_scale = loader->size->metrics.x_scale;
1135 FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale; 1113 FT_Fixed y_scale = loader->size->metrics.y_scale;
1136 1114
1137 1115
1138 x = FT_MulFix( x, x_scale ); 1116 x = FT_MulFix( x, x_scale );
1139 y = FT_MulFix( y, y_scale ); 1117 y = FT_MulFix( y, y_scale );
1140 1118
1141 if ( subglyph->flags & ROUND_XY_TO_GRID ) 1119 if ( subglyph->flags & ROUND_XY_TO_GRID )
1142 { 1120 {
1143 x = FT_PIX_ROUND( x ); 1121 x = FT_PIX_ROUND( x );
1144 y = FT_PIX_ROUND( y ); 1122 y = FT_PIX_ROUND( y );
1145 } 1123 }
1146 } 1124 }
1147 } 1125 }
1148 1126
1149 if ( x || y ) 1127 if ( x || y )
1150 translate_array( num_points - num_base_points, 1128 FT_Outline_Translate( &current, x, y );
1151 base_vec + num_base_points,
1152 x, y );
1153 1129
1154 return FT_Err_Ok; 1130 return FT_Err_Ok;
1155 } 1131 }
1156 1132
1157 1133
1158 /*************************************************************************/ 1134 /*************************************************************************/
1159 /* */ 1135 /* */
1160 /* <Function> */ 1136 /* <Function> */
1161 /* TT_Process_Composite_Glyph */ 1137 /* TT_Process_Composite_Glyph */
1162 /* */ 1138 /* */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 1180
1205 /* TT_Load_Composite_Glyph only gives us the offset of instructions */ 1181 /* TT_Load_Composite_Glyph only gives us the offset of instructions */
1206 /* so we read them here */ 1182 /* so we read them here */
1207 if ( FT_STREAM_SEEK( loader->ins_pos ) || 1183 if ( FT_STREAM_SEEK( loader->ins_pos ) ||
1208 FT_READ_USHORT( n_ins ) ) 1184 FT_READ_USHORT( n_ins ) )
1209 return error; 1185 return error;
1210 1186
1211 FT_TRACE5(( " Instructions size = %d\n", n_ins )); 1187 FT_TRACE5(( " Instructions size = %d\n", n_ins ));
1212 1188
1213 /* check it */ 1189 /* check it */
1214 max_ins = ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions; 1190 max_ins = loader->face->max_profile.maxSizeOfInstructions;
1215 if ( n_ins > max_ins ) 1191 if ( n_ins > max_ins )
1216 { 1192 {
1217 /* don't trust `maxSizeOfInstructions'; */ 1193 /* don't trust `maxSizeOfInstructions'; */
1218 /* only do a rough safety check */ 1194 /* only do a rough safety check */
1219 if ( (FT_Int)n_ins > loader->byte_len ) 1195 if ( (FT_Int)n_ins > loader->byte_len )
1220 { 1196 {
1221 FT_TRACE1(( "TT_Process_Composite_Glyph:" 1197 FT_TRACE1(( "TT_Process_Composite_Glyph:"
1222 " too many instructions (%d) for glyph with length %d\n", 1198 " too many instructions (%d) for glyph with length %d\n",
1223 n_ins, loader->byte_len )); 1199 n_ins, loader->byte_len ));
1224 return FT_THROW( Too_Many_Hints ); 1200 return FT_THROW( Too_Many_Hints );
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 * 1319 *
1344 * For simplicity, FreeType uses (1) for grayscale subpixel hinting and 1320 * For simplicity, FreeType uses (1) for grayscale subpixel hinting and
1345 * (3) for everything else. 1321 * (3) for everything else.
1346 * 1322 *
1347 */ 1323 */
1348 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 1324 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1349 1325
1350 #define TT_LOADER_SET_PP( loader ) \ 1326 #define TT_LOADER_SET_PP( loader ) \
1351 do \ 1327 do \
1352 { \ 1328 { \
1353 FT_Bool subpixel_ = loader->exec ? loader->exec->subpixel \ 1329 FT_Bool subpixel_hinting_ = loader->exec \
1354 : 0; \ 1330 ? loader->exec->subpixel_hinting \
1355 FT_Bool grayscale_ = loader->exec ? loader->exec->grayscale \ 1331 : 0; \
1356 : 0; \ 1332 FT_Bool grayscale_ = loader->exec \
1357 FT_Bool use_aw_2_ = (FT_Bool)( subpixel_ && grayscale_ ); \ 1333 ? loader->exec->grayscale \
1334 : 0; \
1335 FT_Bool use_aw_2_ = (FT_Bool)( subpixel_hinting_ && \
1336 grayscale_ ); \
1358 \ 1337 \
1359 \ 1338 \
1360 (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \ 1339 (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
1361 (loader)->pp1.y = 0; \ 1340 (loader)->pp1.y = 0; \
1362 (loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \ 1341 (loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
1363 (loader)->pp2.y = 0; \ 1342 (loader)->pp2.y = 0; \
1364 \ 1343 \
1365 (loader)->pp3.x = use_aw_2_ ? (loader)->advance / 2 : 0; \ 1344 (loader)->pp3.x = use_aw_2_ ? (loader)->advance / 2 : 0; \
1366 (loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \ 1345 (loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
1367 (loader)->pp4.x = use_aw_2_ ? (loader)->advance / 2 : 0; \ 1346 (loader)->pp4.x = use_aw_2_ ? (loader)->advance / 2 : 0; \
(...skipping 30 matching lines...) Expand all
1398 /* */ 1377 /* */
1399 static FT_Error 1378 static FT_Error
1400 load_truetype_glyph( TT_Loader loader, 1379 load_truetype_glyph( TT_Loader loader,
1401 FT_UInt glyph_index, 1380 FT_UInt glyph_index,
1402 FT_UInt recurse_count, 1381 FT_UInt recurse_count,
1403 FT_Bool header_only ) 1382 FT_Bool header_only )
1404 { 1383 {
1405 FT_Error error = FT_Err_Ok; 1384 FT_Error error = FT_Err_Ok;
1406 FT_Fixed x_scale, y_scale; 1385 FT_Fixed x_scale, y_scale;
1407 FT_ULong offset; 1386 FT_ULong offset;
1408 TT_Face face = (TT_Face)loader->face; 1387 TT_Face face = loader->face;
1409 FT_GlyphLoader gloader = loader->gloader; 1388 FT_GlyphLoader gloader = loader->gloader;
1410 FT_Bool opened_frame = 0; 1389 FT_Bool opened_frame = 0;
1411 1390
1412 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1413 FT_Vector* deltas = NULL;
1414 #endif
1415
1416 #ifdef FT_CONFIG_OPTION_INCREMENTAL 1391 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1417 FT_StreamRec inc_stream; 1392 FT_StreamRec inc_stream;
1418 FT_Data glyph_data; 1393 FT_Data glyph_data;
1419 FT_Bool glyph_data_loaded = 0; 1394 FT_Bool glyph_data_loaded = 0;
1420 #endif 1395 #endif
1421 1396
1422 1397
1423 /* some fonts have an incorrect value of `maxComponentDepth', */ 1398 /* some fonts have an incorrect value of `maxComponentDepth', */
1424 /* thus we allow depth 1 to catch the majority of them */ 1399 /* thus we allow depth 1 to catch the majority of them */
1425 if ( recurse_count > 1 && 1400 if ( recurse_count > 1 &&
1426 recurse_count > face->max_profile.maxComponentDepth ) 1401 recurse_count > face->max_profile.maxComponentDepth )
1427 { 1402 {
1428 error = FT_THROW( Invalid_Composite ); 1403 error = FT_THROW( Invalid_Composite );
1429 goto Exit; 1404 goto Exit;
1430 } 1405 }
1431 1406
1407 #ifndef FT_CONFIG_OPTION_INCREMENTAL
1432 /* check glyph index */ 1408 /* check glyph index */
1433 if ( glyph_index >= (FT_UInt)face->root.num_glyphs ) 1409 if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
1434 { 1410 {
1435 error = FT_THROW( Invalid_Glyph_Index ); 1411 error = FT_THROW( Invalid_Glyph_Index );
1436 goto Exit; 1412 goto Exit;
1437 } 1413 }
1414 #endif
1438 1415
1439 loader->glyph_index = glyph_index; 1416 loader->glyph_index = glyph_index;
1440 1417
1441 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 1418 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1442 { 1419 {
1443 x_scale = ((TT_Size)loader->size)->metrics.x_scale; 1420 x_scale = loader->size->metrics.x_scale;
1444 y_scale = ((TT_Size)loader->size)->metrics.y_scale; 1421 y_scale = loader->size->metrics.y_scale;
1445 } 1422 }
1446 else 1423 else
1447 { 1424 {
1448 x_scale = 0x10000L; 1425 x_scale = 0x10000L;
1449 y_scale = 0x10000L; 1426 y_scale = 0x10000L;
1450 } 1427 }
1451 1428
1452 /* Set `offset' to the start of the glyph relative to the start of */ 1429 /* Set `offset' to the start of the glyph relative to the start of */
1453 /* the `glyf' table, and `byte_len' to the length of the glyph in */ 1430 /* the `glyf' table, and `byte_len' to the length of the glyph in */
1454 /* bytes. */ 1431 /* bytes. */
(...skipping 10 matching lines...) Expand all
1465 glyph_index, &glyph_data ); 1442 glyph_index, &glyph_data );
1466 if ( error ) 1443 if ( error )
1467 goto Exit; 1444 goto Exit;
1468 1445
1469 glyph_data_loaded = 1; 1446 glyph_data_loaded = 1;
1470 offset = 0; 1447 offset = 0;
1471 loader->byte_len = glyph_data.length; 1448 loader->byte_len = glyph_data.length;
1472 1449
1473 FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) ); 1450 FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
1474 FT_Stream_OpenMemory( &inc_stream, 1451 FT_Stream_OpenMemory( &inc_stream,
1475 glyph_data.pointer, glyph_data.length ); 1452 glyph_data.pointer,
1453 (FT_ULong)glyph_data.length );
1476 1454
1477 loader->stream = &inc_stream; 1455 loader->stream = &inc_stream;
1478 } 1456 }
1479 else 1457 else
1480 1458
1481 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ 1459 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
1482 1460
1483 offset = tt_face_get_location( face, glyph_index, 1461 offset = tt_face_get_location( face, glyph_index,
1484 (FT_UInt*)&loader->byte_len ); 1462 (FT_UInt*)&loader->byte_len );
1485 1463
1486 if ( loader->byte_len > 0 ) 1464 if ( loader->byte_len > 0 )
1487 { 1465 {
1488 #ifdef FT_CONFIG_OPTION_INCREMENTAL 1466 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1489 /* for the incremental interface, `glyf_offset' is always zero */ 1467 /* for the incremental interface, `glyf_offset' is always zero */
1490 if ( !loader->glyf_offset && 1468 if ( !loader->glyf_offset &&
1491 !face->root.internal->incremental_interface ) 1469 !face->root.internal->incremental_interface )
1492 #else 1470 #else
1493 if ( !loader->glyf_offset ) 1471 if ( !loader->glyf_offset )
1494 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ 1472 #endif /* FT_CONFIG_OPTION_INCREMENTAL */
1495 { 1473 {
1496 FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" )); 1474 FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
1497 error = FT_THROW( Invalid_Table ); 1475 error = FT_THROW( Invalid_Table );
1498 goto Exit; 1476 goto Exit;
1499 } 1477 }
1500 1478
1501 error = face->access_glyph_frame( loader, glyph_index, 1479 error = face->access_glyph_frame( loader, glyph_index,
1502 loader->glyf_offset + offset, 1480 loader->glyf_offset + offset,
1503 loader->byte_len ); 1481 (FT_UInt)loader->byte_len );
1504 if ( error ) 1482 if ( error )
1505 goto Exit; 1483 goto Exit;
1506 1484
1507 opened_frame = 1; 1485 opened_frame = 1;
1508 1486
1509 /* read glyph header first */ 1487 /* read glyph header first */
1510 error = face->read_glyph_header( loader ); 1488 error = face->read_glyph_header( loader );
1511 if ( error ) 1489 if ( error )
1512 goto Exit; 1490 goto Exit;
1513 1491
(...skipping 25 matching lines...) Expand all
1539 /* must initialize points before (possibly) overriding */ 1517 /* must initialize points before (possibly) overriding */
1540 /* glyph metrics from the incremental interface */ 1518 /* glyph metrics from the incremental interface */
1541 TT_LOADER_SET_PP( loader ); 1519 TT_LOADER_SET_PP( loader );
1542 1520
1543 #ifdef FT_CONFIG_OPTION_INCREMENTAL 1521 #ifdef FT_CONFIG_OPTION_INCREMENTAL
1544 tt_get_metrics_incr_overrides( loader, glyph_index ); 1522 tt_get_metrics_incr_overrides( loader, glyph_index );
1545 #endif 1523 #endif
1546 1524
1547 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT 1525 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1548 1526
1549 if ( ((TT_Face)(loader->face))->doblend ) 1527 if ( loader->face->doblend )
1550 { 1528 {
1551 /* this must be done before scaling */ 1529 /* a small outline structure with four elements for */
1552 FT_Memory memory = loader->face->memory; 1530 /* communication with `TT_Vary_Apply_Glyph_Deltas' */
1531 FT_Vector points[4];
1532 char tags[4] = { 1, 1, 1, 1 };
1533 short contours[4] = { 0, 1, 2, 3 };
1534 FT_Outline outline;
1553 1535
1554 1536
1555 error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face), 1537 points[0].x = loader->pp1.x;
1556 glyph_index, &deltas, 4 ); 1538 points[0].y = loader->pp1.y;
1539 points[1].x = loader->pp2.x;
1540 points[1].y = loader->pp2.y;
1541
1542 points[2].x = loader->pp3.x;
1543 points[2].y = loader->pp3.y;
1544 points[3].x = loader->pp4.x;
1545 points[3].y = loader->pp4.y;
1546
1547 outline.n_points = 4;
1548 outline.n_contours = 4;
1549 outline.points = points;
1550 outline.tags = tags;
1551 outline.contours = contours;
1552
1553 /* this must be done before scaling */
1554 error = TT_Vary_Apply_Glyph_Deltas( loader->face,
1555 glyph_index,
1556 &outline,
1557 (FT_UInt)outline.n_points );
1557 if ( error ) 1558 if ( error )
1558 goto Exit; 1559 goto Exit;
1559 1560
1560 loader->pp1.x += deltas[0].x; 1561 loader->pp1.x = points[0].x;
1561 loader->pp1.y += deltas[0].y; 1562 loader->pp1.y = points[0].y;
1562 loader->pp2.x += deltas[1].x; 1563 loader->pp2.x = points[1].x;
1563 loader->pp2.y += deltas[1].y; 1564 loader->pp2.y = points[1].y;
1564 1565
1565 loader->pp3.x += deltas[2].x; 1566 loader->pp3.x = points[2].x;
1566 loader->pp3.y += deltas[2].y; 1567 loader->pp3.y = points[2].y;
1567 loader->pp4.x += deltas[3].x; 1568 loader->pp4.x = points[3].x;
1568 loader->pp4.y += deltas[3].y; 1569 loader->pp4.y = points[3].y;
1569
1570 FT_FREE( deltas );
1571 } 1570 }
1572 1571
1573 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ 1572 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
1574 1573
1575 /* scale phantom points, if necessary; */ 1574 /* scale phantom points, if necessary; */
1576 /* they get rounded in `TT_Hint_Glyph' */ 1575 /* they get rounded in `TT_Hint_Glyph' */
1577 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 1576 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1578 { 1577 {
1579 loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale ); 1578 loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
1580 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale ); 1579 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 /***********************************************************************/ 1625 /***********************************************************************/
1627 1626
1628 /* otherwise, load a composite! */ 1627 /* otherwise, load a composite! */
1629 else if ( loader->n_contours == -1 ) 1628 else if ( loader->n_contours == -1 )
1630 { 1629 {
1631 FT_UInt start_point; 1630 FT_UInt start_point;
1632 FT_UInt start_contour; 1631 FT_UInt start_contour;
1633 FT_ULong ins_pos; /* position of composite instructions, if any */ 1632 FT_ULong ins_pos; /* position of composite instructions, if any */
1634 1633
1635 1634
1636 start_point = gloader->base.outline.n_points; 1635 start_point = (FT_UInt)gloader->base.outline.n_points;
1637 start_contour = gloader->base.outline.n_contours; 1636 start_contour = (FT_UInt)gloader->base.outline.n_contours;
1638 1637
1639 /* for each subglyph, read composite header */ 1638 /* for each subglyph, read composite header */
1640 error = face->read_composite_glyph( loader ); 1639 error = face->read_composite_glyph( loader );
1641 if ( error ) 1640 if ( error )
1642 goto Exit; 1641 goto Exit;
1643 1642
1644 /* store the offset of instructions */ 1643 /* store the offset of instructions */
1645 ins_pos = loader->ins_pos; 1644 ins_pos = loader->ins_pos;
1646 1645
1647 /* all data we need are read */ 1646 /* all data we need are read */
1648 face->forget_glyph_frame( loader ); 1647 face->forget_glyph_frame( loader );
1649 opened_frame = 0; 1648 opened_frame = 0;
1650 1649
1651 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT 1650 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1652 1651
1653 if ( face->doblend ) 1652 if ( face->doblend )
1654 { 1653 {
1655 FT_Int i, limit; 1654 short i, limit;
1656 FT_SubGlyph subglyph; 1655 FT_SubGlyph subglyph;
1657 FT_Memory memory = face->root.memory; 1656
1657 FT_Outline outline;
1658 FT_Vector* points = NULL;
1659 char* tags = NULL;
1660 short* contours = NULL;
1661
1662 FT_Memory memory = face->root.memory;
1658 1663
1659 1664
1660 /* this provides additional offsets */ 1665 limit = (short)gloader->current.num_subglyphs;
1661 /* for each component's translation */
1662 1666
1663 if ( ( error = TT_Vary_Get_Glyph_Deltas( 1667 /* construct an outline structure for */
1668 /* communication with `TT_Vary_Apply_Glyph_Deltas' */
1669 outline.n_points = (short)( gloader->current.num_subglyphs + 4 );
1670 outline.n_contours = outline.n_points;
1671
1672 if ( FT_NEW_ARRAY( points, outline.n_points ) ||
1673 FT_NEW_ARRAY( tags, outline.n_points ) ||
1674 FT_NEW_ARRAY( contours, outline.n_points ) )
1675 goto Exit1;
1676
1677 subglyph = gloader->current.subglyphs;
1678
1679 for ( i = 0; i < limit; i++, subglyph++ )
1680 {
1681 /* applying deltas for anchor points doesn't make sense, */
1682 /* but we don't have to specially check this since */
1683 /* unused delta values are zero anyways */
1684 points[i].x = subglyph->arg1;
1685 points[i].y = subglyph->arg2;
1686 tags[i] = 1;
1687 contours[i] = i;
1688 }
1689
1690 points[i].x = loader->pp1.x;
1691 points[i].y = loader->pp1.y;
1692 tags[i] = 1;
1693 contours[i] = i;
1694
1695 i++;
1696 points[i].x = loader->pp2.x;
1697 points[i].y = loader->pp2.y;
1698 tags[i] = 1;
1699 contours[i] = i;
1700
1701 i++;
1702 points[i].x = loader->pp3.x;
1703 points[i].y = loader->pp3.y;
1704 tags[i] = 1;
1705 contours[i] = i;
1706
1707 i++;
1708 points[i].x = loader->pp4.x;
1709 points[i].y = loader->pp4.y;
1710 tags[i] = 1;
1711 contours[i] = i;
1712
1713 outline.points = points;
1714 outline.tags = tags;
1715 outline.contours = contours;
1716
1717 /* this call provides additional offsets */
1718 /* for each component's translation */
1719 if ( ( error = TT_Vary_Apply_Glyph_Deltas(
1664 face, 1720 face,
1665 glyph_index, 1721 glyph_index,
1666 &deltas, 1722 &outline,
1667 gloader->current.num_subglyphs + 4 ) ) != 0 ) 1723 (FT_UInt)outline.n_points ) ) != 0 )
1668 goto Exit; 1724 goto Exit1;
1669 1725
1670 subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs; 1726 subglyph = gloader->current.subglyphs;
1671 limit = gloader->current.num_subglyphs;
1672 1727
1673 for ( i = 0; i < limit; ++i, ++subglyph ) 1728 for ( i = 0; i < limit; i++, subglyph++ )
1674 { 1729 {
1675 if ( subglyph->flags & ARGS_ARE_XY_VALUES ) 1730 /* XXX: overflow check for subglyph->{arg1,arg2}. */
1676 { 1731 /* Deltas must be within signed 16-bit, */
1677 /* XXX: overflow check for subglyph->{arg1,arg2}. */ 1732 /* but the restriction of summed deltas is not clear */
1678 /* deltas[i].{x,y} must be within signed 16-bit, */ 1733 subglyph->arg1 = (FT_Int16)points[i].x;
1679 /* but the restriction of summed delta is not clear */ 1734 subglyph->arg2 = (FT_Int16)points[i].y;
1680 subglyph->arg1 += (FT_Int16)deltas[i].x;
1681 subglyph->arg2 += (FT_Int16)deltas[i].y;
1682 }
1683 } 1735 }
1684 1736
1685 loader->pp1.x += deltas[i + 0].x; 1737 loader->pp1.x = points[i + 0].x;
1686 loader->pp1.y += deltas[i + 0].y; 1738 loader->pp1.y = points[i + 0].y;
1687 loader->pp2.x += deltas[i + 1].x; 1739 loader->pp2.x = points[i + 1].x;
1688 loader->pp2.y += deltas[i + 1].y; 1740 loader->pp2.y = points[i + 1].y;
1689 1741
1690 loader->pp3.x += deltas[i + 2].x; 1742 loader->pp3.x = points[i + 2].x;
1691 loader->pp3.y += deltas[i + 2].y; 1743 loader->pp3.y = points[i + 2].y;
1692 loader->pp4.x += deltas[i + 3].x; 1744 loader->pp4.x = points[i + 3].x;
1693 loader->pp4.y += deltas[i + 3].y; 1745 loader->pp4.y = points[i + 3].y;
1694 1746
1695 FT_FREE( deltas ); 1747 Exit1:
1748 FT_FREE( outline.points );
1749 FT_FREE( outline.tags );
1750 FT_FREE( outline.contours );
1751
1752 if ( error )
1753 goto Exit;
1696 } 1754 }
1697 1755
1698 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ 1756 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
1699 1757
1700 /* scale phantom points, if necessary; */ 1758 /* scale phantom points, if necessary; */
1701 /* they get rounded in `TT_Hint_Glyph' */ 1759 /* they get rounded in `TT_Hint_Glyph' */
1702 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 1760 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1703 { 1761 {
1704 loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale ); 1762 loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
1705 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale ); 1763 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
(...skipping 15 matching lines...) Expand all
1721 1779
1722 goto Exit; 1780 goto Exit;
1723 } 1781 }
1724 1782
1725 /*********************************************************************/ 1783 /*********************************************************************/
1726 /*********************************************************************/ 1784 /*********************************************************************/
1727 /*********************************************************************/ 1785 /*********************************************************************/
1728 1786
1729 { 1787 {
1730 FT_UInt n, num_base_points; 1788 FT_UInt n, num_base_points;
1731 FT_SubGlyph subglyph = 0; 1789 FT_SubGlyph subglyph = NULL;
1732 1790
1733 FT_UInt num_points = start_point; 1791 FT_UInt num_points = start_point;
1734 FT_UInt num_subglyphs = gloader->current.num_subglyphs; 1792 FT_UInt num_subglyphs = gloader->current.num_subglyphs;
1735 FT_UInt num_base_subgs = gloader->base.num_subglyphs; 1793 FT_UInt num_base_subgs = gloader->base.num_subglyphs;
1736 1794
1737 FT_Stream old_stream = loader->stream; 1795 FT_Stream old_stream = loader->stream;
1738 FT_Int old_byte_len = loader->byte_len; 1796 FT_Int old_byte_len = loader->byte_len;
1739 1797
1740 1798
1741 FT_GlyphLoader_Add( gloader ); 1799 FT_GlyphLoader_Add( gloader );
1742 1800
1743 /* read each subglyph independently */ 1801 /* read each subglyph independently */
1744 for ( n = 0; n < num_subglyphs; n++ ) 1802 for ( n = 0; n < num_subglyphs; n++ )
1745 { 1803 {
1746 FT_Vector pp[4]; 1804 FT_Vector pp[4];
1747 1805
1748 1806
1749 /* Each time we call load_truetype_glyph in this loop, the */ 1807 /* Each time we call load_truetype_glyph in this loop, the */
1750 /* value of `gloader.base.subglyphs' can change due to table */ 1808 /* value of `gloader.base.subglyphs' can change due to table */
1751 /* reallocations. We thus need to recompute the subglyph */ 1809 /* reallocations. We thus need to recompute the subglyph */
1752 /* pointer on each iteration. */ 1810 /* pointer on each iteration. */
1753 subglyph = gloader->base.subglyphs + num_base_subgs + n; 1811 subglyph = gloader->base.subglyphs + num_base_subgs + n;
1754 1812
1755 pp[0] = loader->pp1; 1813 pp[0] = loader->pp1;
1756 pp[1] = loader->pp2; 1814 pp[1] = loader->pp2;
1757 pp[2] = loader->pp3; 1815 pp[2] = loader->pp3;
1758 pp[3] = loader->pp4; 1816 pp[3] = loader->pp4;
1759 1817
1760 num_base_points = gloader->base.outline.n_points; 1818 num_base_points = (FT_UInt)gloader->base.outline.n_points;
1761 1819
1762 error = load_truetype_glyph( loader, subglyph->index, 1820 error = load_truetype_glyph( loader,
1763 recurse_count + 1, FALSE ); 1821 (FT_UInt)subglyph->index,
1822 recurse_count + 1,
1823 FALSE );
1764 if ( error ) 1824 if ( error )
1765 goto Exit; 1825 goto Exit;
1766 1826
1767 /* restore subglyph pointer */ 1827 /* restore subglyph pointer */
1768 subglyph = gloader->base.subglyphs + num_base_subgs + n; 1828 subglyph = gloader->base.subglyphs + num_base_subgs + n;
1769 1829
1770 /* restore phantom points if necessary */ 1830 /* restore phantom points if necessary */
1771 if ( !( subglyph->flags & USE_MY_METRICS ) ) 1831 if ( !( subglyph->flags & USE_MY_METRICS ) )
1772 { 1832 {
1773 loader->pp1 = pp[0]; 1833 loader->pp1 = pp[0];
1774 loader->pp2 = pp[1]; 1834 loader->pp2 = pp[1];
1775 loader->pp3 = pp[2]; 1835 loader->pp3 = pp[2];
1776 loader->pp4 = pp[3]; 1836 loader->pp4 = pp[3];
1777 } 1837 }
1778 1838
1779 num_points = gloader->base.outline.n_points; 1839 num_points = (FT_UInt)gloader->base.outline.n_points;
1780 1840
1781 if ( num_points == num_base_points ) 1841 if ( num_points == num_base_points )
1782 continue; 1842 continue;
1783 1843
1784 /* gloader->base.outline consists of three parts: */ 1844 /* gloader->base.outline consists of three parts: */
1785 /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */ 1845 /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
1786 /* */ 1846 /* */
1787 /* (1): exists from the beginning */ 1847 /* (1): exists from the beginning */
1788 /* (2): components that have been loaded so far */ 1848 /* (2): components that have been loaded so far */
1789 /* (3): the newly loaded component */ 1849 /* (3): the newly loaded component */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 #endif 1900 #endif
1841 1901
1842 return error; 1902 return error;
1843 } 1903 }
1844 1904
1845 1905
1846 static FT_Error 1906 static FT_Error
1847 compute_glyph_metrics( TT_Loader loader, 1907 compute_glyph_metrics( TT_Loader loader,
1848 FT_UInt glyph_index ) 1908 FT_UInt glyph_index )
1849 { 1909 {
1850 TT_Face face = (TT_Face)loader->face; 1910 TT_Face face = loader->face;
1851 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 1911 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1852 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); 1912 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
1853 #endif 1913 #endif
1854 1914
1855 FT_BBox bbox; 1915 FT_BBox bbox;
1856 FT_Fixed y_scale; 1916 FT_Fixed y_scale;
1857 TT_GlyphSlot glyph = loader->glyph; 1917 TT_GlyphSlot glyph = loader->glyph;
1858 TT_Size size = (TT_Size)loader->size; 1918 TT_Size size = loader->size;
1859 1919
1860 1920
1861 y_scale = 0x10000L; 1921 y_scale = 0x10000L;
1862 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 1922 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
1863 y_scale = size->root.metrics.y_scale; 1923 y_scale = size->root.metrics.y_scale;
1864 1924
1865 if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE ) 1925 if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE )
1866 FT_Outline_Get_CBox( &glyph->outline, &bbox ); 1926 FT_Outline_Get_CBox( &glyph->outline, &bbox );
1867 else 1927 else
1868 bbox = loader->bbox; 1928 bbox = loader->bbox;
1869 1929
1870 /* get the device-independent horizontal advance; it is scaled later */ 1930 /* get the device-independent horizontal advance; it is scaled later */
1871 /* by the base layer. */ 1931 /* by the base layer. */
1872 glyph->linearHoriAdvance = loader->linear; 1932 glyph->linearHoriAdvance = loader->linear;
1873 1933
1874 glyph->metrics.horiBearingX = bbox.xMin; 1934 glyph->metrics.horiBearingX = bbox.xMin;
1875 glyph->metrics.horiBearingY = bbox.yMax; 1935 glyph->metrics.horiBearingY = bbox.yMax;
1876 glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; 1936 glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
1877 1937
1878 /* adjust advance width to the value contained in the hdmx table */ 1938 /* adjust advance width to the value contained in the hdmx table */
1879 if ( !face->postscript.isFixedPitch && 1939 /* unless FT_LOAD_COMPUTE_METRICS is set */
1880 IS_HINTED( loader->load_flags ) ) 1940 if ( !face->postscript.isFixedPitch &&
1941 IS_HINTED( loader->load_flags ) &&
1942 !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) )
1881 { 1943 {
1882 FT_Byte* widthp; 1944 FT_Byte* widthp;
1883 1945
1884 1946
1885 widthp = tt_face_get_device_metrics( face, 1947 widthp = tt_face_get_device_metrics( face,
1886 size->root.metrics.x_ppem, 1948 size->root.metrics.x_ppem,
1887 glyph_index ); 1949 glyph_index );
1888 1950
1889 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 1951 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1890 1952
1891 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 ) 1953 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
1892 { 1954 {
1893 FT_Bool ignore_x_mode; 1955 FT_Bool ignore_x_mode;
1894 1956
1895 1957
1896 ignore_x_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) != 1958 ignore_x_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) !=
1897 FT_RENDER_MODE_MONO ); 1959 FT_RENDER_MODE_MONO );
1898 1960
1899 if ( widthp && 1961 if ( widthp &&
1900 ( ( ignore_x_mode && loader->exec->compatible_widths ) || 1962 ( ( ignore_x_mode && loader->exec->compatible_widths ) ||
1901 !ignore_x_mode || 1963 !ignore_x_mode ||
1902 SPH_OPTION_BITMAP_WIDTHS ) ) 1964 SPH_OPTION_BITMAP_WIDTHS ) )
1903 glyph->metrics.horiAdvance = *widthp << 6; 1965 glyph->metrics.horiAdvance = *widthp * 64;
1904 } 1966 }
1905 else 1967 else
1906 1968
1907 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ 1969 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
1908 1970
1909 { 1971 {
1910 if ( widthp ) 1972 if ( widthp )
1911 glyph->metrics.horiAdvance = *widthp << 6; 1973 glyph->metrics.horiAdvance = *widthp * 64;
1912 } 1974 }
1913 } 1975 }
1914 1976
1915 /* set glyph dimensions */ 1977 /* set glyph dimensions */
1916 glyph->metrics.width = bbox.xMax - bbox.xMin; 1978 glyph->metrics.width = bbox.xMax - bbox.xMin;
1917 glyph->metrics.height = bbox.yMax - bbox.yMin; 1979 glyph->metrics.height = bbox.yMax - bbox.yMin;
1918 1980
1919 /* Now take care of vertical metrics. In the case where there is */ 1981 /* Now take care of vertical metrics. In the case where there is */
1920 /* no vertical information within the font (relatively common), */ 1982 /* no vertical information within the font (relatively common), */
1921 /* create some metrics manually */ 1983 /* create some metrics manually */
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 TT_SBit_MetricsRec metrics; 2094 TT_SBit_MetricsRec metrics;
2033 2095
2034 2096
2035 face = (TT_Face)glyph->face; 2097 face = (TT_Face)glyph->face;
2036 sfnt = (SFNT_Service)face->sfnt; 2098 sfnt = (SFNT_Service)face->sfnt;
2037 stream = face->root.stream; 2099 stream = face->root.stream;
2038 2100
2039 error = sfnt->load_sbit_image( face, 2101 error = sfnt->load_sbit_image( face,
2040 size->strike_index, 2102 size->strike_index,
2041 glyph_index, 2103 glyph_index,
2042 (FT_Int)load_flags, 2104 (FT_UInt)load_flags,
2043 stream, 2105 stream,
2044 &glyph->bitmap, 2106 &glyph->bitmap,
2045 &metrics ); 2107 &metrics );
2046 if ( !error ) 2108 if ( !error )
2047 { 2109 {
2048 glyph->outline.n_points = 0; 2110 glyph->outline.n_points = 0;
2049 glyph->outline.n_contours = 0; 2111 glyph->outline.n_contours = 0;
2050 2112
2051 glyph->metrics.width = (FT_Pos)metrics.width << 6; 2113 glyph->metrics.width = (FT_Pos)metrics.width * 64;
2052 glyph->metrics.height = (FT_Pos)metrics.height << 6; 2114 glyph->metrics.height = (FT_Pos)metrics.height * 64;
2053 2115
2054 glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; 2116 glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX * 64;
2055 glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; 2117 glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY * 64;
2056 glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; 2118 glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance * 64;
2057 2119
2058 glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; 2120 glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX * 64;
2059 glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; 2121 glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY * 64;
2060 glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; 2122 glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance * 64;
2061 2123
2062 glyph->format = FT_GLYPH_FORMAT_BITMAP; 2124 glyph->format = FT_GLYPH_FORMAT_BITMAP;
2063 2125
2064 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) 2126 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
2065 { 2127 {
2066 glyph->bitmap_left = metrics.vertBearingX; 2128 glyph->bitmap_left = metrics.vertBearingX;
2067 glyph->bitmap_top = metrics.vertBearingY; 2129 glyph->bitmap_top = metrics.vertBearingY;
2068 } 2130 }
2069 else 2131 else
2070 { 2132 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 2166
2105 /* load execution context */ 2167 /* load execution context */
2106 if ( IS_HINTED( load_flags ) && !glyf_table_only ) 2168 if ( IS_HINTED( load_flags ) && !glyf_table_only )
2107 { 2169 {
2108 TT_ExecContext exec; 2170 TT_ExecContext exec;
2109 FT_Bool grayscale; 2171 FT_Bool grayscale;
2110 2172
2111 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 2173 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
2112 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); 2174 TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
2113 2175
2114 FT_Bool subpixel = FALSE; 2176 FT_Bool subpixel_hinting = FALSE;
2115 2177
2116 #if 0 2178 #if 0
2117 /* not used yet */ 2179 /* not used yet */
2118 FT_Bool compatible_widths; 2180 FT_Bool compatible_widths;
2119 FT_Bool symmetrical_smoothing; 2181 FT_Bool symmetrical_smoothing;
2120 FT_Bool bgr; 2182 FT_Bool bgr;
2183 FT_Bool vertical_lcd;
2121 FT_Bool subpixel_positioned; 2184 FT_Bool subpixel_positioned;
2185 FT_Bool gray_cleartype;
2122 #endif 2186 #endif
2123 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ 2187 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
2124 2188
2125 FT_Bool reexecute = FALSE; 2189 FT_Bool reexecute = FALSE;
2126 2190
2127 2191
2128 if ( size->bytecode_ready < 0 || size->cvt_ready < 0 ) 2192 if ( size->bytecode_ready < 0 || size->cvt_ready < 0 )
2129 { 2193 {
2130 error = tt_size_ready_bytecode( size, pedantic ); 2194 error = tt_size_ready_bytecode( size, pedantic );
2131 if ( error ) 2195 if ( error )
2132 return error; 2196 return error;
2133 } 2197 }
2134 else if ( size->bytecode_ready ) 2198 else if ( size->bytecode_ready )
2135 return size->bytecode_ready; 2199 return size->bytecode_ready;
2136 else if ( size->cvt_ready ) 2200 else if ( size->cvt_ready )
2137 return size->cvt_ready; 2201 return size->cvt_ready;
2138 2202
2139 /* query new execution context */ 2203 /* query new execution context */
2140 exec = size->debug ? size->context 2204 exec = size->context;
2141 : ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
2142 if ( !exec ) 2205 if ( !exec )
2143 return FT_THROW( Could_Not_Find_Context ); 2206 return FT_THROW( Could_Not_Find_Context );
2144 2207
2145 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 2208 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
2146 2209
2147 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 ) 2210 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
2148 { 2211 {
2149 subpixel = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags ) != 2212 subpixel_hinting = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags ) !=
2150 FT_RENDER_MODE_MONO ) && 2213 FT_RENDER_MODE_MONO ) &&
2151 SPH_OPTION_SET_SUBPIXEL ); 2214 SPH_OPTION_SET_SUBPIXEL );
2152 2215
2153 if ( subpixel ) 2216 if ( subpixel_hinting )
2154 grayscale = FALSE; 2217 grayscale = FALSE;
2155 else if ( SPH_OPTION_SET_GRAYSCALE ) 2218 else if ( SPH_OPTION_SET_GRAYSCALE )
2156 { 2219 {
2157 grayscale = TRUE; 2220 grayscale = TRUE;
2158 subpixel = FALSE; 2221 subpixel_hinting = FALSE;
2159 } 2222 }
2160 else 2223 else
2161 grayscale = FALSE; 2224 grayscale = FALSE;
2162 2225
2163 if ( FT_IS_TRICKY( glyph->face ) ) 2226 if ( FT_IS_TRICKY( glyph->face ) )
2164 subpixel = FALSE; 2227 subpixel_hinting = FALSE;
2165 2228
2166 exec->ignore_x_mode = subpixel || grayscale; 2229 exec->ignore_x_mode = subpixel_hinting || grayscale;
2167 exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION; 2230 exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
2168 if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 ) 2231 if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
2169 exec->rasterizer_version = TT_INTERPRETER_VERSION_35; 2232 exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
2170 2233
2171 #if 1 2234 #if 1
2172 exec->compatible_widths = SPH_OPTION_SET_COMPATIBLE_WIDTHS; 2235 exec->compatible_widths = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
2173 exec->symmetrical_smoothing = FALSE; 2236 exec->symmetrical_smoothing = TRUE;
2174 exec->bgr = FALSE; 2237 exec->bgr = FALSE;
2238 exec->vertical_lcd = FALSE;
2175 exec->subpixel_positioned = TRUE; 2239 exec->subpixel_positioned = TRUE;
2240 exec->gray_cleartype = FALSE;
2176 #else /* 0 */ 2241 #else /* 0 */
2177 exec->compatible_widths = 2242 exec->compatible_widths =
2178 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != 2243 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2179 TT_LOAD_COMPATIBLE_WIDTHS ); 2244 TT_LOAD_COMPATIBLE_WIDTHS );
2180 exec->symmetrical_smoothing = 2245 exec->symmetrical_smoothing =
2181 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != 2246 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2182 TT_LOAD_SYMMETRICAL_SMOOTHING ); 2247 TT_LOAD_SYMMETRICAL_SMOOTHING );
2183 exec->bgr = 2248 exec->bgr =
2184 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != 2249 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2185 TT_LOAD_BGR ); 2250 TT_LOAD_BGR );
2251 exec->vertical_lcd =
2252 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2253 TT_LOAD_VERTICAL_LCD );
2186 exec->subpixel_positioned = 2254 exec->subpixel_positioned =
2187 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != 2255 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2188 TT_LOAD_SUBPIXEL_POSITIONED ); 2256 TT_LOAD_SUBPIXEL_POSITIONED );
2257 exec->gray_cleartype =
2258 FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2259 TT_LOAD_GRAY_CLEARTYPE );
2189 #endif /* 0 */ 2260 #endif /* 0 */
2190 2261
2191 } 2262 }
2192 else 2263 else
2193 2264
2194 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ 2265 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
2195 2266
2196 { 2267 {
2197 grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != 2268 grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
2198 FT_RENDER_MODE_MONO ); 2269 FT_RENDER_MODE_MONO );
2199 } 2270 }
2200 2271
2201 error = TT_Load_Context( exec, face, size ); 2272 error = TT_Load_Context( exec, face, size );
2202 if ( error ) 2273 if ( error )
2203 return error; 2274 return error;
2204 2275
2205 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 2276 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
2206 2277
2207 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 ) 2278 if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
2208 { 2279 {
2209 /* a change from mono to subpixel rendering (and vice versa) */ 2280 /* a change from mono to subpixel rendering (and vice versa) */
2210 /* requires a re-execution of the CVT program */ 2281 /* requires a re-execution of the CVT program */
2211 if ( subpixel != exec->subpixel ) 2282 if ( subpixel_hinting != exec->subpixel_hinting )
2212 { 2283 {
2213 FT_TRACE4(( "tt_loader_init: subpixel hinting change," 2284 FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
2214 " re-executing `prep' table\n" )); 2285 " re-executing `prep' table\n" ));
2215 2286
2216 exec->subpixel = subpixel; 2287 exec->subpixel_hinting = subpixel_hinting;
2217 reexecute = TRUE; 2288 reexecute = TRUE;
2218 } 2289 }
2219 2290
2220 /* a change from mono to grayscale rendering (and vice versa) */ 2291 /* a change from mono to grayscale rendering (and vice versa) */
2221 /* requires a re-execution of the CVT program */ 2292 /* requires a re-execution of the CVT program */
2222 if ( grayscale != exec->grayscale ) 2293 if ( grayscale != exec->grayscale )
2223 { 2294 {
2224 FT_TRACE4(( "tt_loader_init: grayscale hinting change," 2295 FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
2225 " re-executing `prep' table\n" )); 2296 " re-executing `prep' table\n" ));
2226 2297
2227 exec->grayscale = grayscale; 2298 exec->grayscale = grayscale;
2228 reexecute = TRUE; 2299 reexecute = TRUE;
2229 } 2300 }
2230 } 2301 }
2231 else 2302 else
2232 2303
2233 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ 2304 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
2234 2305
2235 { 2306 {
2236 /* a change from mono to grayscale rendering (and vice versa) */ 2307 /* a change from mono to grayscale rendering (and vice versa) */
2237 /* requires a re-execution of the CVT program */ 2308 /* requires a re-execution of the CVT program */
2238 if ( grayscale != exec->grayscale ) 2309 if ( grayscale != exec->grayscale )
2239 { 2310 {
2240 FT_TRACE4(( "tt_loader_init: grayscale change," 2311 FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
2241 " re-executing `prep' table\n" )); 2312 " re-executing `prep' table\n" ));
2242 2313
2243 exec->grayscale = grayscale; 2314 exec->grayscale = grayscale;
2244 reexecute = TRUE; 2315 reexecute = TRUE;
2245 } 2316 }
2246 } 2317 }
2247 2318
2248 if ( reexecute ) 2319 if ( reexecute )
2249 { 2320 {
2250 FT_UInt i; 2321 FT_UInt i;
2251 2322
2252 2323
2253 for ( i = 0; i < size->cvt_size; i++ ) 2324 for ( i = 0; i < size->cvt_size; i++ )
2254 size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); 2325 size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
2255 error = tt_size_run_prep( size, pedantic ); 2326 error = tt_size_run_prep( size, pedantic );
2256 if ( error ) 2327 if ( error )
2257 return error; 2328 return error;
2258 } 2329 }
2259 2330
2260 /* see whether the cvt program has disabled hinting */ 2331 /* check whether the cvt program has disabled hinting */
2261 if ( exec->GS.instruct_control & 1 ) 2332 if ( exec->GS.instruct_control & 1 )
2262 load_flags |= FT_LOAD_NO_HINTING; 2333 load_flags |= FT_LOAD_NO_HINTING;
2263 2334
2264 /* load default graphics state -- if needed */ 2335 /* load default graphics state -- if needed */
2265 if ( exec->GS.instruct_control & 2 ) 2336 if ( exec->GS.instruct_control & 2 )
2266 exec->GS = tt_default_graphics_state; 2337 exec->GS = tt_default_graphics_state;
2267 2338
2339 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
2340 /* check whether we have a font hinted for ClearType -- */
2341 /* note that this flag can also be modified in a glyph's bytecode */
2342 if ( exec->GS.instruct_control & 4 )
2343 exec->ignore_x_mode = 0;
2344 #endif
2345
2268 exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC ); 2346 exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
2269 loader->exec = exec; 2347 loader->exec = exec;
2270 loader->instructions = exec->glyphIns; 2348 loader->instructions = exec->glyphIns;
2271 } 2349 }
2272 2350
2273 #endif /* TT_USE_BYTECODE_INTERPRETER */ 2351 #endif /* TT_USE_BYTECODE_INTERPRETER */
2274 2352
2275 /* seek to the beginning of the glyph table -- for Type 42 fonts */ 2353 /* seek to the beginning of the glyph table -- for Type 42 fonts */
2276 /* the table might be accessed from a Postscript stream or something */ 2354 /* the table might be accessed from a Postscript stream or something */
2277 /* else... */ 2355 /* else... */
(...skipping 23 matching lines...) Expand all
2301 /* get face's glyph loader */ 2379 /* get face's glyph loader */
2302 if ( !glyf_table_only ) 2380 if ( !glyf_table_only )
2303 { 2381 {
2304 FT_GlyphLoader gloader = glyph->internal->loader; 2382 FT_GlyphLoader gloader = glyph->internal->loader;
2305 2383
2306 2384
2307 FT_GlyphLoader_Rewind( gloader ); 2385 FT_GlyphLoader_Rewind( gloader );
2308 loader->gloader = gloader; 2386 loader->gloader = gloader;
2309 } 2387 }
2310 2388
2311 loader->load_flags = load_flags; 2389 loader->load_flags = (FT_ULong)load_flags;
2312 2390
2313 loader->face = (FT_Face)face; 2391 loader->face = face;
2314 loader->size = (FT_Size)size; 2392 loader->size = size;
2315 loader->glyph = (FT_GlyphSlot)glyph; 2393 loader->glyph = (FT_GlyphSlot)glyph;
2316 loader->stream = stream; 2394 loader->stream = stream;
2317 2395
2318 return FT_Err_Ok; 2396 return FT_Err_Ok;
2319 } 2397 }
2320 2398
2321 2399
2322 /*************************************************************************/ 2400 /*************************************************************************/
2323 /* */ 2401 /* */
2324 /* <Function> */ 2402 /* <Function> */
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 /* */ 2554 /* */
2477 if ( !( load_flags & FT_LOAD_NO_SCALE ) && 2555 if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
2478 size->root.metrics.y_ppem < 24 ) 2556 size->root.metrics.y_ppem < 24 )
2479 glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION; 2557 glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
2480 2558
2481 return error; 2559 return error;
2482 } 2560 }
2483 2561
2484 2562
2485 /* END */ 2563 /* END */
OLDNEW
« no previous file with comments | « third_party/freetype/src/truetype/ttgload.h ('k') | third_party/freetype/src/truetype/ttgxvar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698