diff --git a/src/hb-vector-draw.cc b/src/hb-vector-draw.cc
index 8a41b33ce..c2f7512d3 100644
--- a/src/hb-vector-draw.cc
+++ b/src/hb-vector-draw.cc
@@ -495,7 +495,7 @@ hb_vector_draw_glyph_or_fail (hb_vector_draw_t *draw,
float yy = draw->transform.yy;
float tx = draw->transform.x0;
float ty = draw->transform.y0;
- hb_transform_t<> extents_transform = {xx, yx, -xy, -yy, tx, -ty};
+ hb_transform_t<> extents_transform = {xx, yx, xy, yy, tx, ty};
hb_bool_t has_extents = draw->has_extents;
hb_vector_set_glyph_extents_common (extents_transform,
@@ -763,18 +763,25 @@ hb_vector_draw_render_svg (hb_vector_draw_t *draw)
(draw->body.length ? draw->body.length : draw->path.length) +
256;
out.alloc (estimated);
+ /* Extents are in Y-up (font) space. SVG is Y-down.
+ * The global scale(1,-1) wrapper flips content; the
+ * viewBox maps the flipped range. */
+ float vb_x = draw->extents.x;
+ float vb_y = -(draw->extents.y + draw->extents.height);
+ float vb_w = draw->extents.width;
+ float vb_h = draw->extents.height;
out.append_str ("\n");
diff --git a/src/hb-vector-draw.hh b/src/hb-vector-draw.hh
index d2458cd89..b91ae52de 100644
--- a/src/hb-vector-draw.hh
+++ b/src/hb-vector-draw.hh
@@ -84,31 +84,11 @@ struct hb_vector_draw_t
void flush_path_svg ()
{
- unsigned r = hb_color_get_red (foreground);
- unsigned g = hb_color_get_green (foreground);
- unsigned b = hb_color_get_blue (foreground);
- unsigned a = hb_color_get_alpha (foreground);
- body.append_str (""
- "\n");
+ body.append_str ("\" fill=\"");
+ body.append_svg_color (foreground, true);
+ body.append_str ("\"/>\n");
}
void transform_xy (float x, float y, float *tx, float *ty)
diff --git a/src/hb-vector-paint-svg.cc b/src/hb-vector-paint-svg.cc
index e391e86de..6d2a41e9b 100644
--- a/src/hb-vector-paint-svg.cc
+++ b/src/hb-vector-paint-svg.cc
@@ -916,18 +916,22 @@ hb_vector_paint_render_svg (hb_vector_paint_t *paint)
paint->group_stack.arrayZ[0].length +
320;
out.alloc (estimated);
+ float vb_x = paint->extents.x;
+ float vb_y = -(paint->extents.y + paint->extents.height);
+ float vb_w = paint->extents.width;
+ float vb_h = paint->extents.height;
out.append_str ("\n");
diff --git a/src/hb-vector-paint.cc b/src/hb-vector-paint.cc
index a16682490..4a58d22cc 100644
--- a/src/hb-vector-paint.cc
+++ b/src/hb-vector-paint.cc
@@ -548,7 +548,7 @@ hb_vector_paint_glyph_impl (hb_vector_paint_t *paint,
if (hb_font_get_glyph_extents (font, glyph, &ge))
{
hb_bool_t has_extents = paint->has_extents;
- hb_transform_t<> extents_transform = {xx, yx, -xy, -yy, tx, -ty};
+ hb_transform_t<> extents_transform = {xx, yx, xy, yy, tx, ty};
hb_bool_t ret = hb_vector_set_glyph_extents_common (extents_transform,
paint->x_scale_factor,
paint->y_scale_factor,
@@ -564,17 +564,7 @@ hb_vector_paint_glyph_impl (hb_vector_paint_t *paint,
return false;
hb_paint_funcs_t *funcs = hb_vector_paint_get_funcs (paint);
- switch (paint->format)
- {
- case HB_VECTOR_FORMAT_SVG:
- hb_paint_push_transform (funcs, paint, xx, yx, -xy, -yy, tx, -ty);
- break;
- case HB_VECTOR_FORMAT_PDF:
- hb_paint_push_transform (funcs, paint, xx, yx, xy, yy, tx, ty);
- break;
- case HB_VECTOR_FORMAT_INVALID: default:
- return false;
- }
+ hb_paint_push_transform (funcs, paint, xx, yx, xy, yy, tx, ty);
hb_bool_t ret = true;
if (fallible)
diff --git a/test/vector/data/expected/basic/cff1.svg b/test/vector/data/expected/basic/cff1.svg
index 7f95e4387..0a478e233 100644
--- a/test/vector/data/expected/basic/cff1.svg
+++ b/test/vector/data/expected/basic/cff1.svg
@@ -1,6 +1,8 @@
-