freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 48df0fa 2/2: [sfnt] PaintRotate/PaintRotateAroundCent


From: Werner Lemberg
Subject: [freetype2] master 48df0fa 2/2: [sfnt] PaintRotate/PaintRotateAroundCenter spec updates
Date: Thu, 29 Jul 2021 02:00:39 -0400 (EDT)

branch: master
commit 48df0fa6522f078498d3be92686522b1a512481f
Author: Dominik Röttsches <drott@chromium.org>
Commit: Werner Lemberg <wl@gnu.org>

    [sfnt] PaintRotate/PaintRotateAroundCenter spec updates
    
    * src/sfnt/ttcolr.c (read_paint): Implement spec change where
    PaintRotate and PaintRotateAroundCenter were split for a more
    compact format definition.  Update parsing to read shorter values
    as changed in the spec.
    * include/freetype/ftcolor.h (FT_PaintRotate): Update documentation.
---
 include/freetype/ftcolor.h |  4 +++-
 src/sfnt/ttcolr.c          | 25 +++++++++++++++++++++----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/include/freetype/ftcolor.h b/include/freetype/ftcolor.h
index 59e6f15..8f2507c 100644
--- a/include/freetype/ftcolor.h
+++ b/include/freetype/ftcolor.h
@@ -1173,7 +1173,9 @@ FT_BEGIN_HEADER
    *     rotated.
    *
    *   angle ::
-   *     The rotation angle that is to be applied.
+   *     The rotation angle that is to be applied in degrees divided by
+   *     180.0 (as in the spec).  Multiply by 180.0f to receive degrees
+   *     value.
    *
    *   center_x ::
    *     The x~coordinate of the pivot point of the rotation (in font
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index ad305ac..ca8a7a2 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -619,15 +619,32 @@
       return 1;
     }
 
-    else if ( apaint->format == FT_COLR_PAINTFORMAT_ROTATE )
+    else if ( apaint->format == FT_COLR_PAINTFORMAT_ROTATE  ||
+              (FT_PaintFormat_Internal)apaint->format ==
+                FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER  )
     {
       apaint->u.rotate.paint.p                     = child_table_p;
       apaint->u.rotate.paint.insert_root_transform = 0;
 
-      apaint->u.rotate.angle = FT_NEXT_LONG( p );
+      /* The angle is specified as F2DOT14 and our output type is an FT_Fixed,
+       * shift by 2 positions. */
+      apaint->u.rotate.angle = FT_NEXT_SHORT( p ) << 2;
+
+      if ( (FT_PaintFormat_Internal)apaint->format ==
+           FT_COLR_PAINTFORMAT_INTERNAL_ROTATE_CENTER )
+      {
+        /* The center is specified as Int16 in font units, shift by 16 bits to
+         * convert to our FT_Fixed output type. */
+        apaint->u.rotate.center_x = FT_NEXT_SHORT( p ) << 16;
+        apaint->u.rotate.center_y = FT_NEXT_SHORT( p ) << 16;
+      }
+      else
+      {
+        apaint->u.rotate.center_x = 0;
+        apaint->u.rotate.center_y = 0;
+      }
 
-      apaint->u.rotate.center_x = FT_NEXT_LONG( p );
-      apaint->u.rotate.center_y = FT_NEXT_LONG( p );
+      apaint->format = FT_COLR_PAINTFORMAT_ROTATE;
 
       return 1;
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]