diff options
Diffstat (limited to 'source/fitz/svg-device.c')
-rw-r--r-- | source/fitz/svg-device.c | 264 |
1 files changed, 132 insertions, 132 deletions
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index eb056c13..e80682fd 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -94,7 +94,7 @@ end_def(fz_context *ctx, svg_device *sdev) sdev->out = sdev->out_store; if (sdev->def_count == 0 && sdev->defs_buffer != NULL) { - fz_write(ctx, sdev->out, sdev->defs_buffer->data, sdev->defs_buffer->len); + fz_write_data(ctx, sdev->out, sdev->defs_buffer->data, sdev->defs_buffer->len); sdev->defs_buffer->len = 0; } return sdev->out; @@ -107,7 +107,7 @@ svg_path_moveto(fz_context *ctx, void *arg, float x, float y) { fz_output *out = (fz_output *)arg; - fz_printf(ctx, out, "M %g %g ", x, y); + fz_write_printf(ctx, out, "M %g %g ", x, y); } static void @@ -115,7 +115,7 @@ svg_path_lineto(fz_context *ctx, void *arg, float x, float y) { fz_output *out = (fz_output *)arg; - fz_printf(ctx, out, "L %g %g ", x, y); + fz_write_printf(ctx, out, "L %g %g ", x, y); } static void @@ -123,7 +123,7 @@ svg_path_curveto(fz_context *ctx, void *arg, float x1, float y1, float x2, float { fz_output *out = (fz_output *)arg; - fz_printf(ctx, out, "C %g %g %g %g %g %g ", x1, y1, x2, y2, x3, y3); + fz_write_printf(ctx, out, "C %g %g %g %g %g %g ", x1, y1, x2, y2, x3, y3); } static void @@ -131,7 +131,7 @@ svg_path_close(fz_context *ctx, void *arg) { fz_output *out = (fz_output *)arg; - fz_printf(ctx, out, "Z "); + fz_write_printf(ctx, out, "Z "); } static const fz_path_walker svg_path_walker = @@ -145,9 +145,9 @@ static const fz_path_walker svg_path_walker = static void svg_dev_path(fz_context *ctx, svg_device *sdev, const fz_path *path) { - fz_printf(ctx, sdev->out, " d=\""); + fz_write_printf(ctx, sdev->out, " d=\""); fz_walk_path(ctx, path, &svg_path_walker, sdev->out); - fz_printf(ctx, sdev->out, "\""); + fz_write_printf(ctx, sdev->out, "\""); } static void @@ -157,7 +157,7 @@ svg_dev_ctm(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm) if (ctm->a != 1.0 || ctm->b != 0 || ctm->c != 0 || ctm->d != 1.0 || ctm->e != 0 || ctm->f != 0) { - fz_printf(ctx, out, " transform=\"matrix(%g,%g,%g,%g,%g,%g)\"", + fz_write_printf(ctx, out, " transform=\"matrix(%g,%g,%g,%g,%g,%g)\"", ctm->a, ctm->b, ctm->c, ctm->d, ctm->e, ctm->f); } } @@ -175,23 +175,23 @@ svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, const fz_stroke_state *s if (exp < 1) exp = 1; - fz_printf(ctx, out, " stroke-width=\"%g\"", exp); - fz_printf(ctx, out, " stroke-linecap=\"%s\"", + fz_write_printf(ctx, out, " stroke-width=\"%g\"", exp); + fz_write_printf(ctx, out, " stroke-linecap=\"%s\"", (stroke_state->start_cap == FZ_LINECAP_SQUARE ? "square" : (stroke_state->start_cap == FZ_LINECAP_ROUND ? "round" : "butt"))); if (stroke_state->dash_len != 0) { int i; - fz_printf(ctx, out, " stroke-dasharray="); + fz_write_printf(ctx, out, " stroke-dasharray="); for (i = 0; i < stroke_state->dash_len; i++) - fz_printf(ctx, out, "%c%g", (i == 0 ? '\"' : ','), stroke_state->dash_list[i]); - fz_printf(ctx, out, "\""); + fz_write_printf(ctx, out, "%c%g", (i == 0 ? '\"' : ','), stroke_state->dash_list[i]); + fz_write_printf(ctx, out, "\""); if (stroke_state->dash_phase != 0) - fz_printf(ctx, out, " stroke-dashoffset=\"%g\"", stroke_state->dash_phase); + fz_write_printf(ctx, out, " stroke-dashoffset=\"%g\"", stroke_state->dash_phase); } if (stroke_state->linejoin == FZ_LINEJOIN_MITER || stroke_state->linejoin == FZ_LINEJOIN_MITER_XPS) - fz_printf(ctx, out, " stroke-miterlimit=\"%g\"", stroke_state->miterlimit); - fz_printf(ctx, out, " stroke-linejoin=\"%s\"", + fz_write_printf(ctx, out, " stroke-miterlimit=\"%g\"", stroke_state->miterlimit); + fz_write_printf(ctx, out, " stroke-linejoin=\"%s\"", (stroke_state->linejoin == FZ_LINEJOIN_BEVEL ? "bevel" : (stroke_state->linejoin == FZ_LINEJOIN_ROUND ? "round" : "miter"))); } @@ -223,12 +223,12 @@ svg_dev_fill_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspace, { int rgb = svg_hex_color(ctx, colorspace, color); if (rgb != 0) /* black is the default value */ - fz_printf(ctx, out, " fill=\"#%06x\"", rgb); + fz_write_printf(ctx, out, " fill=\"#%06x\"", rgb); } else - fz_printf(ctx, out, " fill=\"none\""); + fz_write_printf(ctx, out, " fill=\"none\""); if (alpha != 1) - fz_printf(ctx, out, " fill-opacity=\"%g\"", alpha); + fz_write_printf(ctx, out, " fill-opacity=\"%g\"", alpha); } static void @@ -236,11 +236,11 @@ svg_dev_stroke_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspac { fz_output *out = sdev->out; if (colorspace) - fz_printf(ctx, out, " fill=\"none\" stroke=\"#%06x\"", svg_hex_color(ctx, colorspace, color)); + fz_write_printf(ctx, out, " fill=\"none\" stroke=\"#%06x\"", svg_hex_color(ctx, colorspace, color)); else - fz_printf(ctx, out, " fill=\"none\" stroke=\"none\""); + fz_write_printf(ctx, out, " fill=\"none\" stroke=\"none\""); if (alpha != 1) - fz_printf(ctx, out, " stroke-opacity=\"%g\"", alpha); + fz_write_printf(ctx, out, " stroke-opacity=\"%g\"", alpha); } static void @@ -322,7 +322,7 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const if (span->len == 0) { - fz_printf(ctx, out, "/>\n"); + fz_write_printf(ctx, out, "/>\n"); return; } @@ -344,15 +344,15 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const is_bold = fz_font_is_bold(ctx, span->font); is_italic = fz_font_is_italic(ctx, span->font); - fz_printf(ctx, out, " xml:space=\"preserve\""); - fz_printf(ctx, out, " transform=\"matrix(%M)\"", &final_tm); - fz_printf(ctx, out, " font-size=\"%g\"", font_size); - fz_printf(ctx, out, " font-family=\"%s\"", font_family); - if (is_bold) fz_printf(ctx, out, " font-weight=\"bold\""); - if (is_italic) fz_printf(ctx, out, " font-style=\"italic\""); - if (span->wmode != 0) fz_printf(ctx, out, " writing-mode=\"tb\""); + fz_write_printf(ctx, out, " xml:space=\"preserve\""); + fz_write_printf(ctx, out, " transform=\"matrix(%M)\"", &final_tm); + fz_write_printf(ctx, out, " font-size=\"%g\"", font_size); + fz_write_printf(ctx, out, " font-family=\"%s\"", font_family); + if (is_bold) fz_write_printf(ctx, out, " font-weight=\"bold\""); + if (is_italic) fz_write_printf(ctx, out, " font-style=\"italic\""); + if (span->wmode != 0) fz_write_printf(ctx, out, " writing-mode=\"tb\""); - fz_putc(ctx, out, '>'); + fz_write_byte(ctx, out, '>'); start = find_first_char(ctx, span, 0); while (start < span->len) @@ -365,9 +365,9 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const if (span->items[start].gid >= 0) cluster_advance = svg_cluster_advance(ctx, span, start, end); if (span->wmode == 0) - fz_printf(ctx, out, "<tspan y=\"%g\" x=\"%g", p.y, p.x); + fz_write_printf(ctx, out, "<tspan y=\"%g\" x=\"%g", p.y, p.x); else - fz_printf(ctx, out, "<tspan x=\"%g\" y=\"%g", p.x, p.y); + fz_write_printf(ctx, out, "<tspan x=\"%g\" y=\"%g", p.x, p.y); for (i = start + 1; i < end; ++i) { it = &span->items[i]; @@ -389,10 +389,10 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const else p.y += font_size * cluster_advance; } - fz_printf(ctx, out, " %g", span->wmode == 0 ? p.x : p.y); + fz_write_printf(ctx, out, " %g", span->wmode == 0 ? p.x : p.y); } } - fz_printf(ctx, out, "\">"); + fz_write_printf(ctx, out, "\">"); for (i = start; i < end; ++i) { it = &span->items[i]; @@ -400,17 +400,17 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const { int c = it->ucs; if (c >= 32 && c <= 127 && c != '<' && c != '&' && c != '>') - fz_putc(ctx, out, c); + fz_write_byte(ctx, out, c); else - fz_printf(ctx, out, "&#x%04x;", c); + fz_write_printf(ctx, out, "&#x%04x;", c); } } - fz_printf(ctx, out, "</tspan>"); + fz_write_printf(ctx, out, "</tspan>"); start = find_first_char(ctx, span, end); } - fz_printf(ctx, out, "</text>\n"); + fz_write_printf(ctx, out, "</text>\n"); } static font * @@ -476,10 +476,10 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s shift.f = -rect.y0; fz_transform_path(ctx, path, &shift); out = start_def(ctx, sdev); - fz_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid); - fz_printf(ctx, out, "<path"); + fz_write_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid); + fz_write_printf(ctx, out, "<path"); svg_dev_path(ctx, sdev, path); - fz_printf(ctx, out, "/>\n"); + fz_write_printf(ctx, out, "/>\n"); fz_drop_path(ctx, path); } else @@ -488,10 +488,10 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s shift.e = -rect.x0; shift.f = -rect.y0; out = start_def(ctx, sdev); - fz_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid); + fz_write_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid); fz_run_t3_glyph(ctx, span->font, gid, &shift, dev); } - fz_printf(ctx, out, "</symbol>\n"); + fz_write_printf(ctx, out, "</symbol>\n"); out = end_def(ctx, sdev); fnt->sentlist[gid].x_off = rect.x0; fnt->sentlist[gid].y_off = rect.y0; @@ -533,10 +533,10 @@ svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, const fz_text_s local_trm.f = it->y; fz_concat(&local_trm2, &local_trm, ctm); fz_concat(&local_trm2, &shift, &local_trm2); - fz_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid); + fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid); svg_dev_ctm(ctx, sdev, &local_trm2); svg_dev_fill_color(ctx, sdev, colorspace, color, alpha); - fz_printf(ctx, out, "/>\n"); + fz_write_printf(ctx, out, "/>\n"); } } @@ -573,11 +573,11 @@ svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, const fz_text local_trm.f = it->y; fz_concat(&local_trm2, &local_trm, ctm); fz_concat(&local_trm2, &shift, &local_trm2); - fz_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid); + fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid); svg_dev_stroke_state(ctx, sdev, stroke, &local_trm2); svg_dev_ctm(ctx, sdev, &local_trm2); svg_dev_stroke_color(ctx, sdev, colorspace, color, alpha); - fz_printf(ctx, out, "/>\n"); + fz_write_printf(ctx, out, "/>\n"); } } @@ -590,13 +590,13 @@ svg_dev_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even svg_device *sdev = (svg_device*)dev; fz_output *out = sdev->out; - fz_printf(ctx, out, "<path"); + fz_write_printf(ctx, out, "<path"); svg_dev_ctm(ctx, sdev, ctm); svg_dev_path(ctx, sdev, path); svg_dev_fill_color(ctx, sdev, colorspace, color, alpha); if (even_odd) - fz_printf(ctx, out, " fill-rule=\"evenodd\""); - fz_printf(ctx, out, "/>\n"); + fz_write_printf(ctx, out, " fill-rule=\"evenodd\""); + fz_write_printf(ctx, out, "/>\n"); } static void @@ -606,12 +606,12 @@ svg_dev_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const svg_device *sdev = (svg_device*)dev; fz_output *out = sdev->out; - fz_printf(ctx, out, "<path"); + fz_write_printf(ctx, out, "<path"); svg_dev_ctm(ctx, sdev, ctm); svg_dev_stroke_state(ctx, sdev, stroke, &fz_identity); svg_dev_stroke_color(ctx, sdev, colorspace, color, alpha); svg_dev_path(ctx, sdev, path); - fz_printf(ctx, out, "/>\n"); + fz_write_printf(ctx, out, "/>\n"); } static void @@ -623,15 +623,15 @@ svg_dev_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even int num = sdev->id++; out = start_def(ctx, sdev); - fz_printf(ctx, out, "<clipPath id=\"cp%d\">\n", num); - fz_printf(ctx, out, "<path"); + fz_write_printf(ctx, out, "<clipPath id=\"cp%d\">\n", num); + fz_write_printf(ctx, out, "<path"); svg_dev_ctm(ctx, sdev, ctm); svg_dev_path(ctx, sdev, path); if (even_odd) - fz_printf(ctx, out, " fill-rule=\"evenodd\""); - fz_printf(ctx, out, "/>\n</clipPath>\n"); + fz_write_printf(ctx, out, " fill-rule=\"evenodd\""); + fz_write_printf(ctx, out, "/>\n</clipPath>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", num); + fz_write_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", num); } static void @@ -647,16 +647,16 @@ svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, c fz_bound_path(ctx, path, stroke, ctm, &bounds); out = start_def(ctx, sdev); - fz_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n", + fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n", num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0); - fz_printf(ctx, out, "<path"); + fz_write_printf(ctx, out, "<path"); svg_dev_ctm(ctx, sdev, ctm); svg_dev_stroke_state(ctx, sdev, stroke, &fz_identity); svg_dev_stroke_color(ctx, sdev, fz_device_rgb(ctx), white, 1); svg_dev_path(ctx, sdev, path); - fz_printf(ctx, out, "/>\n</mask>\n"); + fz_write_printf(ctx, out, "/>\n</mask>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num); + fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num); } static void @@ -672,7 +672,7 @@ svg_dev_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz { for (span = text->head; span; span = span->next) { - fz_printf(ctx, out, "<text"); + fz_write_printf(ctx, out, "<text"); svg_dev_fill_color(ctx, sdev, colorspace, color, alpha); svg_dev_text_span(ctx, sdev, ctm, span); } @@ -700,7 +700,7 @@ svg_dev_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const { for (span = text->head; span; span = span->next) { - fz_printf(ctx, out, "<text"); + fz_write_printf(ctx, out, "<text"); svg_dev_fill_color(ctx, sdev, colorspace, color, alpha); svg_dev_text_span(ctx, sdev, ctm, span); } @@ -730,14 +730,14 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz fz_bound_text(ctx, text, NULL, ctm, &bounds); out = start_def(ctx, sdev); - fz_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"", + fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"", num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0); - fz_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n"); + fz_write_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n"); if (sdev->text_as_text) { for (span = text->head; span; span = span->next) { - fz_printf(ctx, out, "<text"); + fz_write_printf(ctx, out, "<text"); svg_dev_fill_color(ctx, sdev, fz_device_rgb(ctx), white, 1); svg_dev_text_span(ctx, sdev, ctm, span); } @@ -750,9 +750,9 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz svg_dev_text_span_as_paths_fill(ctx, dev, span, ctm, fz_device_rgb(ctx), white, 1.0f, fnt); } } - fz_printf(ctx, out, "</mask>\n"); + fz_write_printf(ctx, out, "</mask>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num); + fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num); } static void @@ -770,14 +770,14 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c fz_bound_text(ctx, text, NULL, ctm, &bounds); out = start_def(ctx, sdev); - fz_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"", + fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"", num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0); - fz_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n"); + fz_write_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n"); if (sdev->text_as_text) { for (span = text->head; span; span = span->next) { - fz_printf(ctx, out, "<text"); + fz_write_printf(ctx, out, "<text"); svg_dev_stroke_state(ctx, sdev, stroke, &fz_identity); svg_dev_stroke_color(ctx, sdev, fz_device_rgb(ctx), white, 1); svg_dev_text_span(ctx, sdev, ctm, span); @@ -791,9 +791,9 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c svg_dev_text_span_as_paths_stroke(ctx, dev, span, stroke, ctm, fz_device_rgb(ctx), white, 1.0f, fnt); } } - fz_printf(ctx, out, "</mask>\n"); + fz_write_printf(ctx, out, "</mask>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num); + fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num); } static void @@ -809,7 +809,7 @@ svg_dev_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const { for (span = text->head; span; span = span->next) { - fz_printf(ctx, out, "<text"); + fz_write_printf(ctx, out, "<text"); svg_dev_fill_color(ctx, sdev, fz_device_rgb(ctx), black, 0.0f); svg_dev_text_span(ctx, sdev, ctm, span); } @@ -829,8 +829,8 @@ send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer) int d = buffer->data[3*i+1]; int e = buffer->data[3*i+2]; if ((i & 15) == 0) - fz_printf(ctx, out, "\n"); - fz_printf(ctx, out, "%c%c%c%c", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)|(e>>6)], set[e & 63]); + fz_write_printf(ctx, out, "\n"); + fz_write_printf(ctx, out, "%c%c%c%c", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)|(e>>6)], set[e & 63]); } i *= 3; switch (buffer->len-i) @@ -839,13 +839,13 @@ send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer) { int c = buffer->data[i]; int d = buffer->data[i+1]; - fz_printf(ctx, out, "%c%c%c=", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)]); + fz_write_printf(ctx, out, "%c%c%c=", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)]); break; } case 1: { int c = buffer->data[i]; - fz_printf(ctx, out, "%c%c==", set[c>>2], set[(c&3)<<4]); + fz_write_printf(ctx, out, "%c%c==", set[c>>2], set[(c&3)<<4]); break; } default: @@ -874,7 +874,7 @@ svg_send_image(fz_context *ctx, svg_device *sdev, fz_image *img) break; if (i >= 0) { - fz_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n", + fz_write_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n", sdev->images[i].id, img->w, img->h); return; } @@ -891,23 +891,23 @@ svg_send_image(fz_context *ctx, svg_device *sdev, fz_image *img) id = sdev->id++; out = start_def(ctx, sdev); - fz_printf(ctx, out, "<symbol id=\"im%d\" viewBox=\"0 0 %d %d\">\n", id, img->w, img->h); + fz_write_printf(ctx, out, "<symbol id=\"im%d\" viewBox=\"0 0 %d %d\">\n", id, img->w, img->h); } - fz_printf(ctx, out, "<image"); + fz_write_printf(ctx, out, "<image"); buffer = fz_compressed_image_buffer(ctx, img); - fz_printf(ctx, out, " width=\"%d\" height=\"%d\" xlink:href=\"data:", img->w, img->h); + fz_write_printf(ctx, out, " width=\"%d\" height=\"%d\" xlink:href=\"data:", img->w, img->h); switch (buffer == NULL ? FZ_IMAGE_JPX : buffer->params.type) { case FZ_IMAGE_PNG: - fz_printf(ctx, out, "image/png;base64,"); + fz_write_printf(ctx, out, "image/png;base64,"); send_data_base64(ctx, out, buffer->buffer); break; case FZ_IMAGE_JPEG: /* SVG cannot cope with CMYK images */ if (img->colorspace != fz_device_cmyk(ctx)) { - fz_printf(ctx, out, "image/jpeg;base64,"); + fz_write_printf(ctx, out, "image/jpeg;base64,"); send_data_base64(ctx, out, buffer->buffer); break; } @@ -915,24 +915,24 @@ svg_send_image(fz_context *ctx, svg_device *sdev, fz_image *img) default: { fz_buffer *buf = fz_new_buffer_from_image_as_png(ctx, img); - fz_printf(ctx, out, "image/png;base64,"); + fz_write_printf(ctx, out, "image/png;base64,"); send_data_base64(ctx, out, buf); fz_drop_buffer(ctx, buf); break; } } - fz_printf(ctx, out, "\"/>\n"); + fz_write_printf(ctx, out, "\"/>\n"); if (sdev->reuse_images) { - fz_printf(ctx, out, "</symbol>\n"); + fz_write_printf(ctx, out, "</symbol>\n"); out = end_def(ctx, sdev); sdev->images[sdev->num_images].id = id; sdev->images[sdev->num_images].image = fz_keep_image(ctx, img); sdev->num_images++; - fz_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n", + fz_write_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n", id, img->w, img->h); } } @@ -950,13 +950,13 @@ svg_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma scale.d = 1.0f / image->h; fz_concat(&local_ctm, &scale, ctm); - fz_printf(ctx, out, "<g"); + fz_write_printf(ctx, out, "<g"); if (alpha != 1.0f) - fz_printf(ctx, out, " opacity=\"%g\"", alpha); + fz_write_printf(ctx, out, " opacity=\"%g\"", alpha); svg_dev_ctm(ctx, sdev, &local_ctm); - fz_printf(ctx, out, ">\n"); + fz_write_printf(ctx, out, ">\n"); svg_send_image(ctx, sdev, image); - fz_printf(ctx, out, "</g>\n"); + fz_write_printf(ctx, out, "</g>\n"); } static void @@ -985,12 +985,12 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma fz_paint_shade(ctx, shade, ctm, pix, &bbox); buf = fz_new_buffer_from_pixmap_as_png(ctx, pix); if (alpha != 1.0f) - fz_printf(ctx, out, "<g opacity=\"%g\">\n", alpha); - fz_printf(ctx, out, "<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"data:image/png;base64,", pix->x, pix->y, pix->w, pix->h); + fz_write_printf(ctx, out, "<g opacity=\"%g\">\n", alpha); + fz_write_printf(ctx, out, "<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"data:image/png;base64,", pix->x, pix->y, pix->w, pix->h); send_data_base64(ctx, out, buf); - fz_printf(ctx, out, "\"/>\n"); + fz_write_printf(ctx, out, "\"/>\n"); if (alpha != 1.0f) - fz_printf(ctx, out, "</g>\n"); + fz_write_printf(ctx, out, "</g>\n"); } fz_always(ctx) { @@ -1018,14 +1018,14 @@ svg_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_concat(&local_ctm, &scale, ctm); out = start_def(ctx, sdev); - fz_printf(ctx, out, "<mask id=\"ma%d\">\n", mask); + fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n", mask); svg_send_image(ctx, sdev, image); - fz_printf(ctx, out, "</mask>\n"); + fz_write_printf(ctx, out, "</mask>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", image->w, image->h); + fz_write_printf(ctx, out, "<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", image->w, image->h); svg_dev_fill_color(ctx, sdev, colorspace, color, alpha); svg_dev_ctm(ctx, sdev, &local_ctm); - fz_printf(ctx, out, " mask=\"url(#ma%d)\"/>\n", mask); + fz_write_printf(ctx, out, " mask=\"url(#ma%d)\"/>\n", mask); } static void @@ -1042,13 +1042,13 @@ svg_dev_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_concat(&local_ctm, &scale, ctm); out = start_def(ctx, sdev); - fz_printf(ctx, out, "<mask id=\"ma%d\">\n<g", mask); + fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n<g", mask); svg_dev_ctm(ctx, sdev, &local_ctm); - fz_printf(ctx, out, ">\n"); + fz_write_printf(ctx, out, ">\n"); svg_send_image(ctx, sdev, image); - fz_printf(ctx, out, "</g>\n</mask>\n"); + fz_write_printf(ctx, out, "</g>\n</mask>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask); + fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask); } static void @@ -1058,7 +1058,7 @@ svg_dev_pop_clip(fz_context *ctx, fz_device *dev) fz_output *out = sdev->out; /* FIXME */ - fz_printf(ctx, out, "</g>\n"); + fz_write_printf(ctx, out, "</g>\n"); } static void @@ -1069,7 +1069,7 @@ svg_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int lum int mask = sdev->id++; out = start_def(ctx, sdev); - fz_printf(ctx, out, "<mask id=\"ma%d\">\n", mask); + fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n", mask); if (dev->container_len > 0) dev->container[dev->container_len-1].user = mask; @@ -1085,9 +1085,9 @@ svg_dev_end_mask(fz_context *ctx, fz_device *dev) if (dev->container_len > 0) mask = (int)dev->container[dev->container_len-1].user; - fz_printf(ctx, out, "\"/>\n</mask>\n"); + fz_write_printf(ctx, out, "\"/>\n</mask>\n"); out = end_def(ctx, sdev); - fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask); + fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask); } static void @@ -1098,9 +1098,9 @@ svg_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int is /* SVG 1.1 doesn't support adequate blendmodes/knockout etc, so just ignore it for now */ if (alpha == 1) - fz_printf(ctx, out, "<g>\n"); + fz_write_printf(ctx, out, "<g>\n"); else - fz_printf(ctx, out, "<g opacity=\"%g\">\n", alpha); + fz_write_printf(ctx, out, "<g opacity=\"%g\">\n", alpha); } static void @@ -1109,7 +1109,7 @@ svg_dev_end_group(fz_context *ctx, fz_device *dev) svg_device *sdev = (svg_device*)dev; fz_output *out = sdev->out; - fz_printf(ctx, out, "</g>\n"); + fz_write_printf(ctx, out, "</g>\n"); } static int @@ -1148,7 +1148,7 @@ svg_dev_begin_tile(fz_context *ctx, fz_device *dev, const fz_rect *area, const f /* The first thing we do is to capture the contents of the pattern * as a symbol we can reuse. */ out = start_def(ctx, sdev); - fz_printf(ctx, out, "<symbol id=\"pac%d\">\n", t->pattern); + fz_write_printf(ctx, out, "<symbol id=\"pac%d\">\n", t->pattern); return 0; } @@ -1168,7 +1168,7 @@ svg_dev_end_tile(fz_context *ctx, fz_device *dev) num = --sdev->num_tiles; t = &sdev->tiles[num]; - fz_printf(ctx, out, "</symbol>\n"); + fz_write_printf(ctx, out, "</symbol>\n"); /* In svg, the reference tile is taken from (x,y) to (x+width,y+height) * and is repeated at (x+n*width,y+m*height) for all integer n and m. @@ -1178,48 +1178,48 @@ svg_dev_end_tile(fz_context *ctx, fz_device *dev) * pattern tile, we need to render the pattern contents several times * to ensure that the pattern tile contains everything. */ - fz_printf(ctx, out, "<pattern id=\"pa%d\" patternUnits=\"userSpaceOnUse\" patternContentUnits=\"userSpaceOnUse\"", + fz_write_printf(ctx, out, "<pattern id=\"pa%d\" patternUnits=\"userSpaceOnUse\" patternContentUnits=\"userSpaceOnUse\"", t->pattern); - fz_printf(ctx, out, " x=\"0\" y=\"0\" width=\"%g\" height=\"%g\">\n", + fz_write_printf(ctx, out, " x=\"0\" y=\"0\" width=\"%g\" height=\"%g\">\n", t->step.x, t->step.y); if (t->view.x0 > 0 || t->step.x < t->view.x1 || t->view.y0 > 0 || t->step.y < t->view.y1) { cp = sdev->id++; - fz_printf(ctx, out, "<clipPath id=\"cp%d\">\n", cp); - fz_printf(ctx, out, "<path d=\"M %g %g L %g %g L %g %g L %g %g Z\"/>\n", + fz_write_printf(ctx, out, "<clipPath id=\"cp%d\">\n", cp); + fz_write_printf(ctx, out, "<path d=\"M %g %g L %g %g L %g %g L %g %g Z\"/>\n", t->view.x0, t->view.y0, t->view.x1, t->view.y0, t->view.x1, t->view.y1, t->view.x0, t->view.y1); - fz_printf(ctx, out, "</clipPath>\n"); - fz_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", cp); + fz_write_printf(ctx, out, "</clipPath>\n"); + fz_write_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", cp); } /* All the pattern contents will have their own ctm applied. Let's * undo the current one to allow for this */ fz_invert_matrix(&inverse, &t->ctm); - fz_printf(ctx, out, "<g"); + fz_write_printf(ctx, out, "<g"); svg_dev_ctm(ctx, sdev, &inverse); - fz_printf(ctx, out, ">\n"); + fz_write_printf(ctx, out, ">\n"); w = t->view.x1 - t->view.x0; h = t->view.y1 - t->view.y0; for (x = 0; x > -w; x -= t->step.x) for (y = 0; y > -h; y -= t->step.y) - fz_printf(ctx, out, "<use x=\"%g\" y=\"%g\" xlink:href=\"#pac%d\"/>\n", x, y, t->pattern); + fz_write_printf(ctx, out, "<use x=\"%g\" y=\"%g\" xlink:href=\"#pac%d\"/>\n", x, y, t->pattern); - fz_printf(ctx, out, "</g>\n"); + fz_write_printf(ctx, out, "</g>\n"); if (cp != -1) - fz_printf(ctx, out, "</g>\n"); - fz_printf(ctx, out, "</pattern>\n"); + fz_write_printf(ctx, out, "</g>\n"); + fz_write_printf(ctx, out, "</pattern>\n"); out = end_def(ctx, sdev); /* Finally, fill a rectangle with the pattern. */ - fz_printf(ctx, out, "<rect"); + fz_write_printf(ctx, out, "<rect"); svg_dev_ctm(ctx, sdev, &t->ctm); - fz_printf(ctx, out, " fill=\"url(#pa%d)\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"/>\n", + fz_write_printf(ctx, out, " fill=\"url(#pa%d)\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"/>\n", t->pattern, t->area.x0, t->area.y0, t->area.x1 - t->area.x0, t->area.y1 - t->area.y0); } @@ -1228,7 +1228,7 @@ svg_dev_close_device(fz_context *ctx, fz_device *dev) { svg_device *sdev = (svg_device*)dev; fz_output *out = sdev->out; - fz_printf(ctx, out, "</svg>\n"); + fz_write_printf(ctx, out, "</svg>\n"); } static void @@ -1294,9 +1294,9 @@ fz_device *fz_new_svg_device(fz_context *ctx, fz_output *out, float page_width, dev->text_as_text = (text_format == FZ_SVG_TEXT_AS_TEXT); dev->reuse_images = reuse_images; - fz_printf(ctx, out, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); - fz_printf(ctx, out, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); - fz_printf(ctx, out, "<svg xmlns=\"http://www.w3.org/2000/svg\" " + fz_write_printf(ctx, out, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); + fz_write_printf(ctx, out, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); + fz_write_printf(ctx, out, "<svg xmlns=\"http://www.w3.org/2000/svg\" " "xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" " "width=\"%gpt\" height=\"%gpt\" viewBox=\"0 0 %g %g\">\n", page_width, page_height, page_width, page_height); |