From bf9d830adbca9978f82439af7f9b742d00d97214 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 27 Jun 2012 19:43:37 +0100 Subject: Fix clipping of stroked text seen in displaylist cases. When calculating the displaylist node rectangles, we were failing to adjust for linewidth/mitrewidth etc. This could result in glyphs being clipped; see normal_130.pdf for example. --- fitz/dev_list.c | 2 ++ fitz/fitz-internal.h | 1 + fitz/res_path.c | 30 ++++++++++++++++++++---------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/fitz/dev_list.c b/fitz/dev_list.c index d84fb15b..560fb5c6 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -334,6 +334,7 @@ fz_list_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_m fz_try(ctx) { node->rect = fz_bound_text(dev->ctx, text, ctm); + fz_adjust_rect_for_stroke(&node->rect, stroke, &ctm); node->item.text = fz_clone_text(dev->ctx, text); node->stroke = fz_keep_stroke_state(dev->ctx, stroke); } @@ -377,6 +378,7 @@ fz_list_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_try(ctx) { node->rect = fz_bound_text(dev->ctx, text, ctm); + fz_adjust_rect_for_stroke(&node->rect, stroke, &ctm); node->item.text = fz_clone_text(dev->ctx, text); node->stroke = fz_keep_stroke_state(dev->ctx, stroke); } diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index 2f7f8041..6fc40f49 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -814,6 +814,7 @@ void fz_transform_path(fz_context *ctx, fz_path *path, fz_matrix transform); fz_path *fz_clone_path(fz_context *ctx, fz_path *old); fz_rect fz_bound_path(fz_context *ctx, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm); +void fz_adjust_rect_for_stroke(fz_rect *r, fz_stroke_state *stroke, fz_matrix *ctm); void fz_print_path(fz_context *ctx, FILE *out, fz_path *, int indent); fz_stroke_state *fz_new_stroke_state(fz_context *ctx); diff --git a/fitz/res_path.c b/fitz/res_path.c index e3f07192..b8a6a1a2 100644 --- a/fitz/res_path.c +++ b/fitz/res_path.c @@ -275,21 +275,31 @@ fz_bound_path(fz_context *ctx, fz_path *path, fz_stroke_state *stroke, fz_matrix if (stroke) { - float expand = stroke->linewidth; - if (expand == 0) - expand = 1.0f; - expand *= fz_matrix_max_expansion(ctm); - if ((stroke->linejoin == FZ_LINEJOIN_MITER || stroke->linejoin == FZ_LINEJOIN_MITER_XPS) && stroke->miterlimit > 1) - expand *= stroke->miterlimit; - r.x0 -= expand; - r.y0 -= expand; - r.x1 += expand; - r.y1 += expand; + fz_adjust_rect_for_stroke(&r, stroke, &ctm); } return r; } +void +fz_adjust_rect_for_stroke(fz_rect *r, fz_stroke_state *stroke, fz_matrix *ctm) +{ + float expand; + + if (!stroke) + return; + expand = stroke->linewidth; + if (expand == 0) + expand = 1.0f; + expand *= fz_matrix_max_expansion(*ctm); + if ((stroke->linejoin == FZ_LINEJOIN_MITER || stroke->linejoin == FZ_LINEJOIN_MITER_XPS) && stroke->miterlimit > 1) + expand *= stroke->miterlimit; + r->x0 -= expand; + r->y0 -= expand; + r->x1 += expand; + r->y1 += expand; +} + void fz_transform_path(fz_context *ctx, fz_path *path, fz_matrix ctm) { -- cgit v1.2.3