From 029d5db2c4928a0bb4c357fc4db53aa614eac7f9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 17 Feb 2017 13:14:57 +0100 Subject: Fix svg text output when text span is all whitespace or empty. We were emitting unbalanced quotes for the x and y attributes. --- source/fitz/svg-device.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index 8a69d223..09b3d82d 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -310,7 +310,7 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const break; } - fz_printf(ctx, out, " x="); + fz_printf(ctx, out, " x=\""); was_wspace = 0; for (i=start; i < span->len; i++) { @@ -323,9 +323,11 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const p.x = it->x; p.y = it->y; fz_transform_point(&p, &inverse); - fz_printf(ctx, out, "%c%g", i == start ? '\"' : ' ', p.x); + if (i > start) + fz_putc(ctx, out, ' '); + fz_printf(ctx, out, "%g", p.x); } - fz_printf(ctx, out, "\" y="); + fz_printf(ctx, out, "\" y=\""); was_wspace = 0; for (i=start; i < span->len; i++) { @@ -338,7 +340,9 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const p.x = it->x; p.y = it->y; fz_transform_point(&p, &inverse); - fz_printf(ctx, out, "%c%g", i == start ? '\"' : ' ', p.y); + if (i > start) + fz_putc(ctx, out, ' '); + fz_printf(ctx, out, "%g", p.y); } fz_printf(ctx, out, "\">\n"); was_wspace = 0; -- cgit v1.2.3