diff options
author | Werner Lemberg <wl@gnu.org> | 2017-10-07 11:40:03 +0200 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2017-10-07 11:40:03 +0200 |
commit | dd8539ef823d21337cd31894b1072808c297574f (patch) | |
tree | 314e27306669aa046afdd14edfdbc48148d557ca | |
parent | b3f9c4f2f69a49a70e1dd76ce767ab603de312ac (diff) | |
download | freetype2-dd8539ef823d21337cd31894b1072808c297574f.tar.gz |
New function `FT_Set_Named_Instance'.
No effect yet.
* src/base/ftmm.c (FT_Set_Named_Instance): New function.
* include/freetype/ftmm.h: Updated.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | include/freetype/ftmm.h | 37 | ||||
-rw-r--r-- | src/base/ftmm.c | 48 |
3 files changed, 95 insertions, 0 deletions
@@ -1,5 +1,15 @@ 2017-10-07 Werner Lemberg <wl@gnu.org> + New function `FT_Set_Named_Instance'. + + No effect yet. + + * src/base/ftmm.c (FT_Set_Named_Instance): New function. + + * include/freetype/ftmm.h: Updated. + +2017-10-07 Werner Lemberg <wl@gnu.org> + Add macros for checking whether a font variation is active. * include/freetype/freetype.h (FT_FACE_FLAG_VARIATION, diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h index c08119933..fe66f2d6c 100644 --- a/include/freetype/ftmm.h +++ b/include/freetype/ftmm.h @@ -551,6 +551,43 @@ FT_BEGIN_HEADER FT_UInt axis_index, FT_UInt* flags ); + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Named_Instance */ + /* */ + /* <Description> */ + /* Set or change the current named instance. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* instance_index :: The index of the requested instance, starting */ + /* with value 1. If set to value 0, FreeType */ + /* switches to font access without a named */ + /* instance. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The function uses the value of `instance_index' to set bits 16-30 */ + /* of the face's `face_index' field. It also resets any variation */ + /* applied to the font, and the @FT_FACE_FLAG_VARIATION bit of the */ + /* face's `face_flags' field gets reset to zero (i.e., */ + /* @FT_IS_VARIATION will return false). */ + /* */ + /* For Adobe MM fonts (which don't have named instances) this */ + /* function simply resets the current face to the default instance. */ + /* */ + /* <Since> */ + /* 2.8.2 */ + /* */ + FT_EXPORT( FT_Error ) + FT_Set_Named_Instance( FT_Face face, + FT_UInt instance_index ); + /* */ diff --git a/src/base/ftmm.c b/src/base/ftmm.c index 43877ece4..e0131ece3 100644 --- a/src/base/ftmm.c +++ b/src/base/ftmm.c @@ -426,4 +426,52 @@ } + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Set_Named_Instance( FT_Face face, + FT_UInt instance_index ) + { + FT_Error error; + + FT_Service_MultiMasters service_mm = NULL; + FT_Service_MetricsVariations service_mvar = NULL; + + + /* check of `face' delayed to `ft_face_get_mm_service' */ + + error = ft_face_get_mm_service( face, &service_mm ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service_mm->set_instance ) + error = service_mm->set_instance( face, instance_index ); + } + + if ( !error ) + { + (void)ft_face_get_mvar_service( face, &service_mvar ); + + if ( service_mvar && service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + if ( !error ) + { + face->face_index = ( instance_index << 16 ) | + ( face->face_index & 0xFFFFL ); + face->face_flags &= ~FT_FACE_FLAG_VARIATION; + } + + return error; + } + + /* END */ |