[vector] Fix global paint transform for output-space

The SVG global transform prefix emitted x0/y0 raw without
dividing by scale_factor.  The PDF per-glyph cm was reduced
to identity + translation, losing the matrix entries from
paint->transform when non-identity.

Fix: divide x0/y0 by sf in SVG; emit full matrix in PDF cm.
Update stale comment.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad Esfahbod committed 2026-04-17 01:22:56 -06:00
1 parent bc1346db0d
commit 9dfd7aa5a5
2 files changed
+13 -8

No files matched your search

+5 -7
View File
@@ -35,11 +35,9 @@
static void
hb_vector_svg_paint_append_global_transform_prefix (hb_vector_paint_t *paint, hb_vector_buf_t *buf)
{
/* Skip when the paint's own transform is identity -- each
* instance's <use> transform already divides by scale_factor,
* so wrapping the body in another /scale_factor matrix would
* double-scale. Only emit when the user has set a non-
* identity paint-level transform. */
/* Skip when the paint's own transform is identity.
* Only emit when the user has set a non-identity
* paint-level transform via hb_vector_paint_set_transform. */
if (paint->transform.xx == 1.f && paint->transform.yx == 0.f &&
paint->transform.xy == 0.f && paint->transform.yy == 1.f &&
paint->transform.x0 == 0.f && paint->transform.y0 == 0.f)
@@ -55,9 +53,9 @@ hb_vector_svg_paint_append_global_transform_prefix (hb_vector_paint_t *paint, hb
buf->append_c (',');
buf->append_num (paint->transform.yy, sprec);
buf->append_c (',');
buf->append_num (paint->transform.x0);
buf->append_num (paint->sx (paint->transform.x0));
buf->append_c (',');
buf->append_num (paint->transform.y0);
buf->append_num (paint->sy (paint->transform.y0));
buf->append_str (")\">\n");
}
+8 -1
View File
@@ -587,7 +587,14 @@ hb_vector_paint_glyph_impl (hb_vector_paint_t *paint,
float sx = paint->x_scale_factor;
float sy = paint->y_scale_factor;
body.append_str ("q\n");
body.append_str ("1 0 0 1 ");
body.append_num (xx);
body.append_c (' ');
body.append_num (yx);
body.append_c (' ');
body.append_num (xy);
body.append_c (' ');
body.append_num (yy);
body.append_c (' ');
body.append_num (tx / sx);
body.append_c (' ');
body.append_num (ty / sy);