shithub: freetype+ttf2subf

Download patch

ref: 7833e308efec8caf5ce62855e9b27041ad2155ad
parent: 8dc02fb99909df5d459978fbb14836b387c7000d
author: Alexei Podtelezhnikov <apodtele@gmail.com>
date: Wed Jun 9 06:40:30 EDT 2021

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- 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'.
--- 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;
@@ -3543,11 +3548,6 @@
     if ( FT_ALLOC( orientations,
                    (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;
 
--- 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 )