freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [sfnt] Clarify `COLR` v1 FT_Paint* form


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [sfnt] Clarify `COLR` v1 FT_Paint* format representations
Date: Wed, 03 Nov 2021 08:38:02 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

2 changed files:

Changes:

  • include/freetype/ftcolor.h
    ... ... @@ -870,13 +870,16 @@ FT_BEGIN_HEADER
    870 870
        *     color stops along the gradient.
    
    871 871
        *
    
    872 872
        *   p0 ::
    
    873
    -   *     The starting point of the gradient definition (in font units).
    
    873
    +   *     The starting point of the gradient definition in font units
    
    874
    +   *     represented as a 16.16 fixed-point `FT_Vector`.
    
    874 875
        *
    
    875 876
        *   p1 ::
    
    876
    -   *     The end point of the gradient definition (in font units).
    
    877
    +   *     The end point of the gradient definition in font units
    
    878
    +   *     represented as a 16.16 fixed-point `FT_Vector`.
    
    877 879
        *
    
    878 880
        *   p2 ::
    
    879
    -   *     Optional point~p2 to rotate the gradient (in font units).
    
    881
    +   *     Optional point~p2 to rotate the gradient in font units
    
    882
    +   *     represented as a 16.16 fixed-point `FT_Vector`.
    
    880 883
        *     Otherwise equal to~p0.
    
    881 884
        *
    
    882 885
        * @since:
    
    ... ... @@ -914,19 +917,20 @@ FT_BEGIN_HEADER
    914 917
        *     color stops along the gradient.
    
    915 918
        *
    
    916 919
        *   c0 ::
    
    917
    -   *     The center of the starting point of the radial gradient (in font
    
    918
    -   *     units).
    
    920
    +   *     The center of the starting point of the radial gradient in font
    
    921
    +   *     units represented as a 16.16 fixed-point `FT_Vector`.
    
    919 922
        *
    
    920 923
        *   r0 ::
    
    921
    -   *     The radius of the starting circle of the radial gradient (in font
    
    922
    -   *     units).
    
    924
    +   *     The radius of the starting circle of the radial gradient in font
    
    925
    +   *     units represented as a 16.16 fixed-point value.
    
    923 926
        *
    
    924 927
        *   c1 ::
    
    925
    -   *     The center of the end point of the radial gradient (in font units).
    
    928
    +   *     The center of the end point of the radial gradient in font units
    
    929
    +   *     represented as a 16.16 fixed-point `FT_Vector`.
    
    926 930
        *
    
    927 931
        *   r1 ::
    
    928
    -   *     The radius of the end circle of the radial gradient (in font
    
    929
    -   *     units).
    
    932
    +   *     The radius of the end circle of the radial gradient in font
    
    933
    +   *     units represented as a 16.16 fixed-point value.
    
    930 934
        *
    
    931 935
        * @since:
    
    932 936
        *   2.11 -- **currently experimental only!**  There might be changes
    
    ... ... @@ -938,9 +942,9 @@ FT_BEGIN_HEADER
    938 942
         FT_ColorLine  colorline;
    
    939 943
     
    
    940 944
         FT_Vector  c0;
    
    941
    -    FT_UShort  r0;
    
    945
    +    FT_Pos     r0;
    
    942 946
         FT_Vector  c1;
    
    943
    -    FT_UShort  r1;
    
    947
    +    FT_Pos     r1;
    
    944 948
     
    
    945 949
       } FT_PaintRadialGradient;
    
    946 950
     
    
    ... ... @@ -963,16 +967,17 @@ FT_BEGIN_HEADER
    963 967
        *     color stops along the gradient.
    
    964 968
        *
    
    965 969
        *   center ::
    
    966
    -   *     The center of the sweep gradient (in font units).
    
    970
    +   *     The center of the sweep gradient in font units represented as a
    
    971
    +   *     vector of 16.16 fixed-point values.
    
    967 972
        *
    
    968 973
        *   start_angle ::
    
    969
    -   *     The start angle of the sweep gradient, in 16.16 fixed point
    
    974
    +   *     The start angle of the sweep gradient in 16.16 fixed-point
    
    970 975
        *     format specifying degrees divided by 180.0 (as in the
    
    971 976
        *     spec).  Multiply by 180.0f to receive degrees value.  Values are
    
    972 977
        *     given counter-clockwise, starting from the (positive) y~axis.
    
    973 978
        *
    
    974 979
        *   end_angle ::
    
    975
    -   *     The end angle of the sweep gradient, in 16.16 fixed point
    
    980
    +   *     The end angle of the sweep gradient in 16.16 fixed-point
    
    976 981
        *     format specifying degrees divided by 180.0 (as in the
    
    977 982
        *     spec).  Multiply by 180.0f to receive degrees value.  Values are
    
    978 983
        *     given counter-clockwise, starting from the (positive) y~axis.
    
    ... ... @@ -1061,7 +1066,8 @@ FT_BEGIN_HEADER
    1061 1066
        *     An opaque paint that is subject to being transformed.
    
    1062 1067
        *
    
    1063 1068
        *   affine ::
    
    1064
    -   *     A 2x3 transformation matrix in @FT_Affine23 format.
    
    1069
    +   *     A 2x3 transformation matrix in @FT_Affine23 format containing
    
    1070
    +   *     16.16 fixed-point values.
    
    1065 1071
        *
    
    1066 1072
        * @since:
    
    1067 1073
        *   2.11 -- **currently experimental only!**  There might be changes
    
    ... ... @@ -1091,10 +1097,12 @@ FT_BEGIN_HEADER
    1091 1097
        *     rotated.
    
    1092 1098
        *
    
    1093 1099
        *   dx ::
    
    1094
    -   *     Translation in x~direction (in font units).
    
    1100
    +   *     Translation in x~direction in font units represented as a
    
    1101
    +   *     16.16 fixed-point value.
    
    1095 1102
        *
    
    1096 1103
        *   dy ::
    
    1097
    -   *     Translation in y~direction (in font units).
    
    1104
    +   *     Translation in y~direction in font units represented as a
    
    1105
    +   *     16.16 fixed-point value.
    
    1098 1106
        *
    
    1099 1107
        * @since:
    
    1100 1108
        *   2.11 -- **currently experimental only!**  There might be changes
    
    ... ... @@ -1132,16 +1140,20 @@ FT_BEGIN_HEADER
    1132 1140
        *     scaled.
    
    1133 1141
        *
    
    1134 1142
        *   scale_x ::
    
    1135
    -   *     Scale factor in x~direction.
    
    1143
    +   *     Scale factor in x~direction represented as a
    
    1144
    +   *     16.16 fixed-point value.
    
    1136 1145
        *
    
    1137 1146
        *   scale_y ::
    
    1138
    -   *     Scale factor in y~direction.
    
    1147
    +   *     Scale factor in y~direction represented as a
    
    1148
    +   *     16.16 fixed-point value.
    
    1139 1149
        *
    
    1140 1150
        *   center_x ::
    
    1141
    -   *     x~coordinate of center point to scale from.
    
    1151
    +   *     x~coordinate of center point to scale from represented as a
    
    1152
    +   *     16.16 fixed-point value.
    
    1142 1153
        *
    
    1143 1154
        *   center_y ::
    
    1144
    -   *     y~coordinate of center point to scale from.
    
    1155
    +   *     y~coordinate of center point to scale from represented as a
    
    1156
    +   *     16.16 fixed-point value.
    
    1145 1157
        *
    
    1146 1158
        * @since:
    
    1147 1159
        *   2.11 -- **currently experimental only!**  There might be changes
    
    ... ... @@ -1177,16 +1189,16 @@ FT_BEGIN_HEADER
    1177 1189
        *
    
    1178 1190
        *   angle ::
    
    1179 1191
        *     The rotation angle that is to be applied in degrees divided by
    
    1180
    -   *     180.0 (as in the spec).  Multiply by 180.0f to receive degrees
    
    1181
    -   *     value.
    
    1192
    +   *     180.0 (as in the spec) represented as a 16.16 fixed-point
    
    1193
    +   *     value.  Multiply by 180.0f to receive degrees value.
    
    1182 1194
        *
    
    1183 1195
        *   center_x ::
    
    1184
    -   *     The x~coordinate of the pivot point of the rotation (in font
    
    1185
    -   *     units).
    
    1196
    +   *     The x~coordinate of the pivot point of the rotation in font
    
    1197
    +   *     units) represented as a 16.16 fixed-point value.
    
    1186 1198
        *
    
    1187 1199
        *   center_y ::
    
    1188
    -   *     The y~coordinate of the pivot point of the rotation (in font
    
    1189
    -   *     units).
    
    1200
    +   *     The y~coordinate of the pivot point of the rotation in font
    
    1201
    +   *     units represented as a 16.16 fixed-point value.
    
    1190 1202
        *
    
    1191 1203
        * @since:
    
    1192 1204
        *   2.11 -- **currently experimental only!**  There might be changes
    
    ... ... @@ -1223,17 +1235,21 @@ FT_BEGIN_HEADER
    1223 1235
        *
    
    1224 1236
        *   x_skew_angle ::
    
    1225 1237
        *     The skewing angle in x~direction in degrees divided by 180.0
    
    1226
    -   *     (as in the spec).  Multiply by 180.0f to receive degrees.
    
    1238
    +   *     (as in the spec) represented as a 16.16 fixed-point
    
    1239
    +   *     value. Multiply by 180.0f to receive degrees.
    
    1227 1240
        *
    
    1228 1241
        *   y_skew_angle ::
    
    1229 1242
        *     The skewing angle in y~direction in degrees divided by 180.0
    
    1230
    -   *     (as in the spec).  Multiply by 180.0f to receive degrees.
    
    1243
    +   *     (as in the spec) represented as a 16.16 fixed-point
    
    1244
    +   *     value.  Multiply by 180.0f to receive degrees.
    
    1231 1245
        *
    
    1232 1246
        *   center_x ::
    
    1233
    -   *     The x~coordinate of the pivot point of the skew (in font units).
    
    1247
    +   *     The x~coordinate of the pivot point of the skew in font units
    
    1248
    +   *     represented as a 16.16 fixed-point value.
    
    1234 1249
        *
    
    1235 1250
        *   center_y ::
    
    1236
    -   *     The y~coordinate of the pivot point of the skew (in font units).
    
    1251
    +   *     The y~coordinate of the pivot point of the skew in font units
    
    1252
    +   *     represented as a 16.16 fixed-point value.
    
    1237 1253
        *
    
    1238 1254
        * @since:
    
    1239 1255
        *   2.11 -- **currently experimental only!**  There might be changes
    

  • src/sfnt/ttcolr.c
    ... ... @@ -505,12 +505,16 @@
    505 505
                                  &apaint->u.linear_gradient.colorline ) )
    
    506 506
             return 0;
    
    507 507
     
    
    508
    -      apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT( p );
    
    509
    -      apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT( p );
    
    510
    -      apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT( p );
    
    511
    -      apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT( p );
    
    512
    -      apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT( p );
    
    513
    -      apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT( p );
    
    508
    +      /*
    
    509
    +       * In order to support variations expose these as FT_Fixed 16.16 values so
    
    510
    +       * that we can support fractional values after interpolation.
    
    511
    +       */
    
    512
    +      apaint->u.linear_gradient.p0.x = FT_NEXT_SHORT( p ) << 16;
    
    513
    +      apaint->u.linear_gradient.p0.y = FT_NEXT_SHORT( p ) << 16;
    
    514
    +      apaint->u.linear_gradient.p1.x = FT_NEXT_SHORT( p ) << 16;
    
    515
    +      apaint->u.linear_gradient.p1.y = FT_NEXT_SHORT( p ) << 16;
    
    516
    +      apaint->u.linear_gradient.p2.x = FT_NEXT_SHORT( p ) << 16;
    
    517
    +      apaint->u.linear_gradient.p2.y = FT_NEXT_SHORT( p ) << 16;
    
    514 518
     
    
    515 519
           return 1;
    
    516 520
         }
    
    ... ... @@ -521,15 +525,15 @@
    521 525
                                  &apaint->u.radial_gradient.colorline ) )
    
    522 526
             return 0;
    
    523 527
     
    
    524
    -      apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT( p );
    
    525
    -      apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT( p );
    
    528
    +      apaint->u.radial_gradient.c0.x = FT_NEXT_SHORT( p ) << 16;
    
    529
    +      apaint->u.radial_gradient.c0.y = FT_NEXT_SHORT( p ) << 16;
    
    526 530
     
    
    527
    -      apaint->u.radial_gradient.r0 = FT_NEXT_USHORT( p );
    
    531
    +      apaint->u.radial_gradient.r0 = FT_NEXT_USHORT( p ) << 16;
    
    528 532
     
    
    529
    -      apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT( p );
    
    530
    -      apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT( p );
    
    533
    +      apaint->u.radial_gradient.c1.x = FT_NEXT_SHORT( p ) << 16;
    
    534
    +      apaint->u.radial_gradient.c1.y = FT_NEXT_SHORT( p ) << 16;
    
    531 535
     
    
    532
    -      apaint->u.radial_gradient.r1 = FT_NEXT_USHORT( p );
    
    536
    +      apaint->u.radial_gradient.r1 = FT_NEXT_USHORT( p ) << 16;
    
    533 537
     
    
    534 538
           return 1;
    
    535 539
         }
    
    ... ... @@ -540,8 +544,8 @@
    540 544
                                  &apaint->u.sweep_gradient.colorline ) )
    
    541 545
             return 0;
    
    542 546
     
    
    543
    -      apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT( p );
    
    544
    -      apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT( p );
    
    547
    +      apaint->u.sweep_gradient.center.x = FT_NEXT_SHORT( p ) << 16;
    
    548
    +      apaint->u.sweep_gradient.center.y = FT_NEXT_SHORT( p ) << 16;
    
    545 549
     
    
    546 550
           apaint->u.sweep_gradient.start_angle = FT_NEXT_SHORT( p ) << 2;
    
    547 551
           apaint->u.sweep_gradient.end_angle   = FT_NEXT_SHORT( p ) << 2;
    
    ... ... @@ -568,6 +572,10 @@
    568 572
     
    
    569 573
           p = child_table_p;
    
    570 574
     
    
    575
    +      /*
    
    576
    +       * The following matrix coefficients are encoded as
    
    577
    +       * OpenType 16.16 fixed-point values.
    
    578
    +       */
    
    571 579
           apaint->u.transform.affine.xx = FT_NEXT_LONG( p );
    
    572 580
           apaint->u.transform.affine.yx = FT_NEXT_LONG( p );
    
    573 581
           apaint->u.transform.affine.xy = FT_NEXT_LONG( p );
    


  • reply via email to

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