]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't magnify extent of shifts by variable glyph interpolation
authorPo Lu <luangruo@yahoo.com>
Wed, 3 Jan 2024 05:42:27 +0000 (13:42 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 3 Jan 2024 14:41:23 +0000 (15:41 +0100)
* src/sfnt.c (sfnt_infer_deltas_2): Correctly index
x_coordinates and y_coordinates computing deltas for plain
shift.
(sfnt_vary_simple_glyph): Copy glyph contents to original_x and
original_y not the first time is create, but before each tuple
is applied.

(cherry picked from commit b1380af072d5a76a6f95726fee0eb378dc26849b)

src/sfnt.c

index e66292c6ad8f7e15556f19ee5238ca6020023cf8..aa8b49a9ecdde0610f67ce91222730ee2271efb8 100644 (file)
@@ -15411,7 +15411,7 @@ sfnt_infer_deltas_2 (struct sfnt_glyph *glyph, size_t pair_start,
              d1 = (glyph->simple->x_coordinates[pair_start]
                    - x[pair_start]);
              d2 = (glyph->simple->x_coordinates[pair_end]
-                   - x[pair_start]);
+                   - x[pair_end]);
 
              if (d1 == d2)
                glyph->simple->x_coordinates[j] += d1;
@@ -15483,7 +15483,7 @@ sfnt_infer_deltas_2 (struct sfnt_glyph *glyph, size_t pair_start,
              d1 = (glyph->simple->y_coordinates[pair_start]
                    - y[pair_start]);
              d2 = (glyph->simple->y_coordinates[pair_end]
-                   - y[pair_start]);
+                   - y[pair_end]);
 
              if (d1 == d2)
                glyph->simple->y_coordinates[j] += d1;
@@ -15915,14 +15915,20 @@ sfnt_vary_simple_glyph (struct sfnt_blend *blend, sfnt_glyph id,
                                     * glyph->simple->number_of_points);
 
              original_y = original_x + glyph->simple->number_of_points;
-             memcpy (original_x, glyph->simple->x_coordinates,
-                     (sizeof *original_x
-                      * glyph->simple->number_of_points));
-             memcpy (original_y, glyph->simple->y_coordinates,
-                     (sizeof *original_y
-                      * glyph->simple->number_of_points));
            }
 
+         /* The array of original coordinates should reflect the
+            state of the glyph immediately before deltas from this
+            tuple are applied, in contrast to the state before any
+            deltas are applied.  */
+
+         memcpy (original_x, glyph->simple->x_coordinates,
+                 (sizeof *original_x
+                  * glyph->simple->number_of_points));
+         memcpy (original_y, glyph->simple->y_coordinates,
+                 (sizeof *original_y
+                  * glyph->simple->number_of_points));
+
          memset (touched, 0, (sizeof *touched
                               * glyph->simple->number_of_points));