Commit d51452e3ece19f797f0d81d5a5e85be88bfe38c3

Werner Lemberg 2021-02-13T08:52:58

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.

diff --git a/ChangeLog b/ChangeLog
index b033211..9131a73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2021-02-13  Werner Lemberg  <wl@gnu.org>
+
+	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  <apodtele@gmail.com>
 
 	Decorate `qsort` callbacks with `cdecl`.
diff --git a/docs/CHANGES b/docs/CHANGES
index 4ffdc0b..3cbc669 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 c157796..6c6b298 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
@@ -3225,6 +3227,35 @@ FT_BEGIN_HEADER
 
   /**************************************************************************
    *
+   * @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:
    *   FT_Render_Mode
    *
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 829f4ab..56e1360 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 );