mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 07:21:06 +01:00
[vector-paint] Fold scale_factor into PDF per-glyph cm
Follow-up to 152aa0fd8c. The SVG branch of
hb_vector_paint_glyph divides the instance transform by
x_scale_factor/y_scale_factor (via
hb_vector_svg_append_instance_transform) so input-space
glyph paths land in the pixel-space viewBox. The PDF
branch emitted the raw paint matrix, which kept the CTM in
input space while the MediaBox lived in pixel space —
at any non-identity scale_factor, the glyph rendered
entirely outside the page.
Divide the matrix columns by sx/sy in the emitted cm so
PDF matches SVG. Covers hb-vector's font-size != 20 case
and the website's scale_factor = 64 case, where emoji
rendered blank at 72 px.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
152aa0fd8c
commit
dba4dab3ef
1 file changed
+14
-7
+14
-7
@@ -1370,21 +1370,28 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint,
|
||||
{
|
||||
case HB_VECTOR_FORMAT_PDF:
|
||||
{
|
||||
/* PDF: emit transform + paint directly, no caching. */
|
||||
/* PDF: emit transform + paint directly, no caching.
|
||||
* The paint transform and pen position are in input
|
||||
* space; fold in 1/scale_factor here so glyph path
|
||||
* operators (emitted raw in input space) land in
|
||||
* pixel space, matching the MediaBox. */
|
||||
auto &body = paint->current_body ();
|
||||
unsigned sprec = hb_vector_scale_precision (paint->precision);
|
||||
float sx = paint->x_scale_factor;
|
||||
float sy = paint->y_scale_factor;
|
||||
hb_buf_append_str (&body, "q\n");
|
||||
/* Font and PDF coords are both Y-up; no negation needed. */
|
||||
hb_buf_append_num (&body, xx, paint->precision);
|
||||
hb_buf_append_num (&body, xx / sx, sprec, true);
|
||||
hb_buf_append_c (&body, ' ');
|
||||
hb_buf_append_num (&body, yx, paint->precision);
|
||||
hb_buf_append_num (&body, yx / sy, sprec, true);
|
||||
hb_buf_append_c (&body, ' ');
|
||||
hb_buf_append_num (&body, xy, paint->precision);
|
||||
hb_buf_append_num (&body, xy / sx, sprec, true);
|
||||
hb_buf_append_c (&body, ' ');
|
||||
hb_buf_append_num (&body, yy, paint->precision);
|
||||
hb_buf_append_num (&body, yy / sy, sprec, true);
|
||||
hb_buf_append_c (&body, ' ');
|
||||
hb_buf_append_num (&body, tx, paint->precision);
|
||||
hb_buf_append_num (&body, tx / sx, paint->precision);
|
||||
hb_buf_append_c (&body, ' ');
|
||||
hb_buf_append_num (&body, ty, paint->precision);
|
||||
hb_buf_append_num (&body, ty / sy, paint->precision);
|
||||
hb_buf_append_str (&body, " cm\n");
|
||||
|
||||
hb_bool_t ret = hb_font_paint_glyph_or_fail (font, glyph,
|
||||
|
||||
Reference in new issue
Block a user