Lines 121-139
Link Here
|
121 |
FT_Error error; |
121 |
FT_Error error; |
122 |
|
122 |
|
123 |
|
123 |
|
124 |
if ( maxPoints > 0 ) |
|
|
125 |
maxPoints += 2; |
126 |
|
127 |
FT_MEM_ZERO( zone, sizeof ( *zone ) ); |
124 |
FT_MEM_ZERO( zone, sizeof ( *zone ) ); |
128 |
zone->memory = memory; |
125 |
zone->memory = memory; |
129 |
|
126 |
|
130 |
if ( FT_NEW_ARRAY( zone->org, maxPoints * 2 ) || |
127 |
if ( FT_NEW_ARRAY( zone->org, maxPoints ) || |
131 |
FT_NEW_ARRAY( zone->cur, maxPoints * 2 ) || |
128 |
FT_NEW_ARRAY( zone->cur, maxPoints ) || |
132 |
FT_NEW_ARRAY( zone->tags, maxPoints ) || |
129 |
FT_NEW_ARRAY( zone->tags, maxPoints ) || |
133 |
FT_NEW_ARRAY( zone->contours, maxContours ) ) |
130 |
FT_NEW_ARRAY( zone->contours, maxContours ) ) |
134 |
{ |
131 |
{ |
135 |
tt_glyphzone_done( zone ); |
132 |
tt_glyphzone_done( zone ); |
136 |
} |
133 |
} |
|
|
134 |
else |
135 |
{ |
136 |
zone->max_points = maxPoints; |
137 |
zone->max_contours = maxContours; |
138 |
} |
137 |
|
139 |
|
138 |
return error; |
140 |
return error; |
139 |
} |
141 |
} |
Lines 318-323
Link Here
|
318 |
/* */ |
320 |
/* */ |
319 |
/*************************************************************************/ |
321 |
/*************************************************************************/ |
320 |
|
322 |
|
|
|
323 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
324 |
/*************************************************************************/ |
325 |
/* */ |
326 |
/* <Function> */ |
327 |
/* tt_size_run_fpgm */ |
328 |
/* */ |
329 |
/* <Description> */ |
330 |
/* Run the font program */ |
331 |
/* */ |
332 |
/* <Input> */ |
333 |
/* size :: A handle to the size object. */ |
334 |
/* */ |
335 |
/* <Return> */ |
336 |
/* FreeType error code. 0 means success. */ |
337 |
/* */ |
338 |
FT_LOCAL_DEF( FT_Error ) |
339 |
tt_size_run_fpgm( TT_Size size ) |
340 |
{ |
341 |
TT_Face face = (TT_Face)size->root.face; |
342 |
TT_ExecContext exec; |
343 |
FT_Error error; |
344 |
|
345 |
|
346 |
/* debugging instances have their own context */ |
347 |
if ( size->debug ) |
348 |
exec = size->context; |
349 |
else |
350 |
exec = TT_New_Context( face ); |
351 |
|
352 |
if ( !exec ) |
353 |
return TT_Err_Could_Not_Find_Context; |
354 |
|
355 |
TT_Load_Context( exec, face, size ); |
356 |
|
357 |
exec->callTop = 0; |
358 |
exec->top = 0; |
359 |
|
360 |
exec->period = 64; |
361 |
exec->phase = 0; |
362 |
exec->threshold = 0; |
363 |
|
364 |
exec->instruction_trap = FALSE; |
365 |
exec->F_dot_P = 0x10000L; |
366 |
|
367 |
{ |
368 |
FT_Size_Metrics* metrics = &exec->metrics; |
369 |
TT_Size_Metrics* tt_metrics = &exec->tt_metrics; |
370 |
|
371 |
|
372 |
metrics->x_ppem = 0; |
373 |
metrics->y_ppem = 0; |
374 |
metrics->x_scale = 0; |
375 |
metrics->y_scale = 0; |
376 |
|
377 |
tt_metrics->ppem = 0; |
378 |
tt_metrics->scale = 0; |
379 |
tt_metrics->ratio = 0x10000L; |
380 |
} |
381 |
|
382 |
/* allow font program execution */ |
383 |
TT_Set_CodeRange( exec, |
384 |
tt_coderange_font, |
385 |
face->font_program, |
386 |
face->font_program_size ); |
387 |
|
388 |
/* disable CVT and glyph programs coderange */ |
389 |
TT_Clear_CodeRange( exec, tt_coderange_cvt ); |
390 |
TT_Clear_CodeRange( exec, tt_coderange_glyph ); |
391 |
|
392 |
if ( face->font_program_size > 0 ) |
393 |
{ |
394 |
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); |
395 |
|
396 |
if ( !error ) |
397 |
error = face->interpreter( exec ); |
398 |
} |
399 |
else |
400 |
error = TT_Err_Ok; |
401 |
|
402 |
if ( !error ) |
403 |
TT_Save_Context( exec, size ); |
404 |
|
405 |
if ( !size->debug ) |
406 |
TT_Done_Context( exec ); |
407 |
|
408 |
return error; |
409 |
} |
410 |
|
411 |
|
412 |
/*************************************************************************/ |
413 |
/* */ |
414 |
/* <Function> */ |
415 |
/* tt_size_run_prep */ |
416 |
/* */ |
417 |
/* <Description> */ |
418 |
/* Run the control value program */ |
419 |
/* */ |
420 |
/* <Input> */ |
421 |
/* size :: A handle to the size object. */ |
422 |
/* */ |
423 |
/* <Return> */ |
424 |
/* FreeType error code. 0 means success. */ |
425 |
/* */ |
426 |
FT_LOCAL_DEF( FT_Error ) |
427 |
tt_size_run_prep( TT_Size size ) |
428 |
{ |
429 |
TT_Face face = (TT_Face)size->root.face; |
430 |
TT_ExecContext exec; |
431 |
FT_Error error; |
432 |
|
433 |
|
434 |
/* debugging instances have their own context */ |
435 |
if ( size->debug ) |
436 |
exec = size->context; |
437 |
else |
438 |
exec = TT_New_Context( face ); |
439 |
|
440 |
if ( !exec ) |
441 |
return TT_Err_Could_Not_Find_Context; |
442 |
|
443 |
TT_Load_Context( exec, face, size ); |
444 |
|
445 |
exec->callTop = 0; |
446 |
exec->top = 0; |
447 |
|
448 |
exec->instruction_trap = FALSE; |
449 |
|
450 |
TT_Set_CodeRange( exec, |
451 |
tt_coderange_cvt, |
452 |
face->cvt_program, |
453 |
face->cvt_program_size ); |
454 |
|
455 |
TT_Clear_CodeRange( exec, tt_coderange_glyph ); |
456 |
|
457 |
if ( face->cvt_program_size > 0 ) |
458 |
{ |
459 |
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); |
460 |
|
461 |
if ( !error && !size->debug ) |
462 |
error = face->interpreter( exec ); |
463 |
} |
464 |
else |
465 |
error = TT_Err_Ok; |
466 |
|
467 |
/* save as default graphics state */ |
468 |
size->GS = exec->GS; |
469 |
|
470 |
TT_Save_Context( exec, size ); |
471 |
|
472 |
if ( !size->debug ) |
473 |
TT_Done_Context( exec ); |
474 |
|
475 |
return error; |
476 |
} |
477 |
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
478 |
|
321 |
|
479 |
|
322 |
/*************************************************************************/ |
480 |
/*************************************************************************/ |
323 |
/* */ |
481 |
/* */ |
Lines 338-352
Link Here
|
338 |
{ |
496 |
{ |
339 |
TT_Size size = (TT_Size)ttsize; |
497 |
TT_Size size = (TT_Size)ttsize; |
340 |
FT_Error error = TT_Err_Ok; |
498 |
FT_Error error = TT_Err_Ok; |
341 |
|
|
|
342 |
|
343 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
499 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
344 |
|
|
|
345 |
TT_Face face = (TT_Face)size->root.face; |
500 |
TT_Face face = (TT_Face)size->root.face; |
346 |
FT_Memory memory = face->root.memory; |
501 |
FT_Memory memory = face->root.memory; |
347 |
FT_Int i; |
502 |
FT_Int i; |
348 |
|
503 |
|
349 |
TT_ExecContext exec; |
|
|
350 |
FT_UShort n_twilight; |
504 |
FT_UShort n_twilight; |
351 |
TT_MaxProfile* maxp = &face->max_profile; |
505 |
TT_MaxProfile* maxp = &face->max_profile; |
352 |
|
506 |
|
Lines 387-403
Link Here
|
387 |
FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || |
541 |
FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || |
388 |
FT_NEW_ARRAY( size->cvt, size->cvt_size ) || |
542 |
FT_NEW_ARRAY( size->cvt, size->cvt_size ) || |
389 |
FT_NEW_ARRAY( size->storage, size->storage_size ) ) |
543 |
FT_NEW_ARRAY( size->storage, size->storage_size ) ) |
|
|
544 |
{ |
545 |
tt_size_done( ttsize ); |
390 |
|
546 |
|
391 |
goto Fail_Memory; |
547 |
return error; |
|
|
548 |
} |
392 |
|
549 |
|
393 |
/* reserve twilight zone */ |
550 |
/* reserve twilight zone */ |
394 |
n_twilight = maxp->maxTwilightPoints; |
551 |
n_twilight = maxp->maxTwilightPoints; |
|
|
552 |
|
553 |
/* there are 4 phantom points (do we need this?) */ |
554 |
n_twilight += 4; |
555 |
|
395 |
error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); |
556 |
error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); |
396 |
if ( error ) |
557 |
if ( error ) |
397 |
goto Fail_Memory; |
558 |
{ |
|
|
559 |
tt_size_done( ttsize ); |
560 |
|
561 |
return error; |
562 |
} |
398 |
|
563 |
|
399 |
size->twilight.n_points = n_twilight; |
564 |
size->twilight.n_points = n_twilight; |
400 |
|
565 |
|
|
|
566 |
size->GS = tt_default_graphics_state; |
567 |
|
401 |
/* set `face->interpreter' according to the debug hook present */ |
568 |
/* set `face->interpreter' according to the debug hook present */ |
402 |
{ |
569 |
{ |
403 |
FT_Library library = face->root.driver->root.library; |
570 |
FT_Library library = face->root.driver->root.library; |
Lines 409-503
Link Here
|
409 |
face->interpreter = (TT_Interpreter)TT_RunIns; |
576 |
face->interpreter = (TT_Interpreter)TT_RunIns; |
410 |
} |
577 |
} |
411 |
|
578 |
|
412 |
/* Fine, now execute the font program! */ |
579 |
/* Fine, now run the font program! */ |
413 |
exec = size->context; |
580 |
error = tt_size_run_fpgm( size ); |
414 |
/* size objects used during debugging have their own context */ |
|
|
415 |
if ( !size->debug ) |
416 |
exec = TT_New_Context( face ); |
417 |
|
418 |
if ( !exec ) |
419 |
{ |
420 |
error = TT_Err_Could_Not_Find_Context; |
421 |
goto Fail_Memory; |
422 |
} |
423 |
|
424 |
size->GS = tt_default_graphics_state; |
425 |
TT_Load_Context( exec, face, size ); |
426 |
|
427 |
exec->callTop = 0; |
428 |
exec->top = 0; |
429 |
|
430 |
exec->period = 64; |
431 |
exec->phase = 0; |
432 |
exec->threshold = 0; |
433 |
|
434 |
{ |
435 |
FT_Size_Metrics* metrics = &exec->metrics; |
436 |
TT_Size_Metrics* tt_metrics = &exec->tt_metrics; |
437 |
|
438 |
|
439 |
metrics->x_ppem = 0; |
440 |
metrics->y_ppem = 0; |
441 |
metrics->x_scale = 0; |
442 |
metrics->y_scale = 0; |
443 |
|
444 |
tt_metrics->ppem = 0; |
445 |
tt_metrics->scale = 0; |
446 |
tt_metrics->ratio = 0x10000L; |
447 |
} |
448 |
|
581 |
|
449 |
exec->instruction_trap = FALSE; |
582 |
if ( error ) |
450 |
|
583 |
tt_size_done( ttsize ); |
451 |
exec->cvtSize = size->cvt_size; |
|
|
452 |
exec->cvt = size->cvt; |
453 |
|
454 |
exec->F_dot_P = 0x10000L; |
455 |
|
456 |
/* allow font program execution */ |
457 |
TT_Set_CodeRange( exec, |
458 |
tt_coderange_font, |
459 |
face->font_program, |
460 |
face->font_program_size ); |
461 |
|
462 |
/* disable CVT and glyph programs coderange */ |
463 |
TT_Clear_CodeRange( exec, tt_coderange_cvt ); |
464 |
TT_Clear_CodeRange( exec, tt_coderange_glyph ); |
465 |
|
466 |
if ( face->font_program_size > 0 ) |
467 |
{ |
468 |
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); |
469 |
if ( !error ) |
470 |
error = face->interpreter( exec ); |
471 |
|
472 |
if ( error ) |
473 |
goto Fail_Exec; |
474 |
} |
475 |
else |
476 |
error = TT_Err_Ok; |
477 |
|
478 |
TT_Save_Context( exec, size ); |
479 |
|
480 |
if ( !size->debug ) |
481 |
TT_Done_Context( exec ); |
482 |
|
584 |
|
483 |
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
585 |
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
484 |
|
586 |
|
485 |
size->ttmetrics.valid = FALSE; |
587 |
size->ttmetrics.valid = FALSE; |
486 |
return error; |
|
|
487 |
|
488 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
489 |
|
490 |
Fail_Exec: |
491 |
if ( !size->debug ) |
492 |
TT_Done_Context( exec ); |
493 |
|
494 |
Fail_Memory: |
495 |
|
588 |
|
496 |
tt_size_done( ttsize ); |
|
|
497 |
return error; |
589 |
return error; |
498 |
|
|
|
499 |
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
500 |
|
501 |
} |
590 |
} |
502 |
|
591 |
|
503 |
|
592 |
|
Lines 516-524
Link Here
|
516 |
tt_size_done( FT_Size ttsize ) /* TT_Size */ |
605 |
tt_size_done( FT_Size ttsize ) /* TT_Size */ |
517 |
{ |
606 |
{ |
518 |
TT_Size size = (TT_Size)ttsize; |
607 |
TT_Size size = (TT_Size)ttsize; |
519 |
|
|
|
520 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
608 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
521 |
|
|
|
522 |
FT_Memory memory = size->root.face->memory; |
609 |
FT_Memory memory = size->root.face->memory; |
523 |
|
610 |
|
524 |
|
611 |
|
Lines 625-634
Link Here
|
625 |
#endif |
712 |
#endif |
626 |
|
713 |
|
627 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
714 |
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
628 |
|
|
|
629 |
{ |
715 |
{ |
630 |
TT_ExecContext exec; |
716 |
FT_UInt i; |
631 |
FT_UInt i, j; |
|
|
632 |
|
717 |
|
633 |
|
718 |
|
634 |
/* Scale the cvt values to the new ppem. */ |
719 |
/* Scale the cvt values to the new ppem. */ |
Lines 637-648
Link Here
|
637 |
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); |
722 |
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); |
638 |
|
723 |
|
639 |
/* All twilight points are originally zero */ |
724 |
/* All twilight points are originally zero */ |
640 |
for ( j = 0; j < (FT_UInt)size->twilight.n_points; j++ ) |
725 |
for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) |
641 |
{ |
726 |
{ |
642 |
size->twilight.org[j].x = 0; |
727 |
size->twilight.org[i].x = 0; |
643 |
size->twilight.org[j].y = 0; |
728 |
size->twilight.org[i].y = 0; |
644 |
size->twilight.cur[j].x = 0; |
729 |
size->twilight.cur[i].x = 0; |
645 |
size->twilight.cur[j].y = 0; |
730 |
size->twilight.cur[i].y = 0; |
646 |
} |
731 |
} |
647 |
|
732 |
|
648 |
/* clear storage area */ |
733 |
/* clear storage area */ |
Lines 651-703
Link Here
|
651 |
|
736 |
|
652 |
size->GS = tt_default_graphics_state; |
737 |
size->GS = tt_default_graphics_state; |
653 |
|
738 |
|
654 |
/* get execution context and run prep program */ |
739 |
error = tt_size_run_prep( size ); |
655 |
if ( size->debug ) |
|
|
656 |
exec = size->context; |
657 |
else |
658 |
exec = TT_New_Context( face ); |
659 |
/* debugging instances have their own context */ |
660 |
|
661 |
if ( !exec ) |
662 |
return TT_Err_Could_Not_Find_Context; |
663 |
|
664 |
TT_Load_Context( exec, face, size ); |
665 |
|
666 |
TT_Set_CodeRange( exec, |
667 |
tt_coderange_cvt, |
668 |
face->cvt_program, |
669 |
face->cvt_program_size ); |
670 |
|
671 |
TT_Clear_CodeRange( exec, tt_coderange_glyph ); |
672 |
|
673 |
exec->instruction_trap = FALSE; |
674 |
|
675 |
exec->top = 0; |
676 |
exec->callTop = 0; |
677 |
|
678 |
if ( face->cvt_program_size > 0 ) |
679 |
{ |
680 |
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); |
681 |
if ( error ) |
682 |
goto End; |
683 |
|
684 |
if ( !size->debug ) |
685 |
error = face->interpreter( exec ); |
686 |
} |
687 |
else |
688 |
error = TT_Err_Ok; |
689 |
|
690 |
size->GS = exec->GS; |
691 |
/* save default graphics state */ |
692 |
|
693 |
End: |
694 |
TT_Save_Context( exec, size ); |
695 |
|
696 |
if ( !size->debug ) |
697 |
TT_Done_Context( exec ); |
698 |
/* debugging instances keep their context */ |
699 |
} |
740 |
} |
700 |
|
|
|
701 |
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
741 |
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
702 |
|
742 |
|
703 |
if ( !error ) |
743 |
if ( !error ) |