freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] clean-gxvar 8bbb1c77d 2/2: [truetype/GX] Clean up phantom po


From: Werner Lemberg
Subject: [freetype2] clean-gxvar 8bbb1c77d 2/2: [truetype/GX] Clean up phantom point accounting.
Date: Fri, 17 Jun 2022 13:46:19 -0400 (EDT)

branch: clean-gxvar
commit 8bbb1c77d6dc58ed01171feb8fb72e5f45c78d70
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [truetype/GX] Clean up phantom point accounting.
    
    * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Infer `n_points`
    from the outline size plus four phantom points.
    * src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Remove this
    argument.
    * src/truetype/ttgload.c (TT_Process_Simple_Glyph, load_truetype_glyph):
    Update all callers.
---
 src/truetype/ttgload.c | 43 ++++++++++++++-----------------------------
 src/truetype/ttgxvar.c |  9 ++-------
 src/truetype/ttgxvar.h |  3 +--
 3 files changed, 17 insertions(+), 38 deletions(-)

diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index d2f7496a1..0f6b5baee 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -987,8 +987,7 @@
       /* Deltas apply to the unscaled data. */
       error = TT_Vary_Apply_Glyph_Deltas( loader,
                                           outline,
-                                          unrounded,
-                                          (FT_UInt)n_points );
+                                          unrounded );
       if ( error )
         goto Exit;
     }
@@ -1747,8 +1746,6 @@
         /* a small outline structure with four elements for */
         /* communication with `TT_Vary_Apply_Glyph_Deltas'  */
         FT_Vector   points[4];
-        char        tags[4]     = { 1, 1, 1, 1 };
-        short       contours[4] = { 0, 1, 2, 3 };
         FT_Outline  outline;
 
         /* unrounded values */
@@ -1765,17 +1762,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;
+        outline.tags       = NULL;
+        outline.contours   = NULL;
 
         /* this must be done before scaling */
         error = TT_Vary_Apply_Glyph_Deltas( loader,
                                             &outline,
-                                            unrounded,
-                                            (FT_UInt)outline.n_points );
+                                            unrounded );
         if ( error )
           goto Exit;
       }
@@ -1925,17 +1921,16 @@
 
         /* construct an outline structure for              */
         /* communication with `TT_Vary_Apply_Glyph_Deltas' */
-        outline.n_points   = (short)( gloader->current.num_subglyphs + 4 );
-        outline.n_contours = outline.n_points;
+        outline.n_contours = outline.n_points = limit;
 
         outline.points   = NULL;
         outline.tags     = NULL;
         outline.contours = NULL;
 
-        if ( FT_NEW_ARRAY( points, outline.n_points )    ||
-             FT_NEW_ARRAY( tags, outline.n_points )      ||
-             FT_NEW_ARRAY( contours, outline.n_points )  ||
-             FT_NEW_ARRAY( unrounded, outline.n_points ) )
+        if ( FT_NEW_ARRAY( points, limit + 4 )    ||
+             FT_NEW_ARRAY( tags, limit + 4 )      ||
+             FT_NEW_ARRAY( contours, limit + 4 )  ||
+             FT_NEW_ARRAY( unrounded, limit + 4 ) )
           goto Exit1;
 
         subglyph = gloader->current.subglyphs;
@@ -1953,26 +1948,18 @@
 
         points[i].x = loader->pp1.x;
         points[i].y = loader->pp1.y;
-        tags[i]     = 1;
-        contours[i] = i;
 
         i++;
         points[i].x = loader->pp2.x;
         points[i].y = loader->pp2.y;
-        tags[i]     = 1;
-        contours[i] = i;
 
         i++;
         points[i].x = loader->pp3.x;
         points[i].y = loader->pp3.y;
-        tags[i]     = 1;
-        contours[i] = i;
 
         i++;
         points[i].x = loader->pp4.x;
         points[i].y = loader->pp4.y;
-        tags[i]     = 1;
-        contours[i] = i;
 
         outline.points   = points;
         outline.tags     = tags;
@@ -1980,11 +1967,9 @@
 
         /* this call provides additional offsets */
         /* for each component's translation      */
-        if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
-                             loader,
-                             &outline,
-                             unrounded,
-                             (FT_UInt)outline.n_points ) ) )
+        if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( loader,
+                                                       &outline,
+                                                       unrounded ) ) )
           goto Exit1;
 
         subglyph = gloader->current.subglyphs;
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 8f8239f15..5027e9591 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -3839,25 +3839,20 @@
    *     An array with `n_points' elements that is filled with unrounded
    *     point coordinates (in 26.6 format).
    *
-   * @Input
-   *   n_points ::
-   *     The number of the points in the glyph, including
-   *     phantom points.
-   *
    * @Return:
    *   FreeType error code.  0 means success.
    */
   FT_LOCAL_DEF( FT_Error )
   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 */
diff --git a/src/truetype/ttgxvar.h b/src/truetype/ttgxvar.h
index b3db2fcd3..15c26373d 100644
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -363,8 +363,7 @@ FT_BEGIN_HEADER
   FT_LOCAL( FT_Error )
   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,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]