* src/truetype/ttobjs.h (tt_size_run_fpgm, tt_size_run_prep): New functions.

* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): New functions.
(tt_size_init): Add 4, instead of 2, (phantom) points to twilight zone.
Move code that runs fpgm to tt_size_run_fpgm.
(Reset_Outline_Size): Move code that runs prep to tt_size_run_prep.
(tt_glyphzone_new): Allocate right size of arrays.
Set max_points and max_contours properly.
This commit is contained in:
Wu, Chia-I (吳佳一) 2005-07-31 11:41:54 +00:00
parent 2a41ab9e88
commit 89fff9b9d1
3 changed files with 211 additions and 152 deletions

View File

@ -1,3 +1,14 @@
2005-07-31 Chia I Wu <b90201047@ntu.edu.tw>
* src/truetype/ttobjs.h (tt_size_run_fpgm, tt_size_run_prep): New functions.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): New functions.
(tt_size_init): Add 4, instead of 2, (phantom) points to twilight zone.
Move code that runs fpgm to tt_size_run_fpgm.
(Reset_Outline_Size): Move code that runs prep to tt_size_run_prep.
(tt_glyphzone_new): Allocate right size of arrays.
Set max_points and max_contours properly.
2005-07-26 Chia I Wu <b90201047@ntu.edu.tw> 2005-07-26 Chia I Wu <b90201047@ntu.edu.tw>
* src/truetype/ttdriver.c (Set_Char_Sizes): Avoid unnecessary * src/truetype/ttdriver.c (Set_Char_Sizes): Avoid unnecessary

View File

