emacs-diffs
[Top][All Lists]
Advanced

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

feature/android f92413a7964: Update Android port


From: Po Lu
Subject: feature/android f92413a7964: Update Android port
Date: Tue, 28 Mar 2023 07:22:05 -0400 (EDT)

branch: feature/android
commit f92413a79649ad65e132b450468c933bb1972642
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Update Android port
    
    * src/sfnt.c (sfnt_vary_compound_glyph):
    * src/sfntfont.c (sfntfont_get_glyph)
    (sfntfont_get_glyph_outline): Avoid clobbering offset size flag
    when varying compound glyph.
---
 src/sfnt.c     | 60 ++++------------------------------------------------------
 src/sfntfont.c | 29 +++++++++++-----------------
 2 files changed, 15 insertions(+), 74 deletions(-)

diff --git a/src/sfnt.c b/src/sfnt.c
index d2d3500a18d..d2c726367cb 100644
--- a/src/sfnt.c
+++ b/src/sfnt.c
@@ -14549,8 +14549,6 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
   uint16_t *local_points, n_local_points;
   sfnt_fixed scale;
   ptrdiff_t data_offset;
-  bool *touched;
-  sfnt_fword *restrict original_x, *restrict original_y;
   struct sfnt_compound_glyph_component *component;
 
   gvar = blend->gvar;
@@ -14628,12 +14626,6 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
   intermediate_start = coords + gvar->axis_count;
   intermediate_end = coords + gvar->axis_count;
 
-  /* Allocate arrays of booleans and fwords to keep track of which
-     points have been touched.  */
-  touched = NULL;
-  original_x = NULL;
-  original_y = NULL;
-
   while (ntuples--)
     {
       data = gvar->glyph_variation_data + offset + data_offset;
@@ -14775,7 +14767,6 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
                word = component->argument1.d;
 
              fword = sfnt_mul_fixed_round (dx[i], scale);
-             component->flags |= 01;
              component->argument1.d = word + fword;
 
              /* Vary the Y offset.  */
@@ -14786,6 +14777,8 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
                word = component->argument2.d;
 
              fword = sfnt_mul_fixed_round (dy[i], scale);
+
+             /* Set the flag that says offsets are words.  */
              component->flags |= 01;
              component->argument2.d = word + fword;
            }
@@ -14804,36 +14797,6 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
 
          /* Deltas are only applied for each point number read.  */
 
-         if (!original_x)
-           {
-             if ((glyph->compound->num_components
-                  * sizeof *touched) >= 1024 * 16)
-               touched = xmalloc (sizeof *touched
-                                  * glyph->compound->num_components);
-             else
-               touched = alloca (sizeof *touched
-                                 * glyph->compound->num_components);
-
-             if ((sizeof *original_x * 2
-                  * glyph->compound->num_components) >= 1024 * 16)
-               original_x = xmalloc (sizeof *original_x * 2
-                                     * glyph->compound->num_components);
-             else
-               original_x = alloca (sizeof *original_x * 2
-                                    * glyph->compound->num_components);
-
-             original_y = original_x + glyph->compound->num_components;
-             memcpy (original_x, glyph->simple->x_coordinates,
-                     (sizeof *original_x
-                      * glyph->compound->num_components));
-             memcpy (original_y, glyph->simple->y_coordinates,
-                     (sizeof *original_y
-                      * glyph->compound->num_components));
-           }
-
-         memset (touched, 0, (sizeof *touched
-                              * glyph->compound->num_components));
-
          for (i = 0; i < point_count; ++i)
            {
              /* Apply deltas to phantom points.  */
@@ -14868,7 +14831,6 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
                word = component->argument1.d;
 
              fword = sfnt_mul_fixed_round (dx[i], scale);
-             component->flags |= 01;
              component->argument1.d = word + fword;
 
              /* Vary the Y offset.  */
@@ -14879,6 +14841,8 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
                word = component->argument2.d;
 
              fword = sfnt_mul_fixed_round (dy[i], scale);
+
+             /* Set the flag that says offsets are words.  */
              component->flags |= 01;
              component->argument2.d = word + fword;
            }
@@ -14895,17 +14859,9 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
 
   /* Return success.  */
 
-  if ((glyph->compound->num_components
-       * sizeof *touched) >= 1024 * 16)
-    xfree (touched);
-
   if (gvar->axis_count * sizeof *coords * 3 >= 1024 * 16)
     xfree (coords);
 
-  if ((sizeof *original_x * 2
-       * glyph->compound->num_components) >= 1024 * 16)
-    xfree (original_x);
-
   if (points != (uint16_t *) -1)
     xfree (points);
 
@@ -14921,17 +14877,9 @@ sfnt_vary_compound_glyph (struct sfnt_blend *blend, 
sfnt_glyph id,
   xfree (local_points);
  fail1:
 
-  if ((glyph->compound->num_components
-       * sizeof *touched) >= 1024 * 16)
-    xfree (touched);
-
   if (gvar->axis_count * sizeof *coords * 3 >= 1024 * 16)
     xfree (coords);
 
-  if ((sizeof *original_x * 2
-       * glyph->compound->num_components) >= 1024 * 16)
-    xfree (original_x);
-
   if (points != (uint16_t *) -1)
     xfree (points);
 
diff --git a/src/sfntfont.c b/src/sfntfont.c
index daf8f54c03c..3476da6734e 100644
--- a/src/sfntfont.c
+++ b/src/sfntfont.c
@@ -1886,18 +1886,14 @@ sfntfont_get_glyph (sfnt_glyph glyph_id, void *dcontext,
                           tables->loca_short,
                           tables->loca_long);
 
-  if (!tables->blend || !glyph)
-    return glyph;
-
-  if ((glyph->simple
-       && sfnt_vary_simple_glyph (tables->blend, glyph_id,
-                                 glyph, &distortion))
-      || (!glyph->simple
-         && sfnt_vary_compound_glyph (tables->blend, glyph_id,
-                                      glyph, &distortion)))
+  if (tables->blend && glyph)
     {
-      sfnt_free_glyph (glyph);
-      return NULL;
+      if (glyph->simple)
+       sfnt_vary_simple_glyph (tables->blend, glyph_id, glyph,
+                               &distortion);
+      else
+       sfnt_vary_compound_glyph (tables->blend, glyph_id, glyph,
+                                 &distortion);
     }
 
   /* Note that the distortion is not relevant for compound glyphs.  */
@@ -2022,14 +2018,11 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code,
              return NULL;
            }
        }
-      else if (!glyph->simple)
+      else if (sfnt_vary_compound_glyph (blend, glyph_code,
+                                        glyph, &distortion))
        {
-         if (sfnt_vary_compound_glyph (blend, glyph_code,
-                                       glyph, &distortion))
-           {
-             sfnt_free_glyph (glyph);
-             return NULL;
-           }
+         sfnt_free_glyph (glyph);
+         return NULL;
        }
     }
 



reply via email to

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