summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnuj Verma <anujv@iitbhilai.ac.in>2020-08-12 11:52:16 +0530
committerAnuj Verma <anujv@iitbhilai.ac.in>2020-08-12 11:52:16 +0530
commitb457aeee675f3dfa60a81159061566dc57ebfe52 (patch)
tree6a81c5429602d689218936ee7e99b6e0059271e0
parentf644a47aaeb40f928e0284cd869352c28f99ae69 (diff)
downloadfreetype2-b457aeee675f3dfa60a81159061566dc57ebfe52.tar.gz
[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.
-rw-r--r--[GSoC]ChangeLog11
-rw-r--r--src/sdf/ftsdf.c27
2 files changed, 35 insertions, 3 deletions
diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index fef32de43..c70040d31 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 98f4cfc64..0a9f98542 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 );
}
}