[sdf] Fix SDF positioning. * src/sdf/ftsdfrend.c (ft_sdf_render, ft_bsdf_render): Add padding to `bitmap_top' and `bitmap_left'. * sdf/sdf/ftsdf.c (sdf_generate_with_overlaps): Fix VC++ warning.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/ChangeLog b/ChangeLog
index 01f696d..8afac74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-06-09 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [sdf] Fix SDF positioning.
+
+ * src/sdf/ftsdfrend.c (ft_sdf_render, ft_bsdf_render): Add padding to
+ `bitmap_top' and `bitmap_left'.
+
+ * sdf/sdf/ftsdf.c (sdf_generate_with_overlaps): Fix VC++ warning.
+
2021-06-08 Werner Lemberg <wl@gnu.org>
Fix 'devel' build for COLR 'v1'.
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
index b377bde..65a8f32 100644
--- a/src/sdf/ftsdf.c
+++ b/src/sdf/ftsdf.c
@@ -3520,6 +3520,11 @@
if ( !shape || !bitmap || !shape->memory )
return FT_THROW( Invalid_Argument );
+ /* Disable `flip_sign` to avoid extra complication */
+ /* during the combination phase. */
+ flip_sign = internal_params.flip_sign;
+ internal_params.flip_sign = 0;
+
contour = shape->contours;
memory = shape->memory;
temp_shape.memory = memory;
@@ -3544,11 +3549,6 @@
(FT_UInt)num_contours * sizeof ( *orientations ) ) )
goto Exit;
- /* Disable `flip_sign` to avoid extra complication */
- /* during the combination phase. */
- flip_sign = internal_params.flip_sign;
- internal_params.flip_sign = 0;
-
contour = shape->contours;
/* Iterate over all contours and generate SDF separately. */
diff --git a/src/sdf/ftsdfrend.c b/src/sdf/ftsdfrend.c
index aedc5bb..f8ffd19 100644
--- a/src/sdf/ftsdfrend.c
+++ b/src/sdf/ftsdfrend.c
@@ -323,8 +323,11 @@
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
- x_shift = 64 * -( slot->bitmap_left - x_pad );
- y_shift = 64 * -( slot->bitmap_top + y_pad );
+ slot->bitmap_top += y_pad;
+ slot->bitmap_left -= x_pad;
+
+ x_shift = 64 * -slot->bitmap_left;
+ y_shift = 64 * -slot->bitmap_top;
y_shift += 64 * (FT_Int)bitmap->rows;
if ( origin )
@@ -520,7 +523,7 @@
y_pad = sdf_module->spread;
/* apply padding, which extends to all directions */
- target.rows = bitmap->rows + y_pad * 2;
+ target.rows = bitmap->rows + y_pad * 2;
target.width = bitmap->width + x_pad * 2;
/* set up the target bitmap */
@@ -553,6 +556,8 @@
}
slot->bitmap = target;
+ slot->bitmap_top += y_pad;
+ slot->bitmap_left -= x_pad;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
}
else if ( target.buffer )