freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] clean-gxvar 45f0e067c: [truetype/GX] Clean up phantom point


From: Werner Lemberg
Subject: [freetype2] clean-gxvar 45f0e067c: [truetype/GX] Clean up phantom point accounting.
Date: Fri, 17 Jun 2022 22:54:36 -0400 (EDT)

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

    [truetype/GX] Clean up phantom point accounting.
    
    This formalizes that the phantom points appended in the outline
    do not increase its point count, nor do they tag them or include
    in any additional contours.  Only their coordinates are stored.
    The glyph zone, however, counts them.
    
    * 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_prepare_zone): Add phantom four.
    (TT_Process_Simple_Glyph, load_truetype_glyph): Update all callers.
---
 src/truetype/ttgload.c | 55 ++++++++++++++++----------------------------------
 src/truetype/ttgxvar.c |  9 ++-------
 src/truetype/ttgxvar.h |  3 +--
 3 files changed, 20 insertions(+), 47 deletions(-)

diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index d2f7496a1..0810377aa 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -801,7 +801,7 @@
                    FT_UInt       start_point,
                    FT_UInt       start_contour )
   {
-    zone->n_points    = (FT_UShort)load->outline.n_points -
+    zone->n_points    = (FT_UShort)load->outline.n_points + 4 -
                           (FT_UShort)start_point;
     zone->n_contours  = load->outline.n_contours -
                           (FT_Short)start_contour;
@@ -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;
     }
@@ -1000,7 +999,7 @@
       tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
 
       FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
-                     loader->zone.n_points + 4 );
+                     loader->zone.n_points );
     }
 
     {
@@ -1142,11 +1141,7 @@
     }
 
     if ( IS_HINTED( loader->load_flags ) )
-    {
-      loader->zone.n_points += 4;
-
       error = TT_Hint_Glyph( loader, 0 );
-    }
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
   Exit:
@@ -1422,11 +1417,9 @@
 
     /* Some points are likely touched during execution of  */
     /* instructions on components.  So let's untouch them. */
-    for ( i = 0; i < loader->zone.n_points; i++ )
+    for ( i = 0; i < loader->zone.n_points - 4; i++ )
       loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
 
-    loader->zone.n_points += 4;
-
     return TT_Hint_Glyph( loader, 1 );
   }
 
@@ -1747,8 +1740,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 +1756,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 +1915,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 +1942,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 +1961,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 4eaa32d56..760293515 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]