[paint] Pass font to all callbacks

This will lead to easier implementations.

At the same time, we change the push_clip_glyph
callback to use the font as-is, no unscaling needed.

Update all callers and expected test results.
This commit is contained in:
Matthias Clasen authored and Behdad Esfahbod committed 2022-12-23 13:37:59 -07:00
1 parent 32ce29f99e
commit 97224f3b63
33 files changed
+639 -457

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 15
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 16
solid 0 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 21
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 18
solid 2 0.200012
end clip
end transform
pop group mode 3
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 0.000000 51.200001 0.000000 0.000000
start clip glyph 20
solid 9 1.000000
end clip
end transform
pop group mode 3
end transform
-79
View File
@@ -1,79 +0,0 @@
start transform 0.019531 0.000000 0.000000 0.019531 0.000000 0.000000
push group
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
pop group mode 3
push group
start clip glyph 15
solid 9 1.000000
end clip
pop group mode 3
push group
start clip glyph 16
solid 0 1.000000
end clip
pop group mode 3
push group
start clip glyph 21
solid 9 1.000000
end clip
pop group mode 3
push group
push group
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
pop group mode 3
push group
start clip glyph 18
solid 2 0.200012
end clip
pop group mode 3
pop group mode 3
push group
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 20
solid 9 1.000000
end clip
pop group mode 3
end transform
+97
View File
@@ -0,0 +1,97 @@
start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 15
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 16
solid 0 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 21
solid 9 1.000000
end clip
end transform
pop group mode 3
push group
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 18
solid 2 0.200012
end clip
end transform
pop group mode 3
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
end transform
pop group mode 3
push group
start transform 51.200001 0.000000 10.240000 51.200001 0.000000 0.000000
start clip glyph 20
solid 9 1.000000
end clip
end transform
pop group mode 3
end transform
-79
View File
@@ -1,79 +0,0 @@
start transform 0.019531 0.000000 0.003906 0.019531 0.000000 0.000000
push group
start clip glyph 13
start transform 1.000000 0.000000 0.000000 0.976807 0.000000 0.000000
radial gradient
p0 280.000000 440.000000 radius 0.000000
p1 280.000000 440.000000 radius 467.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 14
linear gradient
p0 231.000000 -27.000000
p1 1019.000000 -27.000000
p2 231.000000 -815.000000
colors
0.000000 12 1.000000
1.000000 12 1.000000
end clip
pop group mode 3
push group
start clip glyph 15
solid 9 1.000000
end clip
pop group mode 3
push group
start clip glyph 16
solid 0 1.000000
end clip
pop group mode 3
push group
start clip glyph 21
solid 9 1.000000
end clip
pop group mode 3
push group
push group
start clip glyph 16
linear gradient
p0 669.000000 776.000000
p1 180.000000 -106.000000
p2 -212.000000 1265.000000
colors
0.000000 5 1.000000
1.000000 1 1.000000
end clip
pop group mode 3
push group
start clip glyph 18
solid 2 0.200012
end clip
pop group mode 3
pop group mode 3
push group
start clip glyph 19
start transform 1.000000 0.000000 0.000000 0.969116 0.000000 0.000000
radial gradient
p0 588.000000 198.000000 radius 0.000000
p1 588.000000 198.000000 radius 342.000000
colors
0.000000 16 1.000000
0.448792 15 1.000000
0.808594 14 1.000000
1.000000 12 1.000000
end transform
end clip
pop group mode 3
push group
start clip glyph 20
solid 9 1.000000
end clip
pop group mode 3
end transform
+14
View File
@@ -0,0 +1,14 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 174
sweep gradient
center 500.000000 600.000000
angles 0.000000 6.283185
colors
0.250000 7 1.000000
0.416687 4 1.000000
0.583313 0 1.000000
0.750000 8 1.000000
end clip
end transform
end transform
-12
View File
@@ -1,12 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 174
sweep gradient
center 500.000000 600.000000
angles 0.000000 6.283185
colors
0.250000 7 1.000000
0.416687 4 1.000000
0.583313 0 1.000000
0.750000 8 1.000000
end clip
end transform
@@ -1,15 +1,19 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start clip glyph 3
solid 4 0.500000
end clip
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 4 0.500000
end clip
end transform
push group
start transform 0.000000 0.000000 0.000000 0.000000 1000.000000 1000.000000
start transform 1.000000 -0.363874 -0.176283 1.000000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 -1000.000000 -1000.000000
start clip glyph 3
solid 1 0.700012
end clip
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 1 0.700012
end clip
end transform
end transform
end transform
end transform
+18
View File
@@ -0,0 +1,18 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 4 0.500000
end clip
end transform
push group
start transform 1.000000 0.000000 0.000000 1.000000 200.000000 200.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 1 0.700012
end clip
end transform
end transform
pop group mode 4
pop group mode 3
end transform
-14
View File
@@ -1,14 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start clip glyph 3
solid 4 0.500000
end clip
push group
start transform 1.000000 0.000000 0.000000 1.000000 200.000000 200.000000
start clip glyph 3
solid 1 0.700012
end clip
end transform
pop group mode 4
pop group mode 3
end transform
@@ -1,17 +1,21 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start clip glyph 3
solid 10 1.000000
end clip
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 3
solid 10 1.000000
end clip
end transform
pop group mode 3
push group
push group
start transform 0.000000 0.000000 0.000000 0.000000 333.000000 667.000000
start transform 8192.000000 0.000000 0.000000 8192.000000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 -333.000000 -667.000000
start clip glyph 2
solid 12 1.000000
end clip
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 2
solid 12 1.000000
end clip
end transform
end transform
end transform
end transform
@@ -19,9 +23,11 @@ start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 667.000000 333.000000
start transform 8192.000000 0.000000 0.000000 8192.000000 0.000000 0.000000
start transform 0.000000 0.000000 0.000000 0.000000 -667.000000 -333.000000
start clip glyph 2
solid 11 1.000000
end clip
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 2
solid 11 1.000000
end clip
end transform
end transform
end transform
end transform
+14
View File
@@ -0,0 +1,14 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 165
linear gradient
p0 100.000000 950.000000
p1 2300.000000 950.000000
p2 -1000.000000 250.000000
colors
0.000000 0 1.000000
0.500000 4 1.000000
1.000000 2 1.000000
end clip
end transform
end transform
-12
View File
@@ -1,12 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 165
linear gradient
p0 100.000000 950.000000
p1 2300.000000 950.000000
p2 -1000.000000 250.000000
colors
0.000000 0 1.000000
0.500000 4 1.000000
1.000000 2 1.000000
end clip
end transform
+26
View File
@@ -0,0 +1,26 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 1.000000 0.000000 0.000000 1.000000 150.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 174
solid 3 1.000000
end clip
end transform
end transform
pop group mode 3
push group
start transform 1.000000 0.000000 0.000000 1.000000 -150.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 174
linear gradient
p0 500.000000 250.000000
p1 500.000000 950.000000
p2 600.000000 250.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
end transform
pop group mode 3
end transform
-22
View File
@@ -1,22 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
push group
start transform 1.000000 0.000000 0.000000 1.000000 150.000000 0.000000
start clip glyph 174
solid 3 1.000000
end clip
end transform
pop group mode 3
push group
start transform 1.000000 0.000000 0.000000 1.000000 -150.000000 0.000000
start clip glyph 174
linear gradient
p0 500.000000 250.000000
p1 500.000000 950.000000
p2 600.000000 250.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
pop group mode 3
end transform
+13
View File
@@ -0,0 +1,13 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 6
linear gradient
p0 100.000000 250.000000
p1 900.000000 250.000000
p2 100.000000 300.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
end transform
-11
View File
@@ -1,11 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 6
linear gradient
p0 100.000000 250.000000
p1 900.000000 250.000000
p2 100.000000 300.000000
colors
0.000000 0 1.000000
1.000000 4 1.000000
end clip
end transform
+13
View File
@@ -0,0 +1,13 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start transform 50.000000 0.000000 0.000000 50.000000 0.000000 0.000000
start clip glyph 2
radial gradient
p0 166.000000 768.000000 radius 0.000000
p1 166.000000 768.000000 radius 256.000000
colors
0.000000 3 1.000000
0.500000 9 1.000000
1.000000 0 1.000000
end clip
end transform
end transform
-11
View File
@@ -1,11 +0,0 @@
start transform 0.020000 0.000000 0.000000 0.020000 0.000000 0.000000
start clip glyph 2
radial gradient
p0 166.000000 768.000000 radius 0.000000
p1 166.000000 768.000000 radius 256.000000
colors
0.000000 3 1.000000
0.500000 9 1.000000
1.000000 0 1.000000
end clip
end transform
+24 -16
View File
@@ -484,6 +484,7 @@ push_transform (hb_paint_funcs_t *funcs,
float xx, float yx,
float xy, float yy,
float dx, float dy,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -495,6 +496,7 @@ push_transform (hb_paint_funcs_t *funcs,
static void
pop_transform (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -507,6 +509,7 @@ static void
push_clip_glyph (hb_paint_funcs_t *funcs,
void *paint_data,
hb_codepoint_t glyph,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -519,6 +522,7 @@ static void
push_clip_rectangle (hb_paint_funcs_t *funcs,
void *paint_data,
float xmin, float ymin, float xmax, float ymax,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -530,6 +534,7 @@ push_clip_rectangle (hb_paint_funcs_t *funcs,
static void
pop_clip (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -543,6 +548,7 @@ paint_color (hb_paint_funcs_t *funcs,
void *paint_data,
unsigned int color_index,
float alpha,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -556,6 +562,7 @@ paint_image (hb_paint_funcs_t *funcs,
hb_blob_t *blob,
hb_tag_t format,
hb_glyph_extents_t *extents,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -591,6 +598,7 @@ paint_linear_gradient (hb_paint_funcs_t *funcs,
float x0, float y0,
float x1, float y1,
float x2, float y2,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -611,6 +619,7 @@ paint_radial_gradient (hb_paint_funcs_t *funcs,
hb_color_line_t *color_line,
float x0, float y0, float r0,
float x1, float y1, float r1,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -631,6 +640,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
float cx, float cy,
float start_angle,
float end_angle,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -647,6 +657,7 @@ paint_sweep_gradient (hb_paint_funcs_t *funcs,
static void
push_group (hb_paint_funcs_t *funcs,
void *paint_data,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -658,6 +669,7 @@ static void
pop_group (hb_paint_funcs_t *funcs,
void *paint_data,
hb_paint_composite_mode_t mode,
hb_font_t *font,
void *user_data)
{
paint_data_t *data = user_data;
@@ -677,16 +689,16 @@ typedef struct {
#define TEST_GLYPHS "fonts/test_glyphs-glyf_colr_1.ttf"
static colrv1_test_t colrv1_tests[] = {
{ NOTO_HAND, 20, 0., 10, "results/hand-20-0-10.txt" },
{ NOTO_HAND, 20, 0.2, 10, "results/hand-20-0.2-10.txt" },
{ TEST_GLYPHS, 20, 0, 6, "results/test-20-0-6.txt" },
{ TEST_GLYPHS, 20, 0, 10, "results/test-20-0-10.txt" },
{ TEST_GLYPHS, 20, 0, 92, "results/test-20-0-92.txt" },
{ TEST_GLYPHS, 20, 0, 106, "results/test-20-0-106.txt" },
{ TEST_GLYPHS, 20, 0, 116, "results/test-20-0-116.txt" },
{ TEST_GLYPHS, 20, 0, 123, "results/test-20-0-123.txt" },
{ TEST_GLYPHS, 20, 0, 165, "results/test-20-0-165.txt" },
{ TEST_GLYPHS, 20, 0, 175, "results/test-20-0-175.txt" },
{ NOTO_HAND, 20, 0., 10, "hand-20-0-10" },
{ NOTO_HAND, 20, 0.2, 10, "hand-20-0.2-10" },
{ TEST_GLYPHS, 20, 0, 6, "test-20-0-6" },
{ TEST_GLYPHS, 20, 0, 10, "test-20-0-10" },
{ TEST_GLYPHS, 20, 0, 92, "test-20-0-92" },
{ TEST_GLYPHS, 20, 0, 106, "test-20-0-106" },
{ TEST_GLYPHS, 20, 0, 116, "test-20-0-116" },
{ TEST_GLYPHS, 20, 0, 123, "test-20-0-123" },
{ TEST_GLYPHS, 20, 0, 165, "test-20-0-165" },
{ TEST_GLYPHS, 20, 0, 175, "test-20-0-175" },
};
static void
@@ -738,7 +750,7 @@ test_hb_ot_color_colr_v1 (gconstpointer d)
exit (0);
}
file = g_test_build_filename (G_TEST_DIST, test->output, NULL);
file = g_test_build_filename (G_TEST_DIST, "results", test->output, NULL);
if (!g_file_get_contents (file, &buffer, &len, &error))
{
g_test_message ("File %s not found.", file);
@@ -820,11 +832,7 @@ main (int argc, char **argv)
hb_test_add (test_hb_ot_color_png);
hb_test_add (test_hb_ot_color_svg);
for (unsigned int i = 0; i < G_N_ELEMENTS (colrv1_tests); i++)
{
char buf[10] = { 0, };
g_snprintf (buf, 10, "%d", i);
hb_test_add_data_flavor (&colrv1_tests[i], buf, test_hb_ot_color_colr_v1);
}
hb_test_add_data_flavor (&colrv1_tests[i], colrv1_tests[i].output, test_hb_ot_color_colr_v1);
status = hb_test_run();
hb_face_destroy (cpal_v0);