diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-06-27 19:43:37 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-06-27 19:43:37 +0100 |
commit | bf9d830adbca9978f82439af7f9b742d00d97214 (patch) | |
tree | 06c24666c836e37576b89927de8d4c4c2d4aaa6e | |
parent | 471b33850c85cd5e3d710f490a30f86655519084 (diff) | |
download | mupdf-bf9d830adbca9978f82439af7f9b742d00d97214.tar.xz |
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.
-rw-r--r-- | fitz/dev_list.c | 2 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 1 | ||||
-rw-r--r-- | 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,22 +275,32 @@ 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) { fz_point p; |