summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2024-01-03 13:42:27 +0800
committerPo Lu <luangruo@yahoo.com>2024-01-03 13:53:39 +0800
commitb1380af072d5a76a6f95726fee0eb378dc26849b (patch)
treeca1e495ddc9a37c99f4804cd1164d0f03671eca8
parentef71ff4c7e27a04344d8ddcca7e7d3e2822e38bf (diff)
downloademacs-b1380af072d5a76a6f95726fee0eb378dc26849b.tar.gz
Don't magnify extent of shifts by variable glyph interpolation
* 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.
-rw-r--r--src/sfnt.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/sfnt.c b/src/sfnt.c
index e66292c6ad8..aa8b49a9ecd 100644
--- a/src/sfnt.c
+++ b/src/sfnt.c
@@ -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));