* src/truetype/ttgload.c (load_truetype_glyph): Fix compiler

warnings.

Formatting.
This commit is contained in:
Werner Lemberg 2005-08-19 08:56:29 +00:00
parent da245ee30a
commit ffa033b1bc
3 changed files with 85 additions and 60 deletions

View File

@ -1,3 +1,8 @@
2005-08-19 Werner Lemberg <wl@gnu.org>
* src/truetype/ttgload.c (load_truetype_glyph): Fix compiler
warnings.
2005-08-16 Chia I Wu <b90201047@ntu.edu.tw> 2005-08-16 Chia I Wu <b90201047@ntu.edu.tw>
* src/truetype/ttinterp.c, src/truetype/ttinterp.h: Update copyright * src/truetype/ttinterp.c, src/truetype/ttinterp.h: Update copyright
@ -6,37 +11,48 @@
2005-08-16 Chia I Wu <b90201047@ntu.edu.tw> 2005-08-16 Chia I Wu <b90201047@ntu.edu.tw>
* src/truetype/ttinterp.c, src/truetype/ttinterp.h: Remove original * src/truetype/ttinterp.c, src/truetype/ttinterp.h: Remove original
TT_Done_Context and rename TT_Destroy_Context to TT_Done_Context with TT_Done_Context and rename TT_Destroy_Context to TT_Done_Context
slight changes. with slight changes.
Update all callers.
(TT_New_Context): Now takes TT_Driver argument directly.
Update all callers.
* src/truetype/ttobjs.h (tt_slot_init): New function. * src/truetype/ttobjs.h (tt_slot_init): New function.
* src/truetype/ttobjs.c (tt_driver_init): Initialize execution
* src/truetype/ttobjs.c (tt_driver_init): Initialize execution context context here.
here.
(tt_slot_init): New function to create extra points for the internal (tt_slot_init): New function to create extra points for the internal
glyph loader. We then use it directly, instead of face's glyph loader, glyph loader. We then use it directly, instead of face's glyph
when loading glyph. loader, when loading glyph.
* src/truetype/ttdriver.c: Use tt_slot_init for glyph slot * src/truetype/ttdriver.c (tt_driver_class): Use tt_slot_init for
initialization. glyph slot initialization.
(TT_Load_Glyph): Load flag dependencies are handled here. (Load_Glyph): Load flag dependencies are handled here. Return error
Return error if size is NULL. if size is NULL.
* src/truetype/ttgload.c: Heavy cleanup and refactor. * src/truetype/ttgload.c: Heavy cleanup and refactoring.
(org_to_cur): Removed.
(TT_Load_Simple_Glyph): Call FT_GlyphLoader_CheckPoints.
(TT_Hint_Glyph): New funcion to hint a zone, prepared by caller. (TT_Hint_Glyph): New funcion to hint a zone, prepared by caller.
(TT_Process_Simple_Glyph): Use loader->pp's instead of recalculating. (TT_Process_Simple_Glyph): s/load/loader/.
Use loader->pp values instead of recalculation.
Use TT_Hint_Glyph. Use TT_Hint_Glyph.
No need to save/restore loader->stream before/after No need to save/restore loader->stream before and after
TT_Vary_Get_Glyph_Deltas now. TT_Vary_Get_Glyph_Deltas now.
(TT_LOADER_SET_PP): New macro to calculate and set the four phantom points. (TT_LOADER_SET_PP): New macro to calculate and set the four phantom
(TT_Process_Composite_Component, TT_Process_Composite_Glyph, points.
load_truetype_glyph): Refactor load_truetype_glyph into these three functions. (load_truetype_glyph): Never set exec->glyphSize to 0. This closes
Never set exec->glyphSize to 0. (close #13107) Savannah bug #13107.
Forget glyph frame before calling TT_Process_Simple_Glyph. Forget glyph frame before calling TT_Process_Simple_Glyph.
(TT_Load_Glyph, load_sbit_image, tt_loader_init): Refactor TT_Load_Glyph into Use TT_LOADER_SET_PP.
these three functions. Scale all four phantom points.
Set various fields of `glyph' here, instead of in load_truetype_glyph Split off some functionality to ...
and compute_glyph_metrics. (TT_Process_Composite_Component, TT_Process_Composite_Glyph): These
new functions.
(TT_Load_Glyph): Set various fields of `glyph' here, not in
load_truetype_glyph and compute_glyph_metrics.
Split off some functionality to ...
(load_sbit_image, tt_loader_init): These new functions.
(compute_glyph_metrics): Call FT_Outline_Get_CBox.
2005-08-08 Werner Lemberg <wl@gnu.org> 2005-08-08 Werner Lemberg <wl@gnu.org>

View File

@ -955,9 +955,9 @@
FT_Pos x, y; FT_Pos x, y;
have_scale = ( subglyph->flags & ( WE_HAVE_A_SCALE | have_scale = subglyph->flags & ( WE_HAVE_A_SCALE |
WE_HAVE_AN_XY_SCALE | WE_HAVE_AN_XY_SCALE |
WE_HAVE_A_2X2 ) ); WE_HAVE_A_2X2 );
/* perform the transform required for this subglyph */ /* perform the transform required for this subglyph */
if ( have_scale ) if ( have_scale )
@ -978,17 +978,15 @@
FT_Vector* p2; FT_Vector* p2;
/* match l-th point of the newly loaded component to the k-th point of */ /* match l-th point of the newly loaded component to the k-th point */
/* the previously loaded components. */ /* of the previously loaded components. */
/* change to the point numbers used by our outline */ /* change to the point numbers used by our outline */
k += start_point; k += start_point;
l += num_base_points; l += num_base_points;
if ( k >= (FT_UInt)num_base_points || if ( k >= num_base_points ||
l >= (FT_UInt)num_points ) l >= num_points )
{
return TT_Err_Invalid_Composite; return TT_Err_Invalid_Composite;
}
p1 = gloader->base.outline.points + k; p1 = gloader->base.outline.points + k;
p2 = gloader->base.outline.points + l; p2 = gloader->base.outline.points + l;
@ -1004,9 +1002,9 @@
if ( !x && !y ) if ( !x && !y )
return TT_Err_Ok; return TT_Err_Ok;
/* Use a default value dependent on */ /* Use a default value dependent on */
/* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */ /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */
/* fonts which don't set the xxx_COMPONENT_OFFSET bit. */ /* fonts which don't set the xxx_COMPONENT_OFFSET bit. */
if ( have_scale && if ( have_scale &&
#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED #ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
@ -1017,10 +1015,10 @@
{ {
#if 0 #if 0
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* This algorithm is what Apple documents. But it doesn't work. */ /* This algorithm is what Apple documents. But it doesn't work. */
/* */ /* */
int a = subglyph->transform.xx > 0 ? subglyph->transform.xx int a = subglyph->transform.xx > 0 ? subglyph->transform.xx
: -subglyph->transform.xx; : -subglyph->transform.xx;
int b = subglyph->transform.yx > 0 ? subglyph->transform.yx int b = subglyph->transform.yx > 0 ? subglyph->transform.yx
@ -1042,10 +1040,10 @@
#else /* 0 */ #else /* 0 */
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* This algorithm is a guess and works much better than the above. */ /* This algorithm is a guess and works much better than the above. */
/* */ /* */
FT_Fixed mac_xscale = FT_SqrtFixed( FT_Fixed mac_xscale = FT_SqrtFixed(
FT_MulFix( subglyph->transform.xx, FT_MulFix( subglyph->transform.xx,
subglyph->transform.xx ) + subglyph->transform.xx ) +
@ -1113,7 +1111,9 @@
outline = &loader->gloader->base.outline; outline = &loader->gloader->base.outline;
/* make room for phantom points */ /* make room for phantom points */
error = FT_GlyphLoader_CheckPoints( loader->gloader, outline->n_points + 4, 0 ); error = FT_GlyphLoader_CheckPoints( loader->gloader,
outline->n_points + 4,
0 );
if ( error ) if ( error )
return error; return error;
@ -1161,7 +1161,8 @@
#endif #endif
tt_prepare_zone( &loader->zone, &loader->gloader->base, start_point, start_contour ); tt_prepare_zone( &loader->zone, &loader->gloader->base,
start_point, start_contour );
loader->zone.n_points += 4; loader->zone.n_points += 4;
return TT_Hint_Glyph( loader, 1 ); return TT_Hint_Glyph( loader, 1 );
@ -1283,6 +1284,7 @@
goto Exit; goto Exit;
left_bearing = (FT_Short)metrics.bearing_x; left_bearing = (FT_Short)metrics.bearing_x;
advance_width = (FT_UShort)metrics.advance; advance_width = (FT_UShort)metrics.advance;
# if 0 # if 0
/* GWW: Do I do the same for vertical metrics ??? */ /* GWW: Do I do the same for vertical metrics ??? */
@ -1316,7 +1318,7 @@
} }
/* Set `offset' to the start of the glyph relative to the start of */ /* Set `offset' to the start of the glyph relative to the start of */
/* the 'glyf' table, and `byte_len' to the length of the glyph in */ /* the `glyf' table, and `byte_len' to the length of the glyph in */
/* bytes. */ /* bytes. */
#ifdef FT_CONFIG_OPTION_INCREMENTAL #ifdef FT_CONFIG_OPTION_INCREMENTAL
@ -1346,7 +1348,8 @@
#endif /* FT_CONFIG_OPTION_INCREMENTAL */ #endif /* FT_CONFIG_OPTION_INCREMENTAL */
offset = tt_face_get_location( face, glyph_index, (FT_UInt*)&loader->byte_len ); offset = tt_face_get_location( face, glyph_index,
(FT_UInt*)&loader->byte_len );
if ( loader->byte_len == 0 ) if ( loader->byte_len == 0 )
{ {
@ -1525,7 +1528,7 @@
/*********************************************************************/ /*********************************************************************/
{ {
FT_Int n, num_base_points; FT_UInt n, num_base_points;
FT_SubGlyph subglyph = 0; FT_SubGlyph subglyph = 0;
FT_UInt num_points = start_point; FT_UInt num_points = start_point;
@ -1536,7 +1539,7 @@
FT_GlyphLoader_Add( gloader ); FT_GlyphLoader_Add( gloader );
/* read each subglyph independently */ /* read each subglyph independently */
for ( n = 0; n < (FT_Int)num_subglyphs; n++ ) for ( n = 0; n < num_subglyphs; n++ )
{ {
FT_Vector pp[4]; FT_Vector pp[4];
@ -1815,6 +1818,7 @@
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
static FT_Error static FT_Error
load_sbit_image( TT_Size size, load_sbit_image( TT_Size size,
TT_GlyphSlot glyph, TT_GlyphSlot glyph,
@ -1827,6 +1831,7 @@
FT_Error error; FT_Error error;
TT_SBit_MetricsRec metrics; TT_SBit_MetricsRec metrics;
face = (TT_Face)glyph->face; face = (TT_Face)glyph->face;
sfnt = (SFNT_Service)face->sfnt; sfnt = (SFNT_Service)face->sfnt;
stream = face->root.stream; stream = face->root.stream;
@ -1869,7 +1874,8 @@
return error; return error;
} }
#endif
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
static FT_Error static FT_Error
@ -1934,6 +1940,8 @@
{ {
FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 ); FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 );
if ( error ) if ( error )
{ {
FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" ));
@ -1946,6 +1954,7 @@
{ {
FT_GlyphLoader gloader = glyph->internal->loader; FT_GlyphLoader gloader = glyph->internal->loader;
FT_GlyphLoader_Rewind( gloader ); FT_GlyphLoader_Rewind( gloader );
loader->gloader = gloader; loader->gloader = gloader;
} }