freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 6618980 1/2: [sfnt] 'COLR' v1 PaintSkew related spec


From: Werner Lemberg
Subject: [freetype2] master 6618980 1/2: [sfnt] 'COLR' v1 PaintSkew related spec updates
Date: Thu, 29 Jul 2021 02:06:31 -0400 (EDT)

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

    [sfnt] 'COLR' v1 PaintSkew related spec updates
    
    * src/sfnt/ttcolr.c (read_paint): Implement spec changes around
    PaintSkew, PaintSkewAroundCenter.  Update parsing to read shorter
    values as changed in the spec.
    * include/freetype/ftcolor.h (FT_PaintSkew): Update documentation.
---
 include/freetype/ftcolor.h |  6 ++++--
 src/sfnt/ttcolr.c          | 23 ++++++++++++++++++-----
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/include/freetype/ftcolor.h b/include/freetype/ftcolor.h
index 8f2507c..43e463e 100644
--- a/include/freetype/ftcolor.h
+++ b/include/freetype/ftcolor.h
@@ -1219,10 +1219,12 @@ FT_BEGIN_HEADER
    *     skewed.
    *
    *   x_skew_angle ::
-   *     The skewing angle in x~direction.
+   *     The skewing angle in x~direction in degrees divided by 180.0
+   *     (as in the spec).  Multiply by 180.0f to receive degrees.
    *
    *   y_skew_angle ::
-   *     The skewing angle in y~direction.
+   *     The skewing angle in y~direction in degrees divided by 180.0
+   *     (as in the spec).  Multiply by 180.0f to receive degrees.
    *
    *   center_x ::
    *     The x~coordinate of the pivot point of the skew (in font units).
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index ca8a7a2..e46ca48 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -649,16 +649,29 @@
       return 1;
     }
 
-    else if ( apaint->format == FT_COLR_PAINTFORMAT_SKEW )
+    else if ( apaint->format == FT_COLR_PAINTFORMAT_SKEW  ||
+              (FT_PaintFormat_Internal)apaint->format ==
+                FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER  )
     {
       apaint->u.skew.paint.p                     = child_table_p;
       apaint->u.skew.paint.insert_root_transform = 0;
 
-      apaint->u.skew.x_skew_angle = FT_NEXT_LONG( p );
-      apaint->u.skew.y_skew_angle = FT_NEXT_LONG( p );
+      apaint->u.skew.x_skew_angle = FT_NEXT_SHORT( p ) << 2;
+      apaint->u.skew.y_skew_angle = FT_NEXT_SHORT( p ) << 2;
+
+      if ( (FT_PaintFormat_Internal)apaint->format ==
+           FT_COLR_PAINTFORMAT_INTERNAL_SKEW_CENTER )
+      {
+        apaint->u.skew.center_x = FT_NEXT_SHORT( p ) << 16;
+        apaint->u.skew.center_y = FT_NEXT_SHORT( p ) << 16;
+      }
+      else
+      {
+        apaint->u.skew.center_x = 0;
+        apaint->u.skew.center_y = 0;
+      }
 
-      apaint->u.skew.center_x = FT_NEXT_LONG( p );
-      apaint->u.skew.center_y = FT_NEXT_LONG( p );
+      apaint->format = FT_COLR_PAINTFORMAT_SKEW;
 
       return 1;
     }



reply via email to

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