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

Side by Side Diff: third_party/freetype/src/truetype/ttobjs.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
« no previous file with comments | « third_party/freetype/src/truetype/ttobjs.h ('k') | third_party/freetype/src/truetype/ttpic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* ttobjs.c */ 3 /* ttobjs.c */
4 /* */ 4 /* */
5 /* Objects manager (body). */ 5 /* Objects manager (body). */
6 /* */ 6 /* */
7 /* Copyright 1996-2013 */ 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 /* For example, Quartz ContextPDF clears all entries, or Bullzip PDF */ 184 /* For example, Quartz ContextPDF clears all entries, or Bullzip PDF */
185 /* Printer clears the entries for subsetted subtables. We thus have to */ 185 /* Printer clears the entries for subsetted subtables. We thus have to */
186 /* recalculate the checksums where necessary. */ 186 /* recalculate the checksums where necessary. */
187 187
188 static FT_UInt32 188 static FT_UInt32
189 tt_synth_sfnt_checksum( FT_Stream stream, 189 tt_synth_sfnt_checksum( FT_Stream stream,
190 FT_ULong length ) 190 FT_ULong length )
191 { 191 {
192 FT_Error error; 192 FT_Error error;
193 FT_UInt32 checksum = 0; 193 FT_UInt32 checksum = 0;
194 int i; 194 FT_UInt i;
195 195
196 196
197 if ( FT_FRAME_ENTER( length ) ) 197 if ( FT_FRAME_ENTER( length ) )
198 return 0; 198 return 0;
199 199
200 for ( ; length > 3; length -= 4 ) 200 for ( ; length > 3; length -= 4 )
201 checksum += (FT_UInt32)FT_GET_ULONG(); 201 checksum += (FT_UInt32)FT_GET_ULONG();
202 202
203 for ( i = 3; length > 0; length --, i-- ) 203 for ( i = 3; length > 0; length--, i-- )
204 checksum += (FT_UInt32)( FT_GET_BYTE() << ( i * 8 ) ); 204 checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 );
205 205
206 FT_FRAME_EXIT(); 206 FT_FRAME_EXIT();
207 207
208 return checksum; 208 return checksum;
209 } 209 }
210 210
211 211
212 /* XXX: This function should be in the `sfnt' module. */ 212 /* XXX: This function should be in the `sfnt' module. */
213 213
214 static FT_ULong 214 static FT_ULong
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 #define TRICK_SFNT_IDS_NUM_FACES 17 249 #define TRICK_SFNT_IDS_NUM_FACES 17
250 250
251 static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES] 251 static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES]
252 [TRICK_SFNT_IDS_PER_FACE] = { 252 [TRICK_SFNT_IDS_PER_FACE] = {
253 253
254 #define TRICK_SFNT_ID_cvt 0 254 #define TRICK_SFNT_ID_cvt 0
255 #define TRICK_SFNT_ID_fpgm 1 255 #define TRICK_SFNT_ID_fpgm 1
256 #define TRICK_SFNT_ID_prep 2 256 #define TRICK_SFNT_ID_prep 2
257 257
258 { /* MingLiU 1995 */ 258 { /* MingLiU 1995 */
259 { 0x05bcf058, 0x000002e4 }, /* cvt */ 259 { 0x05BCF058UL, 0x000002E4UL }, /* cvt */
260 { 0x28233bf1, 0x000087c4 }, /* fpgm */ 260 { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
261 { 0xa344a1ea, 0x000001e1 } /* prep */ 261 { 0xA344A1EAUL, 0x000001E1UL } /* prep */
262 }, 262 },
263 { /* MingLiU 1996- */ 263 { /* MingLiU 1996- */
264 { 0x05bcf058, 0x000002e4 }, /* cvt */ 264 { 0x05BCF058UL, 0x000002E4UL }, /* cvt */
265 { 0x28233bf1, 0x000087c4 }, /* fpgm */ 265 { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
266 { 0xa344a1eb, 0x000001e1 } /* prep */ 266 { 0xA344A1EBUL, 0x000001E1UL } /* prep */
267 }, 267 },
268 { /* DFKaiShu */ 268 { /* DFKaiShu */
269 { 0x11e5ead4, 0x00000350 }, /* cvt */ 269 { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
270 { 0x5a30ca3b, 0x00009063 }, /* fpgm */ 270 { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */
271 { 0x13a42602, 0x0000007e } /* prep */ 271 { 0x13A42602UL, 0x0000007EUL } /* prep */
272 }, 272 },
273 { /* HuaTianKaiTi */ 273 { /* HuaTianKaiTi */
274 { 0xfffbfffc, 0x00000008 }, /* cvt */ 274 { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
275 { 0x9c9e48b8, 0x0000bea2 }, /* fpgm */ 275 { 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */
276 { 0x70020112, 0x00000008 } /* prep */ 276 { 0x70020112UL, 0x00000008UL } /* prep */
277 }, 277 },
278 { /* HuaTianSongTi */ 278 { /* HuaTianSongTi */
279 { 0xfffbfffc, 0x00000008 }, /* cvt */ 279 { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
280 { 0x0a5a0483, 0x00017c39 }, /* fpgm */ 280 { 0x0A5A0483UL, 0x00017C39UL }, /* fpgm */
281 { 0x70020112, 0x00000008 } /* prep */ 281 { 0x70020112UL, 0x00000008UL } /* prep */
282 }, 282 },
283 { /* NEC fadpop7.ttf */ 283 { /* NEC fadpop7.ttf */
284 { 0x00000000, 0x00000000 }, /* cvt */ 284 { 0x00000000UL, 0x00000000UL }, /* cvt */
285 { 0x40c92555, 0x000000e5 }, /* fpgm */ 285 { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
286 { 0xa39b58e3, 0x0000117c } /* prep */ 286 { 0xA39B58E3UL, 0x0000117CUL } /* prep */
287 }, 287 },
288 { /* NEC fadrei5.ttf */ 288 { /* NEC fadrei5.ttf */
289 { 0x00000000, 0x00000000 }, /* cvt */ 289 { 0x00000000UL, 0x00000000UL }, /* cvt */
290 { 0x33c41652, 0x000000e5 }, /* fpgm */ 290 { 0x33C41652UL, 0x000000E5UL }, /* fpgm */
291 { 0x26d6c52a, 0x00000f6a } /* prep */ 291 { 0x26D6C52AUL, 0x00000F6AUL } /* prep */
292 }, 292 },
293 { /* NEC fangot7.ttf */ 293 { /* NEC fangot7.ttf */
294 { 0x00000000, 0x00000000 }, /* cvt */ 294 { 0x00000000UL, 0x00000000UL }, /* cvt */
295 { 0x6db1651d, 0x0000019d }, /* fpgm */ 295 { 0x6DB1651DUL, 0x0000019DUL }, /* fpgm */
296 { 0x6c6e4b03, 0x00002492 } /* prep */ 296 { 0x6C6E4B03UL, 0x00002492UL } /* prep */
297 }, 297 },
298 { /* NEC fangyo5.ttf */ 298 { /* NEC fangyo5.ttf */
299 { 0x00000000, 0x00000000 }, /* cvt */ 299 { 0x00000000UL, 0x00000000UL }, /* cvt */
300 { 0x40c92555, 0x000000e5 }, /* fpgm */ 300 { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
301 { 0xde51fad0, 0x0000117c } /* prep */ 301 { 0xDE51FAD0UL, 0x0000117CUL } /* prep */
302 }, 302 },
303 { /* NEC fankyo5.ttf */ 303 { /* NEC fankyo5.ttf */
304 { 0x00000000, 0x00000000 }, /* cvt */ 304 { 0x00000000UL, 0x00000000UL }, /* cvt */
305 { 0x85e47664, 0x000000e5 }, /* fpgm */ 305 { 0x85E47664UL, 0x000000E5UL }, /* fpgm */
306 { 0xa6c62831, 0x00001caa } /* prep */ 306 { 0xA6C62831UL, 0x00001CAAUL } /* prep */
307 }, 307 },
308 { /* NEC fanrgo5.ttf */ 308 { /* NEC fanrgo5.ttf */
309 { 0x00000000, 0x00000000 }, /* cvt */ 309 { 0x00000000UL, 0x00000000UL }, /* cvt */
310 { 0x2d891cfd, 0x0000019d }, /* fpgm */ 310 { 0x2D891CFDUL, 0x0000019DUL }, /* fpgm */
311 { 0xa0604633, 0x00001de8 } /* prep */ 311 { 0xA0604633UL, 0x00001DE8UL } /* prep */
312 }, 312 },
313 { /* NEC fangot5.ttc */ 313 { /* NEC fangot5.ttc */
314 { 0x00000000, 0x00000000 }, /* cvt */ 314 { 0x00000000UL, 0x00000000UL }, /* cvt */
315 { 0x40aa774c, 0x000001cb }, /* fpgm */ 315 { 0x40AA774CUL, 0x000001CBUL }, /* fpgm */
316 { 0x9b5caa96, 0x00001f9a } /* prep */ 316 { 0x9B5CAA96UL, 0x00001F9AUL } /* prep */
317 }, 317 },
318 { /* NEC fanmin3.ttc */ 318 { /* NEC fanmin3.ttc */
319 { 0x00000000, 0x00000000 }, /* cvt */ 319 { 0x00000000UL, 0x00000000UL }, /* cvt */
320 { 0x0d3de9cb, 0x00000141 }, /* fpgm */ 320 { 0x0D3DE9CBUL, 0x00000141UL }, /* fpgm */
321 { 0xd4127766, 0x00002280 } /* prep */ 321 { 0xD4127766UL, 0x00002280UL } /* prep */
322 }, 322 },
323 { /* NEC FA-Gothic, 1996 */ 323 { /* NEC FA-Gothic, 1996 */
324 { 0x00000000, 0x00000000 }, /* cvt */ 324 { 0x00000000UL, 0x00000000UL }, /* cvt */
325 { 0x4a692698, 0x000001f0 }, /* fpgm */ 325 { 0x4A692698UL, 0x000001F0UL }, /* fpgm */
326 { 0x340d4346, 0x00001fca } /* prep */ 326 { 0x340D4346UL, 0x00001FCAUL } /* prep */
327 }, 327 },
328 { /* NEC FA-Minchou, 1996 */ 328 { /* NEC FA-Minchou, 1996 */
329 { 0x00000000, 0x00000000 }, /* cvt */ 329 { 0x00000000UL, 0x00000000UL }, /* cvt */
330 { 0xcd34c604, 0x00000166 }, /* fpgm */ 330 { 0xCD34C604UL, 0x00000166UL }, /* fpgm */
331 { 0x6cf31046, 0x000022b0 } /* prep */ 331 { 0x6CF31046UL, 0x000022B0UL } /* prep */
332 }, 332 },
333 { /* NEC FA-RoundGothicB, 1996 */ 333 { /* NEC FA-RoundGothicB, 1996 */
334 { 0x00000000, 0x00000000 }, /* cvt */ 334 { 0x00000000UL, 0x00000000UL }, /* cvt */
335 { 0x5da75315, 0x0000019d }, /* fpgm */ 335 { 0x5DA75315UL, 0x0000019DUL }, /* fpgm */
336 { 0x40745a5f, 0x000022e0 } /* prep */ 336 { 0x40745A5FUL, 0x000022E0UL } /* prep */
337 }, 337 },
338 { /* NEC FA-RoundGothicM, 1996 */ 338 { /* NEC FA-RoundGothicM, 1996 */
339 { 0x00000000, 0x00000000 }, /* cvt */ 339 { 0x00000000UL, 0x00000000UL }, /* cvt */
340 { 0xf055fc48, 0x000001c2 }, /* fpgm */ 340 { 0xF055FC48UL, 0x000001C2UL }, /* fpgm */
341 { 0x3900ded3, 0x00001e18 } /* prep */ 341 { 0x3900DED3UL, 0x00001E18UL } /* prep */
342 } 342 }
343 }; 343 };
344 344
345 FT_ULong checksum; 345 FT_ULong checksum;
346 int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES]; 346 int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES];
347 FT_Bool has_cvt, has_fpgm, has_prep; 347 FT_Bool has_cvt, has_fpgm, has_prep;
348 FT_UShort i; 348 FT_UShort i;
349 int j, k; 349 int j, k;
350 350
351 351
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 /* */ 483 /* */
484 /* <Function> */ 484 /* <Function> */
485 /* tt_face_init */ 485 /* tt_face_init */
486 /* */ 486 /* */
487 /* <Description> */ 487 /* <Description> */
488 /* Initialize a given TrueType face object. */ 488 /* Initialize a given TrueType face object. */
489 /* */ 489 /* */
490 /* <Input> */ 490 /* <Input> */
491 /* stream :: The source font stream. */ 491 /* stream :: The source font stream. */
492 /* */ 492 /* */
493 /* face_index :: The index of the font face in the resource. */ 493 /* face_index :: The index of the TrueType font, if we are opening a */
494 /* collection, in bits 0-15. The numbered instance */
495 /* index~+~1 of a GX (sub)font, if applicable, in bits */
496 /* 16-30. */
494 /* */ 497 /* */
495 /* num_params :: Number of additional generic parameters. Ignored. */ 498 /* num_params :: Number of additional generic parameters. Ignored. */
496 /* */ 499 /* */
497 /* params :: Additional generic parameters. Ignored. */ 500 /* params :: Additional generic parameters. Ignored. */
498 /* */ 501 /* */
499 /* <InOut> */ 502 /* <InOut> */
500 /* face :: The newly built face object. */ 503 /* face :: The newly built face object. */
501 /* */ 504 /* */
502 /* <Return> */ 505 /* <Return> */
503 /* FreeType error code. 0 means success. */ 506 /* FreeType error code. 0 means success. */
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 tt_check_single_notdef( ttface ) ) 595 tt_check_single_notdef( ttface ) )
593 { 596 {
594 FT_TRACE5(( "tt_face_init:" 597 FT_TRACE5(( "tt_face_init:"
595 " Only the `.notdef' glyph has an outline.\n" 598 " Only the `.notdef' glyph has an outline.\n"
596 " " 599 " "
597 " Resetting scalable flag to FALSE.\n" )); 600 " Resetting scalable flag to FALSE.\n" ));
598 601
599 ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; 602 ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
600 } 603 }
601 604
602 #else 605 #else /* !FT_CONFIG_OPTION_INCREMENTAL */
603 606
604 if ( !error ) 607 if ( !error )
605 error = tt_face_load_loca( face, stream ); 608 error = tt_face_load_loca( face, stream );
606 if ( !error ) 609 if ( !error )
607 error = tt_face_load_cvt( face, stream ); 610 error = tt_face_load_cvt( face, stream );
608 if ( !error ) 611 if ( !error )
609 error = tt_face_load_fpgm( face, stream ); 612 error = tt_face_load_fpgm( face, stream );
610 if ( !error ) 613 if ( !error )
611 error = tt_face_load_prep( face, stream ); 614 error = tt_face_load_prep( face, stream );
612 615
613 /* Check the scalable flag based on `loca'. */ 616 /* Check the scalable flag based on `loca'. */
614 if ( ttface->num_fixed_sizes && 617 if ( ttface->num_fixed_sizes &&
615 face->glyph_locations && 618 face->glyph_locations &&
616 tt_check_single_notdef( ttface ) ) 619 tt_check_single_notdef( ttface ) )
617 { 620 {
618 FT_TRACE5(( "tt_face_init:" 621 FT_TRACE5(( "tt_face_init:"
619 " Only the `.notdef' glyph has an outline.\n" 622 " Only the `.notdef' glyph has an outline.\n"
620 " " 623 " "
621 " Resetting scalable flag to FALSE.\n" )); 624 " Resetting scalable flag to FALSE.\n" ));
622 625
623 ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; 626 ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
624 } 627 }
625 628
626 #endif 629 #endif /* !FT_CONFIG_OPTION_INCREMENTAL */
627 630
628 } 631 }
629 632
633 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
634
635 {
636 FT_Int instance_index = face_index >> 16;
637
638
639 if ( FT_HAS_MULTIPLE_MASTERS( ttface ) &&
640 instance_index > 0 )
641 {
642 error = TT_Get_MM_Var( face, NULL );
643 if ( error )
644 goto Exit;
645
646 if ( face->blend->mmvar->namedstyle )
647 {
648 FT_Memory memory = ttface->memory;
649
650 FT_Var_Named_Style* named_style;
651 FT_String* style_name;
652
653
654 /* in `face_index', the instance index starts with value 1 */
655 named_style = face->blend->mmvar->namedstyle + instance_index - 1;
656 error = sfnt->get_name( face,
657 (FT_UShort)named_style->strid,
658 &style_name );
659 if ( error )
660 goto Exit;
661
662 /* set style name; if already set, replace it */
663 if ( face->root.style_name )
664 FT_FREE( face->root.style_name );
665 face->root.style_name = style_name;
666
667 /* finally, select the named instance */
668 error = TT_Set_Var_Design( face,
669 face->blend->mmvar->num_axis,
670 named_style->coords );
671 if ( error )
672 goto Exit;
673 }
674 }
675 }
676
677 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
678
630 #if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \ 679 #if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
631 !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER ) 680 !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
632 681
633 { 682 {
634 FT_Bool unpatented_hinting; 683 FT_Bool unpatented_hinting;
635 int i; 684 int i;
636 685
637 686
638 /* Determine whether unpatented hinting is to be used for this face. */ 687 /* Determine whether unpatented hinting is to be used for this face. */
639 unpatented_hinting = FT_BOOL 688 unpatented_hinting = FT_BOOL
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 /* */ 793 /* */
745 FT_LOCAL_DEF( FT_Error ) 794 FT_LOCAL_DEF( FT_Error )
746 tt_size_run_fpgm( TT_Size size, 795 tt_size_run_fpgm( TT_Size size,
747 FT_Bool pedantic ) 796 FT_Bool pedantic )
748 { 797 {
749 TT_Face face = (TT_Face)size->root.face; 798 TT_Face face = (TT_Face)size->root.face;
750 TT_ExecContext exec; 799 TT_ExecContext exec;
751 FT_Error error; 800 FT_Error error;
752 801
753 802
754 /* debugging instances have their own context */ 803 exec = size->context;
755 if ( size->debug )
756 exec = size->context;
757 else
758 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
759
760 if ( !exec )
761 return FT_THROW( Could_Not_Find_Context );
762 804
763 error = TT_Load_Context( exec, face, size ); 805 error = TT_Load_Context( exec, face, size );
764 if ( error ) 806 if ( error )
765 return error; 807 return error;
766 808
767 exec->callTop = 0; 809 exec->callTop = 0;
768 exec->top = 0; 810 exec->top = 0;
769 811
770 exec->period = 64; 812 exec->period = 64;
771 exec->phase = 0; 813 exec->phase = 0;
(...skipping 16 matching lines...) Expand all
788 830
789 tt_metrics->ppem = 0; 831 tt_metrics->ppem = 0;
790 tt_metrics->scale = 0; 832 tt_metrics->scale = 0;
791 tt_metrics->ratio = 0x10000L; 833 tt_metrics->ratio = 0x10000L;
792 } 834 }
793 835
794 /* allow font program execution */ 836 /* allow font program execution */
795 TT_Set_CodeRange( exec, 837 TT_Set_CodeRange( exec,
796 tt_coderange_font, 838 tt_coderange_font,
797 face->font_program, 839 face->font_program,
798 face->font_program_size ); 840 (FT_Long)face->font_program_size );
799 841
800 /* disable CVT and glyph programs coderange */ 842 /* disable CVT and glyph programs coderange */
801 TT_Clear_CodeRange( exec, tt_coderange_cvt ); 843 TT_Clear_CodeRange( exec, tt_coderange_cvt );
802 TT_Clear_CodeRange( exec, tt_coderange_glyph ); 844 TT_Clear_CodeRange( exec, tt_coderange_glyph );
803 845
804 if ( face->font_program_size > 0 ) 846 if ( face->font_program_size > 0 )
805 { 847 {
806 TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); 848 TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
807 849
808 FT_TRACE4(( "Executing `fpgm' table.\n" )); 850 FT_TRACE4(( "Executing `fpgm' table.\n" ));
(...skipping 29 matching lines...) Expand all
838 /* */ 880 /* */
839 FT_LOCAL_DEF( FT_Error ) 881 FT_LOCAL_DEF( FT_Error )
840 tt_size_run_prep( TT_Size size, 882 tt_size_run_prep( TT_Size size,
841 FT_Bool pedantic ) 883 FT_Bool pedantic )
842 { 884 {
843 TT_Face face = (TT_Face)size->root.face; 885 TT_Face face = (TT_Face)size->root.face;
844 TT_ExecContext exec; 886 TT_ExecContext exec;
845 FT_Error error; 887 FT_Error error;
846 888
847 889
848 /* debugging instances have their own context */ 890 exec = size->context;
849 if ( size->debug )
850 exec = size->context;
851 else
852 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
853
854 if ( !exec )
855 return FT_THROW( Could_Not_Find_Context );
856 891
857 error = TT_Load_Context( exec, face, size ); 892 error = TT_Load_Context( exec, face, size );
858 if ( error ) 893 if ( error )
859 return error; 894 return error;
860 895
861 exec->callTop = 0; 896 exec->callTop = 0;
862 exec->top = 0; 897 exec->top = 0;
863 898
864 exec->instruction_trap = FALSE; 899 exec->instruction_trap = FALSE;
865 900
866 exec->pedantic_hinting = pedantic; 901 exec->pedantic_hinting = pedantic;
867 902
868 TT_Set_CodeRange( exec, 903 TT_Set_CodeRange( exec,
869 tt_coderange_cvt, 904 tt_coderange_cvt,
870 face->cvt_program, 905 face->cvt_program,
871 face->cvt_program_size ); 906 (FT_Long)face->cvt_program_size );
872 907
873 TT_Clear_CodeRange( exec, tt_coderange_glyph ); 908 TT_Clear_CodeRange( exec, tt_coderange_glyph );
874 909
875 if ( face->cvt_program_size > 0 ) 910 if ( face->cvt_program_size > 0 )
876 { 911 {
877 TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); 912 TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
878 913
879 if ( !size->debug ) 914 FT_TRACE4(( "Executing `prep' table.\n" ));
880 {
881 FT_TRACE4(( "Executing `prep' table.\n" ));
882 915
883 error = face->interpreter( exec ); 916 error = face->interpreter( exec );
884 }
885 } 917 }
886 else 918 else
887 error = FT_Err_Ok; 919 error = FT_Err_Ok;
888 920
889 size->cvt_ready = error; 921 size->cvt_ready = error;
890 922
891 /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */ 923 /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */
892 /* graphics state variables to be modified by the CVT program. */ 924 /* graphics state variables to be modified by the CVT program. */
893 925
894 exec->GS.dualVector.x = 0x4000; 926 exec->GS.dualVector.x = 0x4000;
(...skipping 22 matching lines...) Expand all
917 } 949 }
918 950
919 951
920 static void 952 static void
921 tt_size_done_bytecode( FT_Size ftsize ) 953 tt_size_done_bytecode( FT_Size ftsize )
922 { 954 {
923 TT_Size size = (TT_Size)ftsize; 955 TT_Size size = (TT_Size)ftsize;
924 TT_Face face = (TT_Face)ftsize->face; 956 TT_Face face = (TT_Face)ftsize->face;
925 FT_Memory memory = face->root.memory; 957 FT_Memory memory = face->root.memory;
926 958
927 959 if ( size->context )
928 if ( size->debug )
929 { 960 {
930 /* the debug context must be deleted by the debugger itself */ 961 TT_Done_Context( size->context );
931 size->context = NULL; 962 size->context = NULL;
932 size->debug = FALSE;
933 } 963 }
934 964
935 FT_FREE( size->cvt ); 965 FT_FREE( size->cvt );
936 size->cvt_size = 0; 966 size->cvt_size = 0;
937 967
938 /* free storage area */ 968 /* free storage area */
939 FT_FREE( size->storage ); 969 FT_FREE( size->storage );
940 size->storage_size = 0; 970 size->storage_size = 0;
941 971
942 /* twilight zone */ 972 /* twilight zone */
(...skipping 23 matching lines...) Expand all
966 { 996 {
967 FT_Error error; 997 FT_Error error;
968 TT_Size size = (TT_Size)ftsize; 998 TT_Size size = (TT_Size)ftsize;
969 TT_Face face = (TT_Face)ftsize->face; 999 TT_Face face = (TT_Face)ftsize->face;
970 FT_Memory memory = face->root.memory; 1000 FT_Memory memory = face->root.memory;
971 1001
972 FT_UShort n_twilight; 1002 FT_UShort n_twilight;
973 TT_MaxProfile* maxp = &face->max_profile; 1003 TT_MaxProfile* maxp = &face->max_profile;
974 1004
975 1005
1006 /* clean up bytecode related data */
1007 FT_FREE( size->function_defs );
1008 FT_FREE( size->instruction_defs );
1009 FT_FREE( size->cvt );
1010 FT_FREE( size->storage );
1011
1012 if ( size->context )
1013 TT_Done_Context( size->context );
1014 tt_glyphzone_done( &size->twilight );
1015
976 size->bytecode_ready = -1; 1016 size->bytecode_ready = -1;
977 size->cvt_ready = -1; 1017 size->cvt_ready = -1;
978 1018
1019 size->context = TT_New_Context( (TT_Driver)face->root.driver );
1020
979 size->max_function_defs = maxp->maxFunctionDefs; 1021 size->max_function_defs = maxp->maxFunctionDefs;
980 size->max_instruction_defs = maxp->maxInstructionDefs; 1022 size->max_instruction_defs = maxp->maxInstructionDefs;
981 1023
982 size->num_function_defs = 0; 1024 size->num_function_defs = 0;
983 size->num_instruction_defs = 0; 1025 size->num_instruction_defs = 0;
984 1026
985 size->max_func = 0; 1027 size->max_func = 0;
986 size->max_ins = 0; 1028 size->max_ins = 0;
987 1029
988 size->cvt_size = face->cvt_size; 1030 size->cvt_size = face->cvt_size;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 /* */ 1151 /* */
1110 /* <Return> */ 1152 /* <Return> */
1111 /* FreeType error code. 0 means success. */ 1153 /* FreeType error code. 0 means success. */
1112 /* */ 1154 /* */
1113 FT_LOCAL_DEF( FT_Error ) 1155 FT_LOCAL_DEF( FT_Error )
1114 tt_size_init( FT_Size ttsize ) /* TT_Size */ 1156 tt_size_init( FT_Size ttsize ) /* TT_Size */
1115 { 1157 {
1116 TT_Size size = (TT_Size)ttsize; 1158 TT_Size size = (TT_Size)ttsize;
1117 FT_Error error = FT_Err_Ok; 1159 FT_Error error = FT_Err_Ok;
1118 1160
1161
1119 #ifdef TT_USE_BYTECODE_INTERPRETER 1162 #ifdef TT_USE_BYTECODE_INTERPRETER
1120 size->bytecode_ready = -1; 1163 size->bytecode_ready = -1;
1121 size->cvt_ready = -1; 1164 size->cvt_ready = -1;
1122 #endif 1165 #endif
1123 1166
1124 size->ttmetrics.valid = FALSE; 1167 size->ttmetrics.valid = FALSE;
1125 size->strike_index = 0xFFFFFFFFUL; 1168 size->strike_index = 0xFFFFFFFFUL;
1126 1169
1127 return error; 1170 return error;
1128 } 1171 }
(...skipping 10 matching lines...) Expand all
1139 /* <Input> */ 1182 /* <Input> */
1140 /* size :: A handle to the target size object. */ 1183 /* size :: A handle to the target size object. */
1141 /* */ 1184 /* */
1142 FT_LOCAL_DEF( void ) 1185 FT_LOCAL_DEF( void )
1143 tt_size_done( FT_Size ttsize ) /* TT_Size */ 1186 tt_size_done( FT_Size ttsize ) /* TT_Size */
1144 { 1187 {
1145 TT_Size size = (TT_Size)ttsize; 1188 TT_Size size = (TT_Size)ttsize;
1146 1189
1147 1190
1148 #ifdef TT_USE_BYTECODE_INTERPRETER 1191 #ifdef TT_USE_BYTECODE_INTERPRETER
1149 if ( size->bytecode_ready >= 0 ) 1192 tt_size_done_bytecode( ttsize );
1150 tt_size_done_bytecode( ttsize );
1151 #endif 1193 #endif
1152 1194
1153 size->ttmetrics.valid = FALSE; 1195 size->ttmetrics.valid = FALSE;
1154 } 1196 }
1155 1197
1156 1198
1157 /*************************************************************************/ 1199 /*************************************************************************/
1158 /* */ 1200 /* */
1159 /* <Function> */ 1201 /* <Function> */
1160 /* tt_size_reset */ 1202 /* tt_size_reset */
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 /* FreeType error code. 0 means success. */ 1294 /* FreeType error code. 0 means success. */
1253 /* */ 1295 /* */
1254 FT_LOCAL_DEF( FT_Error ) 1296 FT_LOCAL_DEF( FT_Error )
1255 tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ 1297 tt_driver_init( FT_Module ttdriver ) /* TT_Driver */
1256 { 1298 {
1257 1299
1258 #ifdef TT_USE_BYTECODE_INTERPRETER 1300 #ifdef TT_USE_BYTECODE_INTERPRETER
1259 1301
1260 TT_Driver driver = (TT_Driver)ttdriver; 1302 TT_Driver driver = (TT_Driver)ttdriver;
1261 1303
1262
1263 if ( !TT_New_Context( driver ) )
1264 return FT_THROW( Could_Not_Find_Context );
1265
1266 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING 1304 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
1267 driver->interpreter_version = TT_INTERPRETER_VERSION_38; 1305 driver->interpreter_version = TT_INTERPRETER_VERSION_38;
1268 #else 1306 #else
1269 driver->interpreter_version = TT_INTERPRETER_VERSION_35; 1307 driver->interpreter_version = TT_INTERPRETER_VERSION_35;
1270 #endif 1308 #endif
1271 1309
1272 #else /* !TT_USE_BYTECODE_INTERPRETER */ 1310 #else /* !TT_USE_BYTECODE_INTERPRETER */
1273 1311
1274 FT_UNUSED( ttdriver ); 1312 FT_UNUSED( ttdriver );
1275 1313
(...skipping 10 matching lines...) Expand all
1286 /* */ 1324 /* */
1287 /* <Description> */ 1325 /* <Description> */
1288 /* Finalize a given TrueType driver. */ 1326 /* Finalize a given TrueType driver. */
1289 /* */ 1327 /* */
1290 /* <Input> */ 1328 /* <Input> */
1291 /* driver :: A handle to the target TrueType driver. */ 1329 /* driver :: A handle to the target TrueType driver. */
1292 /* */ 1330 /* */
1293 FT_LOCAL_DEF( void ) 1331 FT_LOCAL_DEF( void )
1294 tt_driver_done( FT_Module ttdriver ) /* TT_Driver */ 1332 tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
1295 { 1333 {
1296 #ifdef TT_USE_BYTECODE_INTERPRETER
1297 TT_Driver driver = (TT_Driver)ttdriver;
1298
1299
1300 /* destroy the execution context */
1301 if ( driver->context )
1302 {
1303 TT_Done_Context( driver->context );
1304 driver->context = NULL;
1305 }
1306 #else
1307 FT_UNUSED( ttdriver ); 1334 FT_UNUSED( ttdriver );
1308 #endif
1309
1310 } 1335 }
1311 1336
1312 1337
1313 /*************************************************************************/ 1338 /*************************************************************************/
1314 /* */ 1339 /* */
1315 /* <Function> */ 1340 /* <Function> */
1316 /* tt_slot_init */ 1341 /* tt_slot_init */
1317 /* */ 1342 /* */
1318 /* <Description> */ 1343 /* <Description> */
1319 /* Initialize a new slot object. */ 1344 /* Initialize a new slot object. */
1320 /* */ 1345 /* */
1321 /* <InOut> */ 1346 /* <InOut> */
1322 /* slot :: A handle to the slot object. */ 1347 /* slot :: A handle to the slot object. */
1323 /* */ 1348 /* */
1324 /* <Return> */ 1349 /* <Return> */
1325 /* FreeType error code. 0 means success. */ 1350 /* FreeType error code. 0 means success. */
1326 /* */ 1351 /* */
1327 FT_LOCAL_DEF( FT_Error ) 1352 FT_LOCAL_DEF( FT_Error )
1328 tt_slot_init( FT_GlyphSlot slot ) 1353 tt_slot_init( FT_GlyphSlot slot )
1329 { 1354 {
1330 return FT_GlyphLoader_CreateExtra( slot->internal->loader ); 1355 return FT_GlyphLoader_CreateExtra( slot->internal->loader );
1331 } 1356 }
1332 1357
1333 1358
1334 /* END */ 1359 /* END */
OLDNEW
« no previous file with comments | « third_party/freetype/src/truetype/ttobjs.h ('k') | third_party/freetype/src/truetype/ttpic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698