forked from minhngoc25a/freetype2
[truetype/GX] Clean up advance adjustment.
* src/truetype/ttgload.c (TT_Process_Simple_Glyph, load_truetype_glyph): Move the advance adjustment from here... * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here and simplify arguments. * src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Update prototype with fewer arguments.
This commit is contained in:
parent
8bb7722a53
commit
d6fc8c6ba0
|
@ -985,24 +985,10 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
/* Deltas apply to the unscaled data. */
|
/* Deltas apply to the unscaled data. */
|
||||||
error = TT_Vary_Apply_Glyph_Deltas( loader->face,
|
error = TT_Vary_Apply_Glyph_Deltas( loader,
|
||||||
loader->glyph_index,
|
|
||||||
outline,
|
outline,
|
||||||
unrounded,
|
unrounded,
|
||||||
(FT_UInt)n_points );
|
(FT_UInt)n_points );
|
||||||
|
|
||||||
/* recalculate linear horizontal and vertical advances */
|
|
||||||
/* if we don't have HVAR and VVAR, respectively */
|
|
||||||
|
|
||||||
/* XXX: change all FreeType modules to store `linear' and `vadvance' */
|
|
||||||
/* in 26.6 format before the `base' module scales them to 16.16 */
|
|
||||||
if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
|
|
||||||
loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
|
|
||||||
unrounded[n_points - 4].x ) / 64;
|
|
||||||
if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
|
|
||||||
loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].x -
|
|
||||||
unrounded[n_points - 2].x ) / 64;
|
|
||||||
|
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
@ -1786,8 +1772,7 @@
|
||||||
outline.contours = contours;
|
outline.contours = contours;
|
||||||
|
|
||||||
/* this must be done before scaling */
|
/* this must be done before scaling */
|
||||||
error = TT_Vary_Apply_Glyph_Deltas( loader->face,
|
error = TT_Vary_Apply_Glyph_Deltas( loader,
|
||||||
glyph_index,
|
|
||||||
&outline,
|
&outline,
|
||||||
unrounded,
|
unrounded,
|
||||||
(FT_UInt)outline.n_points );
|
(FT_UInt)outline.n_points );
|
||||||
|
@ -1803,15 +1788,6 @@
|
||||||
loader->pp3.y = points[2].y;
|
loader->pp3.y = points[2].y;
|
||||||
loader->pp4.x = points[3].x;
|
loader->pp4.x = points[3].x;
|
||||||
loader->pp4.y = points[3].y;
|
loader->pp4.y = points[3].y;
|
||||||
|
|
||||||
/* recalculate linear horizontal and vertical advances */
|
|
||||||
/* if we don't have HVAR and VVAR, respectively */
|
|
||||||
if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
|
|
||||||
loader->linear = FT_PIX_ROUND( unrounded[1].x -
|
|
||||||
unrounded[0].x ) / 64;
|
|
||||||
if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
|
|
||||||
loader->vadvance = FT_PIX_ROUND( unrounded[3].x -
|
|
||||||
unrounded[2].x ) / 64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
||||||
|
@ -2015,8 +1991,7 @@
|
||||||
/* this call provides additional offsets */
|
/* this call provides additional offsets */
|
||||||
/* for each component's translation */
|
/* for each component's translation */
|
||||||
if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
|
if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
|
||||||
face,
|
loader,
|
||||||
glyph_index,
|
|
||||||
&outline,
|
&outline,
|
||||||
unrounded,
|
unrounded,
|
||||||
(FT_UInt)outline.n_points ) ) )
|
(FT_UInt)outline.n_points ) ) )
|
||||||
|
|
|
@ -3827,39 +3827,37 @@
|
||||||
* @Description:
|
* @Description:
|
||||||
* Apply the appropriate deltas to the current glyph.
|
* Apply the appropriate deltas to the current glyph.
|
||||||
*
|
*
|
||||||
* @Input:
|
|
||||||
* face ::
|
|
||||||
* A handle to the target face object.
|
|
||||||
*
|
|
||||||
* glyph_index ::
|
|
||||||
* The index of the glyph being modified.
|
|
||||||
*
|
|
||||||
* n_points ::
|
|
||||||
* The number of the points in the glyph, including
|
|
||||||
* phantom points.
|
|
||||||
*
|
|
||||||
* @InOut:
|
* @InOut:
|
||||||
|
* loader ::
|
||||||
|
* A handle to the loader object.
|
||||||
|
*
|
||||||
* outline ::
|
* outline ::
|
||||||
* The outline to change.
|
* The outline to change, with appended phantom points.
|
||||||
*
|
*
|
||||||
* @Output:
|
* @Output:
|
||||||
* unrounded ::
|
* unrounded ::
|
||||||
* An array with `n_points' elements that is filled with unrounded
|
* An array with `n_points' elements that is filled with unrounded
|
||||||
* point coordinates (in 26.6 format).
|
* point coordinates (in 26.6 format).
|
||||||
*
|
*
|
||||||
|
* @Input
|
||||||
|
* n_points ::
|
||||||
|
* The number of the points in the glyph, including
|
||||||
|
* phantom points.
|
||||||
|
*
|
||||||
* @Return:
|
* @Return:
|
||||||
* FreeType error code. 0 means success.
|
* FreeType error code. 0 means success.
|
||||||
*/
|
*/
|
||||||
FT_LOCAL_DEF( FT_Error )
|
FT_LOCAL_DEF( FT_Error )
|
||||||
TT_Vary_Apply_Glyph_Deltas( TT_Face face,
|
TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
|
||||||
FT_UInt glyph_index,
|
|
||||||
FT_Outline* outline,
|
FT_Outline* outline,
|
||||||
FT_Vector* unrounded,
|
FT_Vector* unrounded,
|
||||||
FT_UInt n_points )
|
FT_UInt n_points )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
TT_Face face = loader->face;
|
||||||
FT_Stream stream = face->root.stream;
|
FT_Stream stream = face->root.stream;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
FT_UInt glyph_index = loader->glyph_index;
|
||||||
|
|
||||||
FT_Vector* points_org = NULL; /* coordinates in 16.16 format */
|
FT_Vector* points_org = NULL; /* coordinates in 16.16 format */
|
||||||
FT_Vector* points_out = NULL; /* coordinates in 16.16 format */
|
FT_Vector* points_out = NULL; /* coordinates in 16.16 format */
|
||||||
|
@ -4255,6 +4253,15 @@
|
||||||
outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
|
outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* recalculate linear horizontal and vertical advances */
|
||||||
|
/* if we don't have HVAR and VVAR, respectively */
|
||||||
|
if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
|
||||||
|
loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
|
||||||
|
unrounded[n_points - 4].x ) / 64;
|
||||||
|
if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
|
||||||
|
loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].x -
|
||||||
|
unrounded[n_points - 2].x ) / 64;
|
||||||
|
|
||||||
Fail3:
|
Fail3:
|
||||||
FT_FREE( point_deltas_x );
|
FT_FREE( point_deltas_x );
|
||||||
FT_FREE( point_deltas_y );
|
FT_FREE( point_deltas_y );
|
||||||
|
|
|
@ -361,8 +361,7 @@ FT_BEGIN_HEADER
|
||||||
|
|
||||||
|
|
||||||
FT_LOCAL( FT_Error )
|
FT_LOCAL( FT_Error )
|
||||||
TT_Vary_Apply_Glyph_Deltas( TT_Face face,
|
TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
|
||||||
FT_UInt glyph_index,
|
|
||||||
FT_Outline* outline,
|
FT_Outline* outline,
|
||||||
FT_Vector* unrounded,
|
FT_Vector* unrounded,
|
||||||
FT_UInt n_points );
|
FT_UInt n_points );
|
||||||
|
|
Loading…
Reference in New Issue