ttgload.c revision 57d4de0e51fd327d118bf8e23164f30ba5e31392
1/***************************************************************************/ 2/* */ 3/* ttgload.c */ 4/* */ 5/* TrueType Glyph Loader (body). */ 6/* */ 7/* Copyright 1996-2000 by */ 8/* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9/* */ 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 */ 12/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13/* this file you indicate that you have read the license and */ 14/* understand and accept it fully. */ 15/* */ 16/***************************************************************************/ 17 18 19#include <ft2build.h> 20#include FT_INTERNAL_DEBUG_H 21#include FT_INTERNAL_CALC_H 22#include FT_INTERNAL_STREAM_H 23#include FT_INTERNAL_SFNT_H 24#include FT_TRUETYPE_TAGS_H 25#include FT_OUTLINE_H 26 27#include "ttgload.h" 28 29#include "tterrors.h" 30 31 32 /*************************************************************************/ 33 /* */ 34 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ 35 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ 36 /* messages during execution. */ 37 /* */ 38#undef FT_COMPONENT 39#define FT_COMPONENT trace_ttgload 40 41 42 /*************************************************************************/ 43 /* */ 44 /* Composite font flags. */ 45 /* */ 46#define ARGS_ARE_WORDS 0x001 47#define ARGS_ARE_XY_VALUES 0x002 48#define ROUND_XY_TO_GRID 0x004 49#define WE_HAVE_A_SCALE 0x008 50/* reserved 0x010 */ 51#define MORE_COMPONENTS 0x020 52#define WE_HAVE_AN_XY_SCALE 0x040 53#define WE_HAVE_A_2X2 0x080 54#define WE_HAVE_INSTR 0x100 55#define USE_MY_METRICS 0x200 56 57 58 59 /*************************************************************************/ 60 /* */ 61 /* <Function> */ 62 /* TT_Get_Metrics */ 63 /* */ 64 /* <Description> */ 65 /* Returns the horizontal or vertical metrics in font units for a */ 66 /* given glyph. The metrics are the left side bearing (resp. top */ 67 /* side bearing) and advance width (resp. advance height). */ 68 /* */ 69 /* <Input> */ 70 /* header :: A pointer to either the horizontal or vertical metrics */ 71 /* structure. */ 72 /* */ 73 /* index :: The glyph index. */ 74 /* */ 75 /* <Output> */ 76 /* bearing :: The bearing, either left side or top side. */ 77 /* */ 78 /* advance :: The advance width resp. advance height. */ 79 /* */ 80 /* <Note> */ 81 /* This function will much probably move to another component in the */ 82 /* near future, but I haven't decided which yet. */ 83 /* */ 84 FT_LOCAL_DEF 85 void TT_Get_Metrics( TT_HoriHeader* header, 86 FT_UInt index, 87 FT_Short* bearing, 88 FT_UShort* advance ) 89 { 90 TT_LongMetrics* longs_m; 91 FT_UShort k = header->number_Of_HMetrics; 92 93 94 if ( index < (FT_UInt)k ) 95 { 96 longs_m = (TT_LongMetrics*)header->long_metrics + index; 97 *bearing = longs_m->bearing; 98 *advance = longs_m->advance; 99 } 100 else 101 { 102 *bearing = ((TT_ShortMetrics*)header->short_metrics)[index - k]; 103 *advance = ((TT_LongMetrics*)header->long_metrics)[k - 1].advance; 104 } 105 } 106 107 108 /*************************************************************************/ 109 /* */ 110 /* Returns the horizontal metrics in font units for a given glyph. If */ 111 /* `check' is true, take care of monospaced fonts by returning the */ 112 /* advance width maximum. */ 113 /* */ 114 static 115 void Get_HMetrics( TT_Face face, 116 FT_UInt index, 117 FT_Bool check, 118 FT_Short* lsb, 119 FT_UShort* aw ) 120 { 121 TT_Get_Metrics( &face->horizontal, index, lsb, aw ); 122 123 if ( check && face->postscript.isFixedPitch ) 124 *aw = face->horizontal.advance_Width_Max; 125 } 126 127 128 /*************************************************************************/ 129 /* */ 130 /* Returns the advance width table for a given pixel size if it is */ 131 /* found in the font's `hdmx' table (if any). */ 132 /* */ 133 static 134 FT_Byte* Get_Advance_Widths( TT_Face face, 135 FT_UShort ppem ) 136 { 137 FT_UShort n; 138 139 for ( n = 0; n < face->hdmx.num_records; n++ ) 140 if ( face->hdmx.records[n].ppem == ppem ) 141 return face->hdmx.records[n].widths; 142 143 return NULL; 144 } 145 146 147#define cur_to_org( n, zone ) \ 148 MEM_Copy( (zone)->org, (zone)->cur, n * sizeof ( FT_Vector ) ) 149 150#define org_to_cur( n, zone ) \ 151 MEM_Copy( (zone)->cur, (zone)->org, n * sizeof ( FT_Vector ) ) 152 153 154 /*************************************************************************/ 155 /* */ 156 /* Translates an array of coordinates. */ 157 /* */ 158 static 159 void translate_array( FT_UInt n, 160 FT_Vector* coords, 161 FT_Pos delta_x, 162 FT_Pos delta_y ) 163 { 164 FT_UInt k; 165 166 167 if ( delta_x ) 168 for ( k = 0; k < n; k++ ) 169 coords[k].x += delta_x; 170 171 if ( delta_y ) 172 for ( k = 0; k < n; k++ ) 173 coords[k].y += delta_y; 174 } 175 176 177 static 178 void tt_prepare_zone( TT_GlyphZone* zone, 179 FT_GlyphLoad* load, 180 FT_UInt start_point, 181 FT_UInt start_contour ) 182 { 183 zone->n_points = load->outline.n_points - start_point; 184 zone->n_contours = load->outline.n_contours - start_contour; 185 zone->org = load->extra_points + start_point; 186 zone->cur = load->outline.points + start_point; 187 zone->tags = (FT_Byte*)load->outline.tags + start_point; 188 zone->contours = (FT_UShort*)load->outline.contours + start_contour; 189 } 190 191 192#undef IS_HINTED 193#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 ) 194 195 196 /*************************************************************************/ 197 /* */ 198 /* The following functions are used by default with TrueType fonts. */ 199 /* However, they can be replaced by alternatives if we need to support */ 200 /* TrueType-compressed formats (like MicroType) in the future. */ 201 /* */ 202 /*************************************************************************/ 203 204 FT_CALLBACK_DEF 205 FT_Error TT_Access_Glyph_Frame( TT_Loader* loader, 206 FT_UInt glyph_index, 207 FT_ULong offset, 208 FT_UInt byte_count ) 209 { 210 FT_Error error; 211 FT_Stream stream = loader->stream; 212 213 /* for non-debug mode */ 214 FT_UNUSED( glyph_index ); 215 216 217 FT_TRACE5(( "Glyph %ld\n", glyph_index )); 218 219 /* the following line sets the `error' variable through macros! */ 220 if ( FILE_Seek( offset ) || ACCESS_Frame( byte_count ) ) 221 return error; 222 223 return TT_Err_Ok; 224 } 225 226 227 FT_CALLBACK_DEF 228 void TT_Forget_Glyph_Frame( TT_Loader* loader ) 229 { 230 FT_Stream stream = loader->stream; 231 232 233 FORGET_Frame(); 234 } 235 236 237 FT_CALLBACK_DEF 238 FT_Error TT_Load_Glyph_Header( TT_Loader* loader ) 239 { 240 FT_Stream stream = loader->stream; 241 242 243 loader->n_contours = GET_Short(); 244 245 loader->bbox.xMin = GET_Short(); 246 loader->bbox.yMin = GET_Short(); 247 loader->bbox.xMax = GET_Short(); 248 loader->bbox.yMax = GET_Short(); 249 250 FT_TRACE5(( " # of contours: %d\n", loader->n_contours )); 251 FT_TRACE5(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin, 252 loader->bbox.xMax )); 253 FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin, 254 loader->bbox.yMax )); 255 256 return TT_Err_Ok; 257 } 258 259 260 FT_CALLBACK_DEF 261 FT_Error TT_Load_Simple_Glyph( TT_Loader* load ) 262 { 263 FT_Error error; 264 FT_Stream stream = load->stream; 265 FT_GlyphLoader* gloader = load->gloader; 266 FT_Int n_contours = load->n_contours; 267 FT_Outline* outline; 268 TT_Face face = (TT_Face)load->face; 269 TT_GlyphSlot slot = (TT_GlyphSlot)load->glyph; 270 FT_UShort n_ins; 271 FT_Int n, n_points; 272 273 274 /* reading the contours endpoints & number of points */ 275 { 276 short* cur = gloader->current.outline.contours; 277 short* limit = cur + n_contours; 278 279 280 for ( ; cur < limit; cur++ ) 281 cur[0] = GET_UShort(); 282 283 n_points = 0; 284 if ( n_contours > 0 ) 285 n_points = cur[-1] + 1; 286 287 error = FT_GlyphLoader_Check_Points( gloader, n_points + 2, 0 ); 288 if ( error ) 289 goto Fail; 290 291 outline = &gloader->current.outline; 292 } 293 294 /* reading the bytecode instructions */ 295 slot->control_len = 0; 296 slot->control_data = 0; 297 298 n_ins = GET_UShort(); 299 300 FT_TRACE5(( " Instructions size: %d\n", n_ins )); 301 302 if ( n_ins > face->max_profile.maxSizeOfInstructions ) 303 { 304 FT_TRACE0(( "ERROR: Too many instructions!\n" )); 305 error = TT_Err_Too_Many_Hints; 306 goto Fail; 307 } 308 309 if ( stream->cursor + n_ins > stream->limit ) 310 { 311 FT_TRACE0(( "ERROR: Instruction count mismatch!\n" )); 312 error = TT_Err_Too_Many_Hints; 313 goto Fail; 314 } 315 316#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 317 318 if ( ( load->load_flags & 319 ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0 && 320 load->instructions ) 321 { 322 slot->control_len = n_ins; 323 slot->control_data = load->instructions; 324 325 MEM_Copy( load->instructions, stream->cursor, n_ins ); 326 } 327 328#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ 329 330 stream->cursor += n_ins; 331 332 /* reading the point tags */ 333 334 { 335 FT_Byte* flag = (FT_Byte*)outline->tags; 336 FT_Byte* limit = flag + n_points; 337 FT_Byte c, count; 338 339 340 for ( ; flag < limit; flag++ ) 341 { 342 *flag = c = GET_Byte(); 343 if ( c & 8 ) 344 { 345 for ( count = GET_Byte(); count > 0; count-- ) 346 *++flag = c; 347 } 348 } 349 } 350 351 /* reading the X coordinates */ 352 353 { 354 FT_Vector* vec = outline->points; 355 FT_Vector* limit = vec + n_points; 356 FT_Byte* flag = (FT_Byte*)outline->tags; 357 FT_Pos x = 0; 358 359 360 for ( ; vec < limit; vec++, flag++ ) 361 { 362 FT_Pos y = 0; 363 364 365 if ( *flag & 2 ) 366 { 367 y = GET_Byte(); 368 if ( ( *flag & 16 ) == 0 ) 369 y = -y; 370 } 371 else if ( ( *flag & 16 ) == 0 ) 372 y = GET_Short(); 373 374 x += y; 375 vec->x = x; 376 } 377 } 378 379 /* reading the Y coordinates */ 380 381 { 382 FT_Vector* vec = gloader->current.outline.points; 383 FT_Vector* limit = vec + n_points; 384 FT_Byte* flag = (FT_Byte*)outline->tags; 385 FT_Pos x = 0; 386 387 388 for ( ; vec < limit; vec++, flag++ ) 389 { 390 FT_Pos y = 0; 391 392 393 if ( *flag & 4 ) 394 { 395 y = GET_Byte(); 396 if ( ( *flag & 32 ) == 0 ) 397 y = -y; 398 } 399 else if ( ( *flag & 32 ) == 0 ) 400 y = GET_Short(); 401 402 x += y; 403 vec->y = x; 404 } 405 } 406 407 /* clear the touch tags */ 408 for ( n = 0; n < n_points; n++ ) 409 outline->tags[n] &= FT_Curve_Tag_On; 410 411 outline->n_points = n_points; 412 outline->n_contours = n_contours; 413 414 Fail: 415 return error; 416 } 417 418 419 FT_CALLBACK_DEF 420 FT_Error TT_Load_Composite_Glyph( TT_Loader* loader ) 421 { 422 FT_Error error; 423 FT_Stream stream = loader->stream; 424 FT_GlyphLoader* gloader = loader->gloader; 425 FT_SubGlyph* subglyph; 426 FT_UInt num_subglyphs; 427 428 429 num_subglyphs = 0; 430 431 do 432 { 433 FT_Fixed xx, xy, yy, yx; 434 435 436 /* check that we can load a new subglyph */ 437 error = FT_GlyphLoader_Check_Subglyphs( gloader, num_subglyphs + 1 ); 438 if ( error ) 439 goto Fail; 440 441 subglyph = gloader->current.subglyphs + num_subglyphs; 442 443 subglyph->arg1 = subglyph->arg2 = 0; 444 445 subglyph->flags = GET_UShort(); 446 subglyph->index = GET_UShort(); 447 448 /* read arguments */ 449 if ( subglyph->flags & ARGS_ARE_WORDS ) 450 { 451 subglyph->arg1 = GET_Short(); 452 subglyph->arg2 = GET_Short(); 453 } 454 else 455 { 456 subglyph->arg1 = GET_Char(); 457 subglyph->arg2 = GET_Char(); 458 } 459 460 /* read transform */ 461 xx = yy = 0x10000L; 462 xy = yx = 0; 463 464 if ( subglyph->flags & WE_HAVE_A_SCALE ) 465 { 466 xx = (FT_Fixed)GET_Short() << 2; 467 yy = xx; 468 } 469 else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE ) 470 { 471 xx = (FT_Fixed)GET_Short() << 2; 472 yy = (FT_Fixed)GET_Short() << 2; 473 } 474 else if ( subglyph->flags & WE_HAVE_A_2X2 ) 475 { 476 xx = (FT_Fixed)GET_Short() << 2; 477 xy = (FT_Fixed)GET_Short() << 2; 478 yx = (FT_Fixed)GET_Short() << 2; 479 yy = (FT_Fixed)GET_Short() << 2; 480 } 481 482 subglyph->transform.xx = xx; 483 subglyph->transform.xy = xy; 484 subglyph->transform.yx = yx; 485 subglyph->transform.yy = yy; 486 487 num_subglyphs++; 488 489 } while ( subglyph->flags & MORE_COMPONENTS ); 490 491 gloader->current.num_subglyphs = num_subglyphs; 492 493#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 494 { 495 /* we must undo the ACCESS_Frame in order to point to the */ 496 /* composite instructions, if we find some. */ 497 /* we will process them later... */ 498 /* */ 499 loader->ins_pos = (FT_ULong)( FILE_Pos() + 500 stream->cursor - stream->limit ); 501 } 502#endif 503 504 Fail: 505 return error; 506 } 507 508 509 FT_LOCAL_DEF 510 void TT_Init_Glyph_Loading( TT_Face face ) 511 { 512 face->access_glyph_frame = TT_Access_Glyph_Frame; 513 face->read_glyph_header = TT_Load_Glyph_Header; 514 face->read_simple_glyph = TT_Load_Simple_Glyph; 515 face->read_composite_glyph = TT_Load_Composite_Glyph; 516 face->forget_glyph_frame = TT_Forget_Glyph_Frame; 517 } 518 519 520 /*************************************************************************/ 521 /* */ 522 /* <Function> */ 523 /* TT_Process_Simple_Glyph */ 524 /* */ 525 /* <Description> */ 526 /* Once a simple glyph has been loaded, it needs to be processed. */ 527 /* Usually, this means scaling and hinting through bytecode */ 528 /* interpretation. */ 529 /* */ 530 static 531 FT_Error TT_Process_Simple_Glyph( TT_Loader* load, 532 FT_Bool debug ) 533 { 534 FT_GlyphLoader* gloader = load->gloader; 535 FT_Outline* outline = &gloader->current.outline; 536 FT_UInt n_points = outline->n_points; 537 FT_UInt n_ins; 538 TT_GlyphZone* zone = &load->zone; 539 FT_Error error = TT_Err_Ok; 540 541 FT_UNUSED( debug ); /* used by truetype interpreter only */ 542 543 544 n_ins = load->glyph->control_len; 545 546 /* add shadow points */ 547 548 /* Now add the two shadow points at n and n + 1. */ 549 /* We need the left side bearing and advance width. */ 550 551 { 552 FT_Vector* pp1; 553 FT_Vector* pp2; 554 555 556 /* pp1 = xMin - lsb */ 557 pp1 = outline->points + n_points; 558 pp1->x = load->bbox.xMin - load->left_bearing; 559 pp1->y = 0; 560 561 /* pp2 = pp1 + aw */ 562 pp2 = pp1 + 1; 563 pp2->x = pp1->x + load->advance; 564 pp2->y = 0; 565 566 outline->tags[n_points ] = 0; 567 outline->tags[n_points + 1] = 0; 568 } 569 570 /* Note that we return two more points that are not */ 571 /* part of the glyph outline. */ 572 573 n_points += 2; 574 575 /* set up zone for hinting */ 576 tt_prepare_zone( zone, &gloader->current, 0, 0 ); 577 578 /* eventually scale the glyph */ 579 if ( !( load->load_flags & FT_LOAD_NO_SCALE ) ) 580 { 581 FT_Vector* vec = zone->cur; 582 FT_Vector* limit = vec + n_points; 583 FT_Fixed x_scale = load->size->metrics.x_scale; 584 FT_Fixed y_scale = load->size->metrics.y_scale; 585 586 587 /* first scale the glyph points */ 588 for ( ; vec < limit; vec++ ) 589 { 590 vec->x = FT_MulFix( vec->x, x_scale ); 591 vec->y = FT_MulFix( vec->y, y_scale ); 592 } 593 } 594 595 cur_to_org( n_points, zone ); 596 597 /* eventually hint the glyph */ 598 if ( IS_HINTED( load->load_flags ) ) 599 { 600 FT_Pos x = zone->org[n_points-2].x; 601 602 603 x = ( ( x + 32 ) & -64 ) - x; 604 translate_array( n_points, zone->org, x, 0 ); 605 606 org_to_cur( n_points, zone ); 607 608 zone->cur[n_points - 1].x = ( zone->cur[n_points - 1].x + 32 ) & -64; 609 610#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 611 612 /* now consider hinting */ 613 if ( n_ins > 0 ) 614 { 615 error = TT_Set_CodeRange( load->exec, tt_coderange_glyph, 616 load->exec->glyphIns, n_ins ); 617 if ( error ) 618 goto Exit; 619 620 load->exec->is_composite = FALSE; 621 load->exec->pedantic_hinting = (FT_Bool)( load->load_flags & 622 FT_LOAD_PEDANTIC ); 623 load->exec->pts = *zone; 624 load->exec->pts.n_points += 2; 625 626 error = TT_Run_Context( load->exec, debug ); 627 if ( error && load->exec->pedantic_hinting ) 628 goto Exit; 629 630 error = TT_Err_Ok; /* ignore bytecode errors in non-pedantic mode */ 631 } 632 633#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ 634 635 } 636 637 /* save glyph phantom points */ 638 if ( !load->preserve_pps ) 639 { 640 load->pp1 = zone->cur[n_points - 2]; 641 load->pp2 = zone->cur[n_points - 1]; 642 } 643 644#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 645 Exit: 646#endif 647 return error; 648 } 649 650 651 /*************************************************************************/ 652 /* */ 653 /* <Function> */ 654 /* load_truetype_glyph */ 655 /* */ 656 /* <Description> */ 657 /* Loads a given truetype glyph. Handles composites and uses a */ 658 /* TT_Loader object. */ 659 /* */ 660 static 661 FT_Error load_truetype_glyph( TT_Loader* loader, 662 FT_UInt glyph_index ) 663 { 664 665#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 666 FT_Stream stream = loader->stream; 667#endif 668 669 FT_Error error; 670 TT_Face face = (TT_Face)loader->face; 671 FT_ULong offset; 672 FT_Int contours_count; 673 FT_UInt index, num_points, num_contours, count; 674 FT_Fixed x_scale, y_scale; 675 FT_ULong ins_offset; 676 FT_GlyphLoader* gloader = loader->gloader; 677 FT_Bool opened_frame = 0; 678 679 680 /* check glyph index */ 681 index = glyph_index; 682 if ( index >= (FT_UInt)face->root.num_glyphs ) 683 { 684 error = TT_Err_Invalid_Glyph_Index; 685 goto Exit; 686 } 687 688 loader->glyph_index = glyph_index; 689 num_contours = 0; 690 num_points = 0; 691 ins_offset = 0; 692 693 x_scale = 0x10000L; 694 y_scale = 0x10000L; 695 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 696 { 697 x_scale = loader->size->metrics.x_scale; 698 y_scale = loader->size->metrics.y_scale; 699 } 700 701 /* get horizontal metrics */ 702 { 703 FT_Short left_bearing; 704 FT_UShort advance_width; 705 706 707 Get_HMetrics( face, index, 708 (FT_Bool)!(loader->load_flags & 709 FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH), 710 &left_bearing, 711 &advance_width ); 712 713 loader->left_bearing = left_bearing; 714 loader->advance = advance_width; 715 716 if ( !loader->linear_def ) 717 { 718 loader->linear_def = 1; 719 loader->linear = advance_width; 720 } 721 } 722 723 offset = face->glyph_locations[index]; 724 count = 0; 725 726 if ( index < (FT_UInt)face->num_locations - 1 ) 727 count = face->glyph_locations[index + 1] - offset; 728 729 if ( count == 0 ) 730 { 731 /* as described by Frederic Loyer, these are spaces, and */ 732 /* not the unknown glyph. */ 733 loader->bbox.xMin = 0; 734 loader->bbox.xMax = 0; 735 loader->bbox.yMin = 0; 736 loader->bbox.yMax = 0; 737 738 loader->pp1.x = 0; 739 loader->pp2.x = loader->advance; 740 741 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 742 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale ); 743 744#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 745 746 if ( loader->exec ) 747 loader->exec->glyphSize = 0; 748 749#endif 750 751 error = TT_Err_Ok; 752 goto Exit; 753 } 754 755 offset = loader->glyf_offset + offset; 756 757 /* access glyph frame */ 758 error = face->access_glyph_frame( loader, glyph_index, offset, count ); 759 if ( error ) 760 goto Exit; 761 762 opened_frame = 1; 763 764 /* read first glyph header */ 765 error = face->read_glyph_header( loader ); 766 if ( error ) 767 goto Fail; 768 769 contours_count = loader->n_contours; 770 771 count -= 10; 772 773 loader->pp1.x = loader->bbox.xMin - loader->left_bearing; 774 loader->pp1.y = 0; 775 loader->pp2.x = loader->pp1.x + loader->advance; 776 loader->pp2.y = 0; 777 778 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 779 { 780 loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale ); 781 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale ); 782 } 783 784 /***********************************************************************/ 785 /***********************************************************************/ 786 /***********************************************************************/ 787 788 /* if it is a simple glyph, load it */ 789 790 if ( contours_count >= 0 ) 791 { 792 /* check that we can add the contours to the glyph */ 793 error = FT_GlyphLoader_Check_Points( gloader, 0, contours_count ); 794 if ( error ) 795 goto Fail; 796 797 error = face->read_simple_glyph( loader ); 798 if ( error ) 799 goto Fail; 800 801#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 802 803 { 804 TT_Size size = (TT_Size)loader->size; 805 806 807 error = TT_Process_Simple_Glyph( loader, 808 (FT_Bool)( size && size->debug ) ); 809 } 810 811#else 812 813 error = TT_Process_Simple_Glyph( loader, 0 ); 814 815#endif 816 817 if ( error ) 818 goto Fail; 819 820 FT_GlyphLoader_Add( gloader ); 821 822 /* Note: We could have put the simple loader source there */ 823 /* but the code is fat enough already :-) */ 824 } 825 826 /***********************************************************************/ 827 /***********************************************************************/ 828 /***********************************************************************/ 829 830 /* otherwise, load a composite! */ 831 else 832 { 833 TT_GlyphSlot glyph = (TT_GlyphSlot)loader->glyph; 834 FT_UInt start_point, start_contour; 835 FT_ULong ins_pos; /* position of composite instructions, if any */ 836 837 838 /* for each subglyph, read composite header */ 839 start_point = gloader->base.outline.n_points; 840 start_contour = gloader->base.outline.n_contours; 841 842 error = face->read_composite_glyph( loader ); 843 if ( error ) 844 goto Fail; 845 846 ins_pos = loader->ins_pos; 847 face->forget_glyph_frame( loader ); 848 opened_frame = 0; 849 850 /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */ 851 /* `as is' in the glyph slot (the client application will be */ 852 /* responsible for interpreting this data)... */ 853 /* */ 854 if ( loader->load_flags & FT_LOAD_NO_RECURSE ) 855 { 856 /* set up remaining glyph fields */ 857 FT_GlyphLoader_Add( gloader ); 858 859 glyph->num_subglyphs = gloader->base.num_subglyphs; 860 glyph->format = ft_glyph_format_composite; 861 glyph->subglyphs = gloader->base.subglyphs; 862 863 goto Exit; 864 } 865 866 /*********************************************************************/ 867 /*********************************************************************/ 868 /*********************************************************************/ 869 870 /* Now, read each subglyph independently. */ 871 { 872 FT_Int n, num_base_points, num_new_points; 873 FT_SubGlyph* subglyph = 0; 874 875 FT_UInt num_subglyphs = gloader->current.num_subglyphs; 876 FT_UInt num_base_subgs = gloader->base.num_subglyphs; 877 878 879 FT_GlyphLoader_Add( gloader ); 880 881 for ( n = 0; n < (FT_Int)num_subglyphs; n++ ) 882 { 883 FT_Vector pp1, pp2; 884 FT_Pos x, y; 885 886 887 /* Each time we call load_truetype_glyph in this loop, the */ 888 /* value of `gloader.base.subglyphs' can change due to table */ 889 /* reallocations. We thus need to recompute the subglyph */ 890 /* pointer on each iteration. */ 891 subglyph = gloader->base.subglyphs + num_base_subgs + n; 892 893 pp1 = loader->pp1; 894 pp2 = loader->pp2; 895 896 num_base_points = gloader->base.outline.n_points; 897 898 error = load_truetype_glyph( loader, subglyph->index ); 899 if ( error ) 900 goto Fail; 901 902 /* restore subglyph pointer */ 903 subglyph = gloader->base.subglyphs + num_base_subgs + n; 904 905 if ( subglyph->flags & USE_MY_METRICS ) 906 { 907 pp1 = loader->pp1; 908 pp2 = loader->pp2; 909 } 910 else 911 { 912 loader->pp1 = pp1; 913 loader->pp2 = pp2; 914 } 915 916 num_points = gloader->base.outline.n_points; 917 918 num_new_points = num_points - num_base_points; 919 920 /* now perform the transform required for this subglyph */ 921 922 if ( subglyph->flags & ( WE_HAVE_A_SCALE | 923 WE_HAVE_AN_XY_SCALE | 924 WE_HAVE_A_2X2 ) ) 925 { 926 FT_Vector* cur = gloader->base.outline.points + 927 num_base_points; 928 FT_Vector* org = gloader->base.extra_points + 929 num_base_points; 930 FT_Vector* limit = cur + num_new_points; 931 932 933 for ( ; cur < limit; cur++, org++ ) 934 { 935 FT_Vector_Transform( cur, &subglyph->transform ); 936 FT_Vector_Transform( org, &subglyph->transform ); 937 } 938 } 939 940 /* apply offset */ 941 942 if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) ) 943 { 944 FT_UInt k = subglyph->arg1; 945 FT_UInt l = subglyph->arg2; 946 FT_Vector* p1; 947 FT_Vector* p2; 948 949 950 if ( start_point + k >= (FT_UInt)num_base_points || 951 l >= (FT_UInt)num_new_points ) 952 { 953 error = TT_Err_Invalid_Composite; 954 goto Fail; 955 } 956 957 l += num_base_points; 958 959 p1 = gloader->base.outline.points + start_point + k; 960 p2 = gloader->base.outline.points + start_point + l; 961 962 x = p1->x - p2->x; 963 y = p1->y - p2->y; 964 } 965 else 966 { 967 x = subglyph->arg1; 968 y = subglyph->arg2; 969 970 if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) 971 { 972 x = FT_MulFix( x, x_scale ); 973 y = FT_MulFix( y, y_scale ); 974 975 if ( subglyph->flags & ROUND_XY_TO_GRID ) 976 { 977 x = ( x + 32 ) & -64; 978 y = ( y + 32 ) & -64; 979 } 980 } 981 } 982 983 if ( x | y ) 984 { 985 translate_array( num_new_points, 986 gloader->base.outline.points + num_base_points, 987 x, y ); 988 989 translate_array( num_new_points, 990 gloader->base.extra_points + num_base_points, 991 x, y ); 992 } 993 } 994 995 /*******************************************************************/ 996 /*******************************************************************/ 997 /*******************************************************************/ 998 999 /* we have finished loading all sub-glyphs; now, look for */ 1000 /* instructions for this composite! */ 1001 1002#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 1003 1004 if ( num_subglyphs > 0 && 1005 loader->exec && 1006 ins_pos > 0 && 1007 subglyph->flags & WE_HAVE_INSTR ) 1008 { 1009 FT_UShort n_ins; 1010 TT_ExecContext exec = loader->exec; 1011 TT_GlyphZone* pts; 1012 FT_Vector* pp1; 1013 1014 1015 /* read size of instructions */ 1016 if ( FILE_Seek( ins_pos ) || 1017 READ_UShort( n_ins ) ) 1018 goto Fail; 1019 FT_TRACE5(( " Instructions size = %d\n", n_ins )); 1020 1021 /* in some fonts? */ 1022 if ( n_ins == 0xFFFF ) 1023 n_ins = 0; 1024 1025 /* check it */ 1026 if ( n_ins > face->max_profile.maxSizeOfInstructions ) 1027 { 1028 FT_TRACE0(( "Too many instructions (%d) in composite glyph %ld\n", 1029 n_ins, subglyph->index )); 1030 return TT_Err_Too_Many_Hints; 1031 } 1032 1033 /* read the instructions */ 1034 if ( FILE_Read( exec->glyphIns, n_ins ) ) 1035 goto Fail; 1036 1037 glyph->control_data = exec->glyphIns; 1038 glyph->control_len = n_ins; 1039 1040 error = TT_Set_CodeRange( exec, 1041 tt_coderange_glyph, 1042 exec->glyphIns, 1043 n_ins ); 1044 if ( error ) 1045 goto Fail; 1046 1047 /* prepare the execution context */ 1048 tt_prepare_zone( &exec->pts, &gloader->base, 1049 start_point, start_contour ); 1050 pts = &exec->pts; 1051 1052 pts->n_points = num_points + 2; 1053 pts->n_contours = gloader->base.outline.n_contours; 1054 1055 /* add phantom points */ 1056 pp1 = pts->cur + num_points; 1057 pp1[0] = loader->pp1; 1058 pp1[1] = loader->pp2; 1059 1060 pts->tags[num_points ] = 0; 1061 pts->tags[num_points + 1] = 0; 1062 1063 /* if hinting, round the phantom points */ 1064 if ( IS_HINTED( loader->load_flags ) ) 1065 { 1066 pp1[0].x = ( ( loader->pp1.x + 32 ) & -64 ); 1067 pp1[1].x = ( ( loader->pp2.x + 32 ) & -64 ); 1068 } 1069 1070 { 1071 FT_UInt k; 1072 1073 1074 for ( k = 0; k < num_points; k++ ) 1075 pts->tags[k] &= FT_Curve_Tag_On; 1076 } 1077 1078 cur_to_org( num_points + 2, pts ); 1079 1080 /* now consider hinting */ 1081 if ( IS_HINTED( loader->load_flags ) && n_ins > 0 ) 1082 { 1083 exec->is_composite = TRUE; 1084 exec->pedantic_hinting = 1085 (FT_Bool)( loader->load_flags & FT_LOAD_PEDANTIC ); 1086 1087 error = TT_Run_Context( exec, ((TT_Size)loader->size)->debug ); 1088 if ( error && exec->pedantic_hinting ) 1089 goto Fail; 1090 } 1091 1092 /* save glyph origin and advance points */ 1093 loader->pp1 = pp1[0]; 1094 loader->pp2 = pp1[1]; 1095 } 1096 1097#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ 1098 1099 } 1100 /* end of composite loading */ 1101 } 1102 1103 /***********************************************************************/ 1104 /***********************************************************************/ 1105 /***********************************************************************/ 1106 1107 Fail: 1108 if ( opened_frame ) 1109 face->forget_glyph_frame( loader ); 1110 1111 Exit: 1112 return error; 1113 } 1114 1115 1116 static 1117 void compute_glyph_metrics( TT_Loader* loader, 1118 FT_UInt glyph_index ) 1119 { 1120 FT_BBox bbox; 1121 TT_Face face = (TT_Face)loader->face; 1122 FT_Fixed x_scale, y_scale; 1123 TT_GlyphSlot glyph = loader->glyph; 1124 TT_Size size = (TT_Size)loader->size; 1125 1126 1127 x_scale = 0x10000L; 1128 y_scale = 0x10000L; 1129 if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) 1130 { 1131 x_scale = size->root.metrics.x_scale; 1132 y_scale = size->root.metrics.y_scale; 1133 } 1134 1135 if ( glyph->format != ft_glyph_format_composite ) 1136 { 1137 glyph->outline.flags &= ~ft_outline_single_pass; 1138 1139 /* copy outline to our glyph slot */ 1140 FT_GlyphLoader_Copy_Points( glyph->internal->loader, loader->gloader ); 1141 glyph->outline = glyph->internal->loader->base.outline; 1142 1143 /* translate array so that (0,0) is the glyph's origin */ 1144 FT_Outline_Translate( &glyph->outline, -loader->pp1.x, 0 ); 1145 1146 FT_Outline_Get_CBox( &glyph->outline, &bbox ); 1147 1148 if ( IS_HINTED( loader->load_flags ) ) 1149 { 1150 /* grid-fit the bounding box */ 1151 bbox.xMin &= -64; 1152 bbox.yMin &= -64; 1153 bbox.xMax = ( bbox.xMax + 63 ) & -64; 1154 bbox.yMax = ( bbox.yMax + 63 ) & -64; 1155 } 1156 } 1157 else 1158 bbox = loader->bbox; 1159 1160 /* get the device-independent horizontal advance. It is scaled later */ 1161 /* by the base layer. */ 1162 { 1163 FT_Pos advance = loader->linear; 1164 1165 1166 /* the flag FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH was introduced to */ 1167 /* correctly support DynaLab fonts, which have an incorrect */ 1168 /* `advance_Width_Max' field! It is used, to my knowledge, */ 1169 /* exclusively in the X-TrueType font server. */ 1170 /* */ 1171 if ( face->postscript.isFixedPitch && 1172 ( loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 ) 1173 advance = face->horizontal.advance_Width_Max; 1174 1175 /* we need to return the advance in font units in linearHoriAdvance, */ 1176 /* it will be scaled later by the base layer. */ 1177 glyph->linearHoriAdvance = advance; 1178 } 1179 1180 glyph->metrics.horiBearingX = bbox.xMin; 1181 glyph->metrics.horiBearingY = bbox.yMax; 1182 glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; 1183 1184 /* Now take care of vertical metrics. In the case where there is */ 1185 /* no vertical information within the font (relatively common), make */ 1186 /* up some metrics by `hand'... */ 1187 1188 { 1189 FT_Short top_bearing; /* vertical top side bearing (EM units) */ 1190 FT_UShort advance_height; /* vertical advance height (EM units) */ 1191 1192 FT_Pos left; /* scaled vertical left side bearing */ 1193 FT_Pos Top; /* scaled original vertical top side bearing */ 1194 FT_Pos top; /* scaled vertical top side bearing */ 1195 FT_Pos advance; /* scaled vertical advance height */ 1196 1197 1198 /* Get the unscaled `tsb' and `ah' */ 1199 if ( face->vertical_info && 1200 face->vertical.number_Of_VMetrics > 0 ) 1201 { 1202 /* Don't assume that both the vertical header and vertical */ 1203 /* metrics are present in the same font :-) */ 1204 1205 TT_Get_Metrics( (TT_HoriHeader*)&face->vertical, 1206 glyph_index, 1207 &top_bearing, 1208 &advance_height ); 1209 } 1210 else 1211 { 1212 /* Make up the distances from the horizontal header. */ 1213 1214 /* NOTE: The OS/2 values are the only `portable' ones, */ 1215 /* which is why we use them, if there is an OS/2 */ 1216 /* table in the font. Otherwise, we use the */ 1217 /* values defined in the horizontal header. */ 1218 /* */ 1219 /* NOTE2: The sTypoDescender is negative, which is why */ 1220 /* we compute the baseline-to-baseline distance */ 1221 /* here with: */ 1222 /* ascender - descender + linegap */ 1223 /* */ 1224 if ( face->os2.version != 0xFFFF ) 1225 { 1226 top_bearing = face->os2.sTypoLineGap / 2; 1227 advance_height = (FT_UShort)( face->os2.sTypoAscender - 1228 face->os2.sTypoDescender + 1229 face->os2.sTypoLineGap ); 1230 } 1231 else 1232 { 1233 top_bearing = face->horizontal.Line_Gap / 2; 1234 advance_height = (FT_UShort)( face->horizontal.Ascender + 1235 face->horizontal.Descender + 1236 face->horizontal.Line_Gap ); 1237 } 1238 } 1239 1240 /* We must adjust the top_bearing value from the bounding box given */ 1241 /* in the glyph header to te bounding box calculated with */ 1242 /* FT_Get_Outline_CBox(). */ 1243 1244 /* scale the metrics */ 1245 if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) 1246 { 1247 Top = FT_MulFix( top_bearing, y_scale ); 1248 top = FT_MulFix( top_bearing + loader->bbox.yMax, y_scale ) 1249 - bbox.yMax; 1250 advance = FT_MulFix( advance_height, y_scale ); 1251 } 1252 else 1253 { 1254 Top = top_bearing; 1255 top = top_bearing + loader->bbox.yMax - bbox.yMax; 1256 advance = advance_height; 1257 } 1258 1259 /* set the advance height in design units. It is scaled later by */ 1260 /* the base layer. */ 1261 glyph->linearVertAdvance = advance_height; 1262 1263 /* XXX: for now, we have no better algorithm for the lsb, but it */ 1264 /* should work fine. */ 1265 /* */ 1266 left = ( bbox.xMin - bbox.xMax ) / 2; 1267 1268 /* grid-fit them if necessary */ 1269 if ( IS_HINTED( loader->load_flags ) ) 1270 { 1271 left &= -64; 1272 top = ( top + 63 ) & -64; 1273 advance = ( advance + 32 ) & -64; 1274 } 1275 1276 glyph->metrics.vertBearingX = left; 1277 glyph->metrics.vertBearingY = top; 1278 glyph->metrics.vertAdvance = advance; 1279 } 1280 1281 /* adjust advance width to the value contained in the hdmx table */ 1282 if ( !face->postscript.isFixedPitch && size && 1283 IS_HINTED( loader->load_flags ) ) 1284 { 1285 FT_Byte* widths = Get_Advance_Widths( face, 1286 size->root.metrics.x_ppem ); 1287 1288 1289 if ( widths ) 1290 glyph->metrics.horiAdvance = widths[glyph_index] << 6; 1291 } 1292 1293 /* set glyph dimensions */ 1294 glyph->metrics.width = bbox.xMax - bbox.xMin; 1295 glyph->metrics.height = bbox.yMax - bbox.yMin; 1296 } 1297 1298 1299 /*************************************************************************/ 1300 /* */ 1301 /* <Function> */ 1302 /* TT_Load_Glyph */ 1303 /* */ 1304 /* <Description> */ 1305 /* A function used to load a single glyph within a given glyph slot, */ 1306 /* for a given size. */ 1307 /* */ 1308 /* <Input> */ 1309 /* glyph :: A handle to a target slot object where the glyph */ 1310 /* will be loaded. */ 1311 /* */ 1312 /* size :: A handle to the source face size at which the glyph */ 1313 /* must be scaled/loaded. */ 1314 /* */ 1315 /* glyph_index :: The index of the glyph in the font file. */ 1316 /* */ 1317 /* load_flags :: A flag indicating what to load for this glyph. The */ 1318 /* FT_LOAD_XXX constants can be used to control the */ 1319 /* glyph loading process (e.g., whether the outline */ 1320 /* should be scaled, whether to load bitmaps or not, */ 1321 /* whether to hint the outline, etc). */ 1322 /* */ 1323 /* <Return> */ 1324 /* FreeType error code. 0 means success. */ 1325 /* */ 1326 FT_LOCAL_DEF 1327 FT_Error TT_Load_Glyph( TT_Size size, 1328 TT_GlyphSlot glyph, 1329 FT_UShort glyph_index, 1330 FT_UInt load_flags ) 1331 { 1332 SFNT_Interface* sfnt; 1333 TT_Face face; 1334 FT_Stream stream; 1335 FT_Memory memory; 1336 FT_Error error; 1337 TT_Loader loader; 1338 1339 1340 face = (TT_Face)glyph->face; 1341 sfnt = (SFNT_Interface*)face->sfnt; 1342 stream = face->root.stream; 1343 memory = face->root.memory; 1344 error = 0; 1345 1346 if ( !size || ( load_flags & FT_LOAD_NO_SCALE ) || 1347 ( load_flags & FT_LOAD_NO_RECURSE ) ) 1348 { 1349 size = NULL; 1350 load_flags |= FT_LOAD_NO_SCALE | 1351 FT_LOAD_NO_HINTING | 1352 FT_LOAD_NO_BITMAP; 1353 } 1354 1355 glyph->num_subglyphs = 0; 1356 1357#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 1358 1359 /* try to load embedded bitmap if any */ 1360 /* */ 1361 /* XXX: The convention should be emphasized in */ 1362 /* the documents because it can be confusing. */ 1363 if ( size && 1364 size->strike_index != 0xFFFF && 1365 sfnt->load_sbits && 1366 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) 1367 1368 { 1369 TT_SBit_Metrics metrics; 1370 1371 1372 error = sfnt->load_sbit_image( face, 1373 size->strike_index, 1374 glyph_index, 1375 load_flags, 1376 stream, 1377 &glyph->bitmap, 1378 &metrics ); 1379 if ( !error ) 1380 { 1381 glyph->outline.n_points = 0; 1382 glyph->outline.n_contours = 0; 1383 1384 glyph->metrics.width = (FT_Pos)metrics.width << 6; 1385 glyph->metrics.height = (FT_Pos)metrics.height << 6; 1386 1387 glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; 1388 glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; 1389 glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; 1390 1391 glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; 1392 glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; 1393 glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; 1394 1395 glyph->format = ft_glyph_format_bitmap; 1396 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) 1397 { 1398 glyph->bitmap_left = metrics.vertBearingX; 1399 glyph->bitmap_top = metrics.vertBearingY; 1400 } 1401 else 1402 { 1403 glyph->bitmap_left = metrics.horiBearingX; 1404 glyph->bitmap_top = metrics.horiBearingY; 1405 } 1406 return error; 1407 } 1408 } 1409 1410#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ 1411 1412 /* seek to the beginning of the glyph table. For Type 42 fonts */ 1413 /* the table might be accessed from a Postscript stream or something */ 1414 /* else... */ 1415 1416 error = face->goto_table( face, TTAG_glyf, stream, 0 ); 1417 if ( error ) 1418 { 1419 FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); 1420 goto Exit; 1421 } 1422 1423 MEM_Set( &loader, 0, sizeof ( loader ) ); 1424 1425 /* update the glyph zone bounds */ 1426 { 1427 FT_GlyphLoader* gloader = FT_FACE_DRIVER(face)->glyph_loader; 1428 1429 1430 loader.gloader = gloader; 1431 1432 FT_GlyphLoader_Rewind( gloader ); 1433 1434 tt_prepare_zone( &loader.zone, &gloader->base, 0, 0 ); 1435 tt_prepare_zone( &loader.base, &gloader->base, 0, 0 ); 1436 } 1437 1438#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 1439 1440 if ( size ) 1441 { 1442 /* query new execution context */ 1443 loader.exec = size->debug ? size->context : TT_New_Context( face ); 1444 if ( !loader.exec ) 1445 return TT_Err_Could_Not_Find_Context; 1446 1447 TT_Load_Context( loader.exec, face, size ); 1448 loader.instructions = loader.exec->glyphIns; 1449 1450 /* load default graphics state - if needed */ 1451 if ( size->GS.instruct_control & 2 ) 1452 loader.exec->GS = tt_default_graphics_state; 1453 } 1454 1455#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ 1456 1457 /* clear all outline flags, except the `owner' one */ 1458 glyph->outline.flags = 0; 1459 1460 if ( size && size->root.metrics.y_ppem < 24 ) 1461 glyph->outline.flags |= ft_outline_high_precision; 1462 1463 /* let's initialize the rest of our loader now */ 1464 1465 loader.load_flags = load_flags; 1466 1467 loader.face = (FT_Face)face; 1468 loader.size = (FT_Size)size; 1469 loader.glyph = (FT_GlyphSlot)glyph; 1470 loader.stream = stream; 1471 1472 loader.glyf_offset = FILE_Pos(); 1473 1474#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 1475 1476 /* if the cvt program has disabled hinting, the argument */ 1477 /* is ignored. */ 1478 if ( size && ( size->GS.instruct_control & 1 ) ) 1479 loader.load_flags |= FT_LOAD_NO_HINTING; 1480 1481#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ 1482 1483 /* Main loading loop */ 1484 glyph->format = ft_glyph_format_outline; 1485 glyph->num_subglyphs = 0; 1486 error = load_truetype_glyph( &loader, glyph_index ); 1487 if ( !error ) 1488 compute_glyph_metrics( &loader, glyph_index ); 1489 1490#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER 1491 1492 if ( !size || !size->debug ) 1493 TT_Done_Context( loader.exec ); 1494 1495#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ 1496 1497 Exit: 1498 return error; 1499 } 1500 1501 1502/* END */ 1503