[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.
This commit is contained in:
parent
d180ac70fc
commit
3683fb55c9
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
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'.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -43,6 +43,40 @@
|
|||
#define FT_COMPONENT trace_afmodule
|
||||
|
||||
|
||||
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,
|
||||
|
@ -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 ));
|
||||
|
|
Loading…
Reference in New Issue