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