Commit b2a85ad32b1f62fd186c018d681baa5adef925c6

Nikolaus Waxweiler 2015-11-02T09:20:32

[autofit] Extend `AF_FaceGlobalsRec' to hold emboldening data. * src/autofit/afglobal.h (AF_FaceGlobalsRec): Add fields. * src/autofit/afglobal.c (af_face_globals_new): Initialize new fields. (af_face_globals_free): Reset new fields.

diff --git a/ChangeLog b/ChangeLog
index 5286c87..697167b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2015-11-02  Nikolaus Waxweiler  <madigens@gmail.com>
 
+	[autofit] Extend `AF_FaceGlobalsRec' to hold emboldening data.
+
+	* src/autofit/afglobal.h (AF_FaceGlobalsRec): Add fields.
+
+	* src/autofit/afglobal.c (af_face_globals_new): Initialize new
+	fields.
+	(af_face_globals_free): Reset new fields.
+
+2015-11-02  Nikolaus Waxweiler  <madigens@gmail.com>
+
 	[autofit] Add stem-darkening properties.
 
 	Actual code follows in a later commit.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index b071cc7..f5a3957 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -350,11 +350,17 @@
                      (FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
       goto Exit;
 
-    globals->face         = face;
-    globals->glyph_count  = face->num_glyphs;
+    globals->face                      = face;
+    globals->glyph_count               = face->num_glyphs;
     /* right after the globals structure come the glyph styles */
-    globals->glyph_styles = (FT_UShort*)( globals + 1 );
-    globals->module       = module;
+    globals->glyph_styles              = (FT_UShort*)( globals + 1 );
+    globals->module                    = module;
+    globals->stem_darkening_for_ppem   = 0;
+    globals->darken_x                  = 0;
+    globals->darken_y                  = 0;
+    globals->standard_vertical_width   = 0;
+    globals->standard_horizontal_width = 0;
+    globals->scale_down_factor         = 0;
 
 #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
     globals->hb_font = hb_ft_font_create( face, NULL );
@@ -406,9 +412,16 @@
       globals->hb_font = NULL;
 #endif
 
-      globals->glyph_count  = 0;
-      globals->glyph_styles = NULL;  /* no need to free this one! */
-      globals->face         = NULL;
+      globals->glyph_count               = 0;
+      globals->stem_darkening_for_ppem   = 0;
+      globals->darken_x                  = 0;
+      globals->darken_y                  = 0;
+      globals->standard_vertical_width   = 0;
+      globals->standard_horizontal_width = 0;
+      globals->scale_down_factor         = 0;
+      /* no need to free this one! */
+      globals->glyph_styles              = NULL;
+      globals->face                      = NULL;
 
       FT_FREE( globals );
     }
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index ffb2f86..a3112de 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -117,6 +117,22 @@ FT_BEGIN_HEADER
 
     AF_StyleMetrics  metrics[AF_STYLE_MAX];
 
+    /* Compute darkening amount once per size.  Use this to check whether */
+    /* darken_{x,y} needs to be recomputed.                               */
+    FT_UShort        stem_darkening_for_ppem;
+    /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_HORZ] */
+    /* to compute the darkening amount.                       */
+    FT_Pos           standard_vertical_width;
+    /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_VERT] */
+    /* to compute the darkening amount.                       */
+    FT_Pos           standard_horizontal_width;
+    /* The actual amount to darken a glyph along the X axis. */
+    FT_Pos           darken_x;
+    /* The actual amount to darken a glyph along the Y axis. */
+    FT_Pos           darken_y;
+    /* Amount to scale down by to keep emboldened points */
+    /* on the Y-axis in pre-computed blue zones.         */
+    FT_Fixed         scale_down_factor;
     AF_Module        module;         /* to access global properties */
 
   } AF_FaceGlobalsRec;