[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] clean-gxvar e94acf35f: [truetype/GX] Clean up advance adjust
From: |
Werner Lemberg |
Subject: |
[freetype2] clean-gxvar e94acf35f: [truetype/GX] Clean up advance adjustment. |
Date: |
Wed, 15 Jun 2022 00:25:11 -0400 (EDT) |
branch: clean-gxvar
commit e94acf35f0a4e2b69bc63353f3c8568145da474d
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[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.
---
src/truetype/ttgload.c | 57 ++++++++------------------------------------------
src/truetype/ttgxvar.c | 34 ++++++++++++++++--------------
src/truetype/ttgxvar.h | 6 ++----
3 files changed, 29 insertions(+), 68 deletions(-)
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index e2908d065..f4dc367de 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -985,24 +985,9 @@
goto Exit;
/* Deltas apply to the unscaled data. */
- error = TT_Vary_Apply_Glyph_Deltas( loader->face,
- loader->glyph_index,
+ error = TT_Vary_Apply_Glyph_Deltas( loader,
outline,
- unrounded,
- (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;
-
+ unrounded );
if ( error )
goto Exit;
}
@@ -1779,18 +1764,16 @@
points[3].x = loader->pp4.x;
points[3].y = loader->pp4.y;
- outline.n_points = 4;
- outline.n_contours = 4;
+ outline.n_points = 0;
+ outline.n_contours = 0;
outline.points = points;
outline.tags = tags;
outline.contours = contours;
/* this must be done before scaling */
- error = TT_Vary_Apply_Glyph_Deltas( loader->face,
- glyph_index,
+ error = TT_Vary_Apply_Glyph_Deltas( loader,
&outline,
- unrounded,
- (FT_UInt)outline.n_points );
+ unrounded );
if ( error )
goto Exit;
@@ -1803,15 +1786,6 @@
loader->pp3.y = points[2].y;
loader->pp4.x = points[3].x;
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 */
@@ -1959,7 +1933,7 @@
/* construct an outline structure for */
/* communication with `TT_Vary_Apply_Glyph_Deltas' */
- outline.n_points = (short)( gloader->current.num_subglyphs + 4 );
+ outline.n_points = (short)( gloader->current.num_subglyphs );
outline.n_contours = outline.n_points;
outline.points = NULL;
@@ -2015,11 +1989,9 @@
/* this call provides additional offsets */
/* for each component's translation */
if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
- face,
- glyph_index,
+ loader,
&outline,
- unrounded,
- (FT_UInt)outline.n_points ) ) )
+ unrounded ) ) )
goto Exit1;
subglyph = gloader->current.subglyphs;
@@ -2043,17 +2015,6 @@
loader->pp4.x = points[i + 3].x;
loader->pp4.y = points[i + 3].y;
- /* 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[outline.n_points - 3].x -
- unrounded[outline.n_points - 4].x ) / 64;
- if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- loader->vadvance =
- FT_PIX_ROUND( unrounded[outline.n_points - 1].x -
- unrounded[outline.n_points - 2].x ) / 64;
-
Exit1:
FT_FREE( outline.points );
FT_FREE( outline.tags );
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 36f70c859..9e31f4dd3 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -3827,20 +3827,12 @@
* @Description:
* 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:
+ * loader ::
+ * A handle to the loader object.
+ *
* outline ::
- * The outline to change.
+ * The outline to change, with appended phantom points.
*
* @Output:
* unrounded ::
@@ -3851,15 +3843,16 @@
* FreeType error code. 0 means success.
*/
FT_LOCAL_DEF( FT_Error )
- TT_Vary_Apply_Glyph_Deltas( TT_Face face,
- FT_UInt glyph_index,
+ TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
FT_Outline* outline,
- FT_Vector* unrounded,
- FT_UInt n_points )
+ FT_Vector* unrounded )
{
FT_Error error;
+ TT_Face face = loader->face;
FT_Stream stream = face->root.stream;
FT_Memory memory = stream->memory;
+ FT_UInt glyph_index = loader->glyph_index;
+ FT_UInt n_points = (FT_UInt)outline->n_points + 4;
FT_Vector* points_org = NULL; /* coordinates in 16.16 format */
FT_Vector* points_out = NULL; /* coordinates in 16.16 format */
@@ -4255,6 +4248,15 @@
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:
FT_FREE( point_deltas_x );
FT_FREE( point_deltas_y );
diff --git a/src/truetype/ttgxvar.h b/src/truetype/ttgxvar.h
index a79b0d211..15c26373d 100644
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -361,11 +361,9 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
- TT_Vary_Apply_Glyph_Deltas( TT_Face face,
- FT_UInt glyph_index,
+ TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
FT_Outline* outline,
- FT_Vector* unrounded,
- FT_UInt n_points );
+ FT_Vector* unrounded );
FT_LOCAL( FT_Error )
tt_hadvance_adjust( TT_Face face,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] clean-gxvar e94acf35f: [truetype/GX] Clean up advance adjustment.,
Werner Lemberg <=