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