[autofit] Implement `increase-x-height' property. * include/freetype/ftautoh.h (FT_Prop_IncreaseXHeight): New structure. * include/autofit/afmodule.c (af_property_get_face_globals): New function, re-using code from `af_property_get'. (af_property_set, af_property_get): Handle `increase-x-height'. Updated.
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
diff --git a/ChangeLog b/ChangeLog
index bc2ecf4..51fac49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2012-09-18 Werner Lemberg <wl@gnu.org>
+ [autofit] Implement `increase-x-height' property.
+
+ * include/freetype/ftautoh.h (FT_Prop_IncreaseXHeight): New
+ structure.
+
+ * include/autofit/afmodule.c (af_property_get_face_globals): New
+ function, re-using code from `af_property_get'.
+ (af_property_set, af_property_get): Handle `increase-x-height'.
+ Updated.
+
+2012-09-18 Werner Lemberg <wl@gnu.org>
+
[autofit] Implement Infinality's `increase glyph heights'.
This is an improved version of a similar fix contained in the
diff --git a/include/freetype/ftautoh.h b/include/freetype/ftautoh.h
index 88a65bc..b427c4d 100644
--- a/include/freetype/ftautoh.h
+++ b/include/freetype/ftautoh.h
@@ -275,15 +275,70 @@ FT_BEGIN_HEADER
*
* It's important to use the right timing for changing this value: The
* creation of the glyph-to-script map which eventually uses the
- * fallback script value gets triggered either by accessing the
- * @glyph-to-script-map property of a face, or by auto-hinting any glyph
- * from that face. In particular, if you have already created an
- * @FT_Face structure but not loaded any glyph (using the auto-hinter),
- * a change of the fallback glyph will affect this face.
+ * fallback script value gets triggered either by setting or reading a
+ * face-specific property like @glyph-to-script-map, or by auto-hinting
+ * any glyph from that face. In particular, if you have already created
+ * an @FT_Face structure but not loaded any glyph (using the
+ * auto-hinter), a change of the fallback glyph will affect this face.
*
*/
+ /**************************************************************************
+ *
+ * @property:
+ * increase-x-height
+ *
+ * @description:
+ * For ppem values in the range 6~<= ppem <= `increase-x-height', round
+ * up the font's x~height much more often than normally. If the value
+ * is set to~0, which is the default, this feature is switched off. Use
+ * this property to improve the legibility of small font sizes if
+ * necessary.
+ *
+ * {
+ * FT_Library library;
+ * FT_Face face;
+ * FT_Prop_IncreaseXHeight prop;
+ *
+ *
+ * FT_Init_FreeType( &library );
+ * FT_New_Face( library, "foo.ttf", 0, &face );
+ * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
+ *
+ * prop.face = face;
+ * prop.limit = 14;
+ *
+ * FT_Property_Set( library, "autofitter",
+ * "increase-x-height", &prop );
+ * }
+ *
+ * @note:
+ * This property can be used with @FT_Property_Get also.
+ *
+ * Set this value right after calling @FT_Set_Char_Size, but before
+ * loading any glyph (using the auto-hinter).
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @struct:
+ * FT_Prop_IncreaseXHeight
+ *
+ * @description:
+ * The data exchange structure for the @increase-x-height property.
+ *
+ */
+ typedef struct FT_Prop_IncreaseXHeight_
+ {
+ FT_Face face;
+ FT_UInt limit;
+
+ } FT_Prop_IncreaseXHeight;
+
+
/* */
FT_END_HEADER
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 79f6257..ea56115 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -44,6 +44,40 @@
FT_Error
+ af_property_get_face_globals( FT_Face face,
+ AF_FaceGlobals* aglobals,
+ AF_Module module )
+ {
+ FT_Error error = AF_Err_Ok;
+ AF_FaceGlobals globals;
+
+
+ if ( !face )
+ return AF_Err_Invalid_Argument;
+
+ globals = (AF_FaceGlobals)face->autohint.data;
+ if ( !globals )
+ {
+ /* trigger computation of the global script data */
+ /* in case it hasn't been done yet */
+ error = af_face_globals_new( face, &globals, module );
+ if ( !error )
+ {
+ face->autohint.data =
+ (FT_Pointer)globals;
+ face->autohint.finalizer =
+ (FT_Generic_Finalizer)af_face_globals_free;
+ }
+ }
+
+ if ( !error )
+ *aglobals = globals;
+
+ return error;
+ }
+
+
+ FT_Error
af_property_set( FT_Module ft_module,
const char* property_name,
const void* value )
@@ -61,6 +95,18 @@
return error;
}
+ else if ( !ft_strcmp( property_name, "increase-x-height" ) )
+ {
+ FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
+ AF_FaceGlobals globals;
+
+
+ error = af_property_get_face_globals( prop->face, &globals, module );
+ if ( !error )
+ globals->increase_x_height = prop->limit;
+
+ return error;
+ }
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));
@@ -84,24 +130,7 @@
AF_FaceGlobals globals;
- if ( !prop->face )
- return AF_Err_Invalid_Argument;
-
- globals = (AF_FaceGlobals)prop->face->autohint.data;
- if ( !globals )
- {
- /* trigger computation of the global script data */
- /* in case it hasn't been done yet */
- error = af_face_globals_new( prop->face, &globals, module );
- if ( !error )
- {
- prop->face->autohint.data =
- (FT_Pointer)globals;
- prop->face->autohint.finalizer =
- (FT_Generic_Finalizer)af_face_globals_free;
- }
- }
-
+ error = af_property_get_face_globals( prop->face, &globals, module );
if ( !error )
prop->map = globals->glyph_scripts;
@@ -116,6 +145,19 @@
return error;
}
+ else if ( !ft_strcmp( property_name, "increase-x-height" ) )
+ {
+ FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
+ AF_FaceGlobals globals;
+
+
+ error = af_property_get_face_globals( prop->face, &globals, module );
+ if ( !error )
+ prop->limit = globals->increase_x_height;
+
+ return error;
+ }
+
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));