freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] anuj-distance-field b457aee 1/2: [sdf] Handle Post-Script fo


From: Anuj Verma
Subject: [freetype2] anuj-distance-field b457aee 1/2: [sdf] Handle Post-Script fonts for overlap.
Date: Wed, 12 Aug 2020 07:52:07 -0400 (EDT)

branch: anuj-distance-field
commit b457aeee675f3dfa60a81159061566dc57ebfe52
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: Anuj Verma <anujv@iitbhilai.ac.in>

    [sdf] Handle Post-Script fonts for overlap.
    
    * src/sdf/ftsdf.c (sdf_generate_with_overlaps): Handle
      Handle Post-Script fonts for overlap support. Simply
      flip the orientation while combining all the separate
      SDF.
      Also, handle the `flip_sign' property separately so as
      to avoid handling extra cases.
---
 [GSoC]ChangeLog | 11 +++++++++++
 src/sdf/ftsdf.c | 27 ++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index fef32de..c70040d 100644
--- a/[GSoC]ChangeLog
+++ b/[GSoC]ChangeLog
@@ -1,5 +1,16 @@
 2020-08-12  Anuj Verma  <anujv@iitbhilai.ac.in>
 
+       [sdf] Handle Post-Script fonts for overlap.
+
+       * src/sdf/ftsdf.c (sdf_generate_with_overlaps): Handle
+         Handle Post-Script fonts for overlap support. Simply
+         flip the orientation while combining all the separate
+         SDF.
+         Also, handle the `flip_sign' property separately so as
+         to avoid handling extra cases.
+
+2020-08-12  Anuj Verma  <anujv@iitbhilai.ac.in>
+
        [sdf] Added overlap support (currently only for TrueType).
 
        * src/sdf/ftsdfrend.h (SDF_Renderer_Module): Removed the
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
index 98f4cfc..0a9f985 100644
--- a/src/sdf/ftsdf.c
+++ b/src/sdf/ftsdf.c
@@ -3207,6 +3207,7 @@
     SDF_Contour*  temp_contour;      /* temporary contour             */
     FT_Memory     memory;            /* to allocate memory            */
     FT_6D10*      t;                 /* target bitmap buffer          */
+    FT_Bool       flip_sign;         /* filp sign?                    */
 
     /* orientation of all the seperate contours */
     SDF_Contour_Orientation*  orientations;
@@ -3239,6 +3240,11 @@
     if ( SDF_ALLOC( orientations, num_contours * sizeof( *orientations ) ) )
       goto Exit;
 
+    /* Disable the 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 through all the contours */
@@ -3281,8 +3287,12 @@
       /* overload the default sign of the outside     */
       /* pixels. Which is necessary for counter clock */
       /* wise contours.                               */
-      if ( orientations[i] == SDF_ORIENTATION_ACW )
+      if ( orientations[i] == SDF_ORIENTATION_ACW &&
+           internal_params.orientation == FT_ORIENTATION_FILL_RIGHT )
         internal_params.overload_sign = -1;
+      if ( orientations[i] == SDF_ORIENTATION_CW &&
+           internal_params.orientation == FT_ORIENTATION_FILL_LEFT )
+        internal_params.overload_sign = 1;
       else
         internal_params.overload_sign = 0;
 
@@ -3292,6 +3302,16 @@
                                          spread,
                                          &bitmaps[i] ) );
 
+      /* Simply flip the orientation in case of post-scritp fonts, */
+      /* so as to avoid modificatons in the combining phase.       */
+      if ( internal_params.orientation == FT_ORIENTATION_FILL_LEFT )
+      {
+        if ( orientations[i] == SDF_ORIENTATION_CW )
+          orientations[i] = SDF_ORIENTATION_ACW;
+        else if ( orientations[i] == SDF_ORIENTATION_ACW )
+          orientations[i] = SDF_ORIENTATION_CW;
+      }
+
       contour = contour->next;
     }
 
@@ -3330,8 +3350,9 @@
             val_ac = FT_MIN( val_ac, temp ); /* for anti-clockwise */
         }
 
-        /* finally find the smaller of two and assign to output */
-        t[id] = FT_MIN( val_c, val_ac );
+        /* Finally find the smaller of two and assign to output. */
+        /* Also apply the flip_sign if set.                      */
+        t[id] = FT_MIN( val_c, val_ac ) * ( flip_sign ? -1 : 1 );
       }
     }
 



reply via email to

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