diff --git a/ChangeLog b/ChangeLog index f30791f63..6d167f8b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-08-05 Alexei Podtelezhnikov + + [truetype] Clean up types. + + * src/truetype/ttobjs.c (TT_Size): Move declaration from here. + * include/freetype/internal/tttypes.h (TT_Size): ... to here. + (TT_LoaderRec): Switch to appropriate types for `face' and `size'. + * src/truetype/ttgload.c: Remove corresponding type casts. + * src/truetype/ttsubpix.c: Ditto. + 2015-08-05 Werner Lemberg [autofit] Improve recognition of flat vs. rounded segments. diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h index 31dd0aac6..1507a7c57 100644 --- a/include/freetype/internal/tttypes.h +++ b/include/freetype/internal/tttypes.h @@ -1457,11 +1457,23 @@ FT_BEGIN_HEADER /* handle to execution context */ typedef struct TT_ExecContextRec_* TT_ExecContext; + + /*************************************************************************/ + /* */ + /* */ + /* TT_Size */ + /* */ + /* */ + /* A handle to a TrueType size object. */ + /* */ + typedef struct TT_SizeRec_* TT_Size; + + /* glyph loader structure */ typedef struct TT_LoaderRec_ { - FT_Face face; - FT_Size size; + TT_Face face; + TT_Size size; FT_GlyphSlot glyph; FT_GlyphLoader gloader; diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 204248fb2..38a25a577 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -120,7 +120,7 @@ tt_get_metrics( TT_Loader loader, FT_UInt glyph_index ) { - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); #endif @@ -182,7 +182,7 @@ tt_get_metrics_incr_overrides( TT_Loader loader, FT_UInt glyph_index ) { - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; FT_Short left_bearing = 0, top_bearing = 0; FT_UShort advance_width = 0, advance_height = 0; @@ -754,7 +754,7 @@ FT_Bool is_composite ) { #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); #endif @@ -781,7 +781,7 @@ FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points ); /* Reset graphics state. */ - loader->exec->GS = ((TT_Size)loader->size)->GS; + loader->exec->GS = loader->size->GS; /* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */ /* completely refer to the (already) hinted subglyphs. */ @@ -794,10 +794,8 @@ } else { - loader->exec->metrics.x_scale = - ((TT_Size)loader->size)->metrics.x_scale; - loader->exec->metrics.y_scale = - ((TT_Size)loader->size)->metrics.y_scale; + loader->exec->metrics.x_scale = loader->size->metrics.x_scale; + loader->exec->metrics.y_scale = loader->size->metrics.y_scale; } #endif @@ -897,13 +895,13 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( ((TT_Face)loader->face)->doblend ) + if ( loader->face->doblend ) { /* Deltas apply to the unscaled data. */ - error = TT_Vary_Apply_Glyph_Deltas( (TT_Face)(loader->face), - loader->glyph_index, - outline, - (FT_UInt)n_points ); + error = TT_Vary_Apply_Glyph_Deltas( loader->face, + loader->glyph_index, + outline, + (FT_UInt)n_points ); if ( error ) return error; } @@ -920,7 +918,7 @@ { #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); FT_String* family = face->root.family_name; @@ -953,9 +951,9 @@ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 || x_scale_factor != 1000 ) { - x_scale = FT_MulDiv( ((TT_Size)loader->size)->metrics.x_scale, + x_scale = FT_MulDiv( loader->size->metrics.x_scale, (FT_Long)x_scale_factor, 1000 ); - y_scale = ((TT_Size)loader->size)->metrics.y_scale; + y_scale = loader->size->metrics.y_scale; /* compensate for any scaling by de/emboldening; */ /* the amount was determined via experimentation */ @@ -975,8 +973,8 @@ /* scale the glyph */ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { - x_scale = ((TT_Size)loader->size)->metrics.x_scale; - y_scale = ((TT_Size)loader->size)->metrics.y_scale; + x_scale = loader->size->metrics.x_scale; + y_scale = loader->size->metrics.y_scale; do_scale = TRUE; } @@ -1135,8 +1133,8 @@ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) { - FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale; - FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale; + FT_Fixed x_scale = loader->size->metrics.x_scale; + FT_Fixed y_scale = loader->size->metrics.y_scale; x = FT_MulFix( x, x_scale ); @@ -1215,7 +1213,7 @@ FT_TRACE5(( " Instructions size = %d\n", n_ins )); /* check it */ - max_ins = ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions; + max_ins = loader->face->max_profile.maxSizeOfInstructions; if ( n_ins > max_ins ) { /* don't trust `maxSizeOfInstructions'; */ @@ -1412,7 +1410,7 @@ FT_Error error = FT_Err_Ok; FT_Fixed x_scale, y_scale; FT_ULong offset; - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; FT_GlyphLoader gloader = loader->gloader; FT_Bool opened_frame = 0; @@ -1445,8 +1443,8 @@ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { - x_scale = ((TT_Size)loader->size)->metrics.x_scale; - y_scale = ((TT_Size)loader->size)->metrics.y_scale; + x_scale = loader->size->metrics.x_scale; + y_scale = loader->size->metrics.y_scale; } else { @@ -1552,7 +1550,7 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( ((TT_Face)(loader->face))->doblend ) + if ( loader->face->doblend ) { /* a small outline structure with four elements for */ /* communication with `TT_Vary_Apply_Glyph_Deltas' */ @@ -1579,10 +1577,10 @@ outline.contours = contours; /* this must be done before scaling */ - error = TT_Vary_Apply_Glyph_Deltas( (TT_Face)(loader->face), - glyph_index, - &outline, - (FT_UInt)outline.n_points ); + error = TT_Vary_Apply_Glyph_Deltas( loader->face, + glyph_index, + &outline, + (FT_UInt)outline.n_points ); if ( error ) goto Exit; @@ -1935,7 +1933,7 @@ compute_glyph_metrics( TT_Loader loader, FT_UInt glyph_index ) { - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); #endif @@ -1943,7 +1941,7 @@ FT_BBox bbox; FT_Fixed y_scale; TT_GlyphSlot glyph = loader->glyph; - TT_Size size = (TT_Size)loader->size; + TT_Size size = loader->size; y_scale = 0x10000L; @@ -2414,8 +2412,8 @@ loader->load_flags = (FT_ULong)load_flags; - loader->face = (FT_Face)face; - loader->size = (FT_Size)size; + loader->face = face; + loader->size = size; loader->glyph = (FT_GlyphSlot)glyph; loader->stream = stream; diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h index 7ac4123ca..9396089a9 100644 --- a/src/truetype/ttobjs.h +++ b/src/truetype/ttobjs.h @@ -39,17 +39,6 @@ FT_BEGIN_HEADER typedef struct TT_DriverRec_* TT_Driver; - /*************************************************************************/ - /* */ - /* */ - /* TT_Instance */ - /* */ - /* */ - /* A handle to a TrueType size object. */ - /* */ - typedef struct TT_SizeRec_* TT_Size; - - /*************************************************************************/ /* */ /* */ diff --git a/src/truetype/ttsubpix.c b/src/truetype/ttsubpix.c index dbda4d968..0d391e95a 100644 --- a/src/truetype/ttsubpix.c +++ b/src/truetype/ttsubpix.c @@ -903,7 +903,7 @@ sph_set_tweaks( TT_Loader loader, FT_UInt glyph_index ) { - TT_Face face = (TT_Face)loader->face; + TT_Face face = loader->face; FT_String* family = face->root.family_name; FT_UInt ppem = loader->size->metrics.x_ppem; FT_String* style = face->root.style_name;