From d51452e3ece19f797f0d81d5a5e85be88bfe38c3 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 13 Feb 2021 08:52:58 +0100 Subject: [PATCH] Add new function `FT_Get_Transform`. See https://github.com/harfbuzz/harfbuzz/issues/2428 for some reasons to introduce this function. * include/freetype/freetype.h, src/base/ftobjs.c (FT_Get_Transform): Implement it. --- ChangeLog | 13 +++++++++++++ docs/CHANGES | 23 +++++++++++++---------- include/freetype/freetype.h | 33 ++++++++++++++++++++++++++++++++- src/base/ftobjs.c | 23 +++++++++++++++++++++++ 4 files changed, 81 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index b03321149..9131a737a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2021-02-13 Werner Lemberg + + Add new function `FT_Get_Transform`. + + See + + https://github.com/harfbuzz/harfbuzz/issues/2428 + + for some reasons to introduce this function. + + * include/freetype/freetype.h, src/base/ftobjs.c (FT_Get_Transform): + Implement it. + 2021-02-12 Alexei Podtelezhnikov Decorate `qsort` callbacks with `cdecl`. diff --git a/docs/CHANGES b/docs/CHANGES index 4ffdc0b88..3cbc66939 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -50,16 +50,6 @@ CHANGES BETWEEN 2.10.4 and 2.11.0 II. MISCELLANEOUS - - `ttdebug` didn't show changed point coordinates (bug introduced in - version 2.10.3). - - - A new configuration macro `FT_DEBUG_LOGGING` is available. It - provides extended debugging capabilities for FreeType, for example - showing a time stamp or displaying the component a tracing message - comes from. See file `docs/DEBUG` for more information. - - This work was Priyesh Kumar's GSoC 2020 project. - - FreeType has moved its infrastructure to https://gitlab.freedesktop.org/freetype @@ -72,6 +62,19 @@ CHANGES BETWEEN 2.10.4 and 2.11.0 FreeType's Savannah repositories will stay; they are now mirrors of the 'freedesktop.org' repositories. + - A new function `FT_Get_Transform` returns the values set by + `FT_Set_Transform`. + + - A new configuration macro `FT_DEBUG_LOGGING` is available. It + provides extended debugging capabilities for FreeType, for example + showing a time stamp or displaying the component a tracing message + comes from. See file `docs/DEBUG` for more information. + + This work was Priyesh Kumar's GSoC 2020 project. + + - `ttdebug` didn't show changed point coordinates (bug introduced in + version 2.10.3). + ====================================================================== diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index c157796dc..6c6b298b6 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -204,6 +204,7 @@ FT_BEGIN_HEADER * FT_Size_RequestRec * FT_Size_Request * FT_Set_Transform + * FT_Get_Transform * FT_Load_Glyph * FT_Get_Char_Index * FT_Get_First_Char @@ -3200,7 +3201,8 @@ FT_BEGIN_HEADER * A pointer to the transformation's 2x2 matrix. Use `NULL` for the * identity matrix. * delta :: - * A pointer to the translation vector. Use `NULL` for the null vector. + * A pointer to the translation vector. Use `NULL` for the null + * vector. * * @note: * This function is provided as a convenience, but keep in mind that @@ -3223,6 +3225,35 @@ FT_BEGIN_HEADER FT_Vector* delta ); + /************************************************************************** + * + * @function: + * FT_Get_Transform + * + * @description: + * Return the transformation that is applied to glyph images when they + * are loaded into a glyph slot through @FT_Load_Glyph. See + * @FT_Set_Transform for more details. + * + * @input: + * face :: + * A handle to the source face object. + * + * @output: + * matrix :: + * A pointer to a transformation's 2x2 matrix. Set this to NULL if you + * are not interested in the value. + * + * delta :: + * A pointer a translation vector. Set this to NULL if you are not + * interested in the value. + */ + FT_EXPORT( void ) + FT_Get_Transform( FT_Face face, + FT_Matrix* matrix, + FT_Vector* delta ); + + /************************************************************************** * * @enum: diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 829f4ab84..56e1360e0 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -738,6 +738,29 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( void ) + FT_Get_Transform( FT_Face face, + FT_Matrix* matrix, + FT_Vector* delta ) + { + FT_Face_Internal internal; + + + if ( !face ) + return; + + internal = face->internal; + + if ( matrix ) + *matrix = internal->transform_matrix; + + if ( delta ) + *delta = internal->transform_delta; + } + + static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );