From fa0bffa57e7e2164f0201b0f2fdc984d475674ae Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 9 Oct 2015 11:07:42 +0200 Subject: Keep spans of multiple fonts and sizes in one fz_text object. --- source/fitz/trace-device.c | 76 ++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 39 deletions(-) (limited to 'source/fitz/trace-device.c') diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c index 59ea8ad8..df2f6455 100644 --- a/source/fitz/trace-device.c +++ b/source/fitz/trace-device.c @@ -13,13 +13,6 @@ fz_trace_matrix(fz_context *ctx, fz_output *out, const fz_matrix *ctm) ctm->a, ctm->b, ctm->c, ctm->d, ctm->e, ctm->f); } -static void -fz_trace_trm(fz_context *ctx, fz_output *out, const fz_matrix *trm) -{ - fz_printf(ctx, out, " trm=\"%g %g %g %g\"", - trm->a, trm->b, trm->c, trm->d); -} - static void fz_trace_color(fz_context *ctx, fz_output *out, fz_colorspace *colorspace, float *color, float alpha) { @@ -32,6 +25,38 @@ fz_trace_color(fz_context *ctx, fz_output *out, fz_colorspace *colorspace, float fz_printf(ctx, out, " alpha=\"%g\"", alpha); } +static int +isxmlmeta(int c) +{ + return c < 32 || c >= 128 || c == '&' || c == '<' || c == '>' || c == '\'' || c == '"'; +} + +static void +fz_trace_text_span(fz_context *ctx, fz_output *out, fz_text_span *span) +{ + int i; + fz_printf(ctx, out, "font->name, span->wmode); + fz_printf(ctx, out, " trm=\"%g %g %g %g\">\n", span->trm.a, span->trm.b, span->trm.c, span->trm.d); + for (i = 0; i < span->len; i++) + { + if (!isxmlmeta(span->items[i].ucs)) + fz_printf(ctx, out, "\n", + span->items[i].ucs, span->items[i].gid, span->items[i].x, span->items[i].y); + else + fz_printf(ctx, out, "\n", + span->items[i].ucs, span->items[i].gid, span->items[i].x, span->items[i].y); + } + fz_printf(ctx, out, "\n"); +} + +static void +fz_trace_text(fz_context *ctx, fz_output *out, fz_text *text) +{ + fz_text_span *span; + for (span = text->head; span; span = span->next) + fz_trace_text_span(ctx, out, span); +} + static void trace_moveto(fz_context *ctx, void *arg, float x, float y) { @@ -166,36 +191,14 @@ fz_trace_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_printf(ctx, out, "\n"); } -static int -isxmlmeta(int c) -{ - return c < 32 || c >= 128 || c == '&' || c == '<' || c == '>' || c == '\'' || c == '"'; -} - -static void -fz_trace_text(fz_context *ctx, fz_output *out, fz_text *text) -{ - int i; - for (i = 0; i < text->len; i++) - { - if (!isxmlmeta(text->items[i].ucs)) - fz_printf(ctx, out, "\n", - text->items[i].ucs, text->items[i].gid, text->items[i].x, text->items[i].y); - else - fz_printf(ctx, out, "\n", - text->items[i].ucs, text->items[i].gid, text->items[i].x, text->items[i].y); - } -} - static void fz_trace_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_output *out = ((fz_trace_device*)dev)->out; - fz_printf(ctx, out, "font->name, text->wmode); + fz_printf(ctx, out, "trm); fz_printf(ctx, out, ">\n"); fz_trace_text(ctx, out, text); fz_printf(ctx, out, "\n"); @@ -206,10 +209,9 @@ fz_trace_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_s fz_colorspace *colorspace, float *color, float alpha) { fz_output *out = ((fz_trace_device*)dev)->out; - fz_printf(ctx, out, "font->name, text->wmode); + fz_printf(ctx, out, "trm); fz_printf(ctx, out, ">\n"); fz_trace_text(ctx, out, text); fz_printf(ctx, out, "\n"); @@ -219,10 +221,8 @@ static void fz_trace_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate) { fz_output *out = ((fz_trace_device*)dev)->out; - fz_printf(ctx, out, "font->name, text->wmode); - fz_printf(ctx, out, " accumulate=\"%d\"", accumulate); + fz_printf(ctx, out, "trm); fz_printf(ctx, out, ">\n"); fz_trace_text(ctx, out, text); fz_printf(ctx, out, "\n"); @@ -232,9 +232,8 @@ static void fz_trace_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm) { fz_output *out = ((fz_trace_device*)dev)->out; - fz_printf(ctx, out, "font->name, text->wmode); + fz_printf(ctx, out, "trm); fz_printf(ctx, out, ">\n"); fz_trace_text(ctx, out, text); fz_printf(ctx, out, "\n"); @@ -244,9 +243,8 @@ static void fz_trace_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm) { fz_output *out = ((fz_trace_device*)dev)->out; - fz_printf(ctx, out, "font->name, text->wmode); + fz_printf(ctx, out, "trm); fz_printf(ctx, out, ">\n"); fz_trace_text(ctx, out, text); fz_printf(ctx, out, "\n"); -- cgit v1.2.3