@ -121,19 +121,21 @@
FT_Error error; FT_Error error;
if ( maxPoints > 0 )
maxPoints += 2;
FT_MEM_ZERO( zone, sizeof ( *zone ) ); FT_MEM_ZERO( zone, sizeof ( *zone ) );
zone->memory = memory; zone->memory = memory;
if ( FT_NEW_ARRAY( zone->org, maxPoints * 2 ) || if ( FT_NEW_ARRAY( zone->org, maxPoints ) ||
FT_NEW_ARRAY( zone->cur, maxPoints * 2 ) || FT_NEW_ARRAY( zone->cur, maxPoints ) ||
FT_NEW_ARRAY( zone->tags, maxPoints ) || FT_NEW_ARRAY( zone->tags, maxPoints ) ||
FT_NEW_ARRAY( zone->contours, maxContours ) ) FT_NEW_ARRAY( zone->contours, maxContours ) )
{ {
tt_glyphzone_done( zone ); tt_glyphzone_done( zone );
} }
else
{
zone->max_points = maxPoints;
zone->max_contours = maxContours;
}
return error; return error;
} }
@ -318,6 +320,162 @@
/* */ /* */
/*************************************************************************/ /*************************************************************************/
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_run_fpgm */
/* */
/* <Description> */
/* Run the font program */
/* */
/* <Input> */
/* size :: A handle to the size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_size_run_fpgm( TT_Size size )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
FT_Error error;
/* debugging instances have their own context */
if ( size->debug )
exec = size->context;
else
exec = TT_New_Context( face );
if ( !exec )
return TT_Err_Could_Not_Find_Context;
TT_Load_Context( exec, face, size );
exec->callTop = 0;
exec->top = 0;
exec->period = 64;
exec->phase = 0;
exec->threshold = 0;
exec->instruction_trap = FALSE;
exec->F_dot_P = 0x10000L;
{
FT_Size_Metrics* metrics = &exec->metrics;
TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
metrics->x_ppem = 0;
metrics->y_ppem = 0;
metrics->x_scale = 0;
metrics->y_scale = 0;
tt_metrics->ppem = 0;
tt_metrics->scale = 0;
tt_metrics->ratio = 0x10000L;
}
/* allow font program execution */
TT_Set_CodeRange( exec,
tt_coderange_font,
face->font_program,
face->font_program_size );
/* disable CVT and glyph programs coderange */
TT_Clear_CodeRange( exec, tt_coderange_cvt );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->font_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
if ( !error )
error = face->interpreter( exec );
}
else
error = TT_Err_Ok;
if ( !error )
TT_Save_Context( exec, size );
if ( !size->debug )
TT_Done_Context( exec );
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_run_prep */
/* */
/* <Description> */
/* Run the control value program */
/* */
/* <Input> */
/* size :: A handle to the size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_size_run_prep( TT_Size size )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
FT_Error error;
/* debugging instances have their own context */
if ( size->debug )
exec = size->context;
else
exec = TT_New_Context( face );
if ( !exec )
return TT_Err_Could_Not_Find_Context;
TT_Load_Context( exec, face, size );
exec->callTop = 0;
exec->top = 0;
exec->instruction_trap = FALSE;
TT_Set_CodeRange( exec,
tt_coderange_cvt,
face->cvt_program,
face->cvt_program_size );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->cvt_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
if ( !error && !size->debug )
error = face->interpreter( exec );
}
else
error = TT_Err_Ok;
/* save as default graphics state */
size->GS = exec->GS;
TT_Save_Context( exec, size );
if ( !size->debug )
TT_Done_Context( exec );
return error;
}
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@ -338,15 +496,11 @@
{ {
TT_Size size = (TT_Size)ttsize; TT_Size size = (TT_Size)ttsize;
FT_Error error = TT_Err_Ok; FT_Error error = TT_Err_Ok;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
TT_Face face = (TT_Face)size->root.face; TT_Face face = (TT_Face)size->root.face;
FT_Memory memory = face->root.memory; FT_Memory memory = face->root.memory;
FT_Int i; FT_Int i;
TT_ExecContext exec;
FT_UShort n_twilight; FT_UShort n_twilight;
TT_MaxProfile* maxp = &face->max_profile; TT_MaxProfile* maxp = &face->max_profile;
@ -387,17 +541,30 @@
FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
FT_NEW_ARRAY( size->cvt, size->cvt_size ) || FT_NEW_ARRAY( size->cvt, size->cvt_size ) ||
FT_NEW_ARRAY( size->storage, size->storage_size ) ) FT_NEW_ARRAY( size->storage, size->storage_size ) )
{
tt_size_done( ttsize );
goto Fail_Memory; return error;
}
/* reserve twilight zone */ /* reserve twilight zone */
n_twilight = maxp->maxTwilightPoints; n_twilight = maxp->maxTwilightPoints;
/* there are 4 phantom points (do we need this?) */
n_twilight += 4;
error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
if ( error ) if ( error )
goto Fail_Memory; {
tt_size_done( ttsize );
return error;
}
size->twilight.n_points = n_twilight; size->twilight.n_points = n_twilight;
size->GS = tt_default_graphics_state;
/* set `face->interpreter' according to the debug hook present */ /* set `face->interpreter' according to the debug hook present */
{ {
FT_Library library = face->root.driver->root.library; FT_Library library = face->root.driver->root.library;
@ -409,95 +576,17 @@
face->interpreter = (TT_Interpreter)TT_RunIns; face->interpreter = (TT_Interpreter)TT_RunIns;
} }
/* Fine, now execute the font program! */ /* Fine, now run the font program! */
exec = size->context; error = tt_size_run_fpgm( size );
/* size objects used during debugging have their own context */
if ( !size->debug )
exec = TT_New_Context( face );
if ( !exec ) if ( error )
{ tt_size_done( ttsize );
error = TT_Err_Could_Not_Find_Context;
goto Fail_Memory;
}
size->GS = tt_default_graphics_state;
TT_Load_Context( exec, face, size );
exec->callTop = 0;
exec->top = 0;
exec->period = 64;
exec->phase = 0;
exec->threshold = 0;
{
FT_Size_Metrics* metrics = &exec->metrics;
TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
metrics->x_ppem = 0;
metrics->y_ppem = 0;
metrics->x_scale = 0;
metrics->y_scale = 0;
tt_metrics->ppem = 0;
tt_metrics->scale = 0;
tt_metrics->ratio = 0x10000L;
}
exec->instruction_trap = FALSE;
exec->cvtSize = size->cvt_size;
exec->cvt = size->cvt;
exec->F_dot_P = 0x10000L;
/* allow font program execution */
TT_Set_CodeRange( exec,
tt_coderange_font,
face->font_program,
face->font_program_size );
/* disable CVT and glyph programs coderange */
TT_Clear_CodeRange( exec, tt_coderange_cvt );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->font_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
if ( !error )
error = face->interpreter( exec );
if ( error )
goto Fail_Exec;
}
else
error = TT_Err_Ok;
TT_Save_Context( exec, size );
if ( !size->debug )
TT_Done_Context( exec );
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
size->ttmetrics.valid = FALSE; size->ttmetrics.valid = FALSE;
return error; return error;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
Fail_Exec:
if ( !size->debug )
TT_Done_Context( exec );
Fail_Memory:
tt_size_done( ttsize );
return error;
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
} }
@ -516,9 +605,7 @@
tt_size_done( FT_Size ttsize ) /* TT_Size */ tt_size_done( FT_Size ttsize ) /* TT_Size */
{ {
TT_Size size = (TT_Size)ttsize; TT_Size size = (TT_Size)ttsize;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
FT_Memory memory = size->root.face->memory; FT_Memory memory = size->root.face->memory;
@ -625,10 +712,8 @@
#endif #endif
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
{ {
TT_ExecContext exec; FT_UInt i;
FT_UInt i, j;
/* Scale the cvt values to the new ppem. */ /* Scale the cvt values to the new ppem. */
@ -637,12 +722,12 @@
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
/* All twilight points are originally zero */ /* All twilight points are originally zero */
for ( j = 0; j < (FT_UInt)size->twilight.n_points; j++ ) for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
{ {
size->twilight.org[j].x = 0; size->twilight.org[i].x = 0;
size->twilight.org[j].y = 0; size->twilight.org[i].y = 0;
size->twilight.cur[j].x = 0; size->twilight.cur[i].x = 0;
size->twilight.cur[j].y = 0; size->twilight.cur[i].y = 0;
} }
/* clear storage area */ /* clear storage area */
@ -651,53 +736,8 @@
size->GS = tt_default_graphics_state; size->GS = tt_default_graphics_state;
/* get execution context and run prep program */ error = tt_size_run_prep( size );
if ( size->debug )
exec = size->context;
else
exec = TT_New_Context( face );
/* debugging instances have their own context */
if ( !exec )
return TT_Err_Could_Not_Find_Context;
TT_Load_Context( exec, face, size );
TT_Set_CodeRange( exec,
tt_coderange_cvt,
face->cvt_program,
face->cvt_program_size );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
exec->instruction_trap = FALSE;
exec->top = 0;
exec->callTop = 0;
if ( face->cvt_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
if ( error )
goto End;
if ( !size->debug )
error = face->interpreter( exec );
}
else
error = TT_Err_Ok;
size->GS = exec->GS;
/* save default graphics state */
End:
TT_Save_Context( exec, size );
if ( !size->debug )
TT_Done_Context( exec );
/* debugging instances keep their context */
} }
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
if ( !error ) if ( !error )

View File

@ -417,6 +417,14 @@ FT_BEGIN_HEADER
FT_LOCAL( void ) FT_LOCAL( void )
tt_size_done( FT_Size ttsize ); /* TT_Size */ tt_size_done( FT_Size ttsize ); /* TT_Size */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
FT_LOCAL( FT_Error )
tt_size_run_fpgm( TT_Size size );
FT_LOCAL( FT_Error )
tt_size_run_prep( TT_Size size );
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
tt_size_reset( TT_Size size ); tt_size_reset( TT_Size size );