diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-05-09 20:01:37 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-05-10 18:44:57 +0100 |
commit | 81626cb122701420a15dae49ed0e7ec3c442e9d3 (patch) | |
tree | 05c3366c61889c99a2640fa8b398c83adb6f6af9 /fitz | |
parent | 6d869a15eb33bdda06a737d2af6c04139e2b3bfe (diff) | |
download | mupdf-81626cb122701420a15dae49ed0e7ec3c442e9d3.tar.xz |
Update fz_bound_{text,path} functions.
Pass stroke state into fz_bound_text to allow for stroked text.
Simplifies some calling code.
Add consts to clarify the meanings of the calls.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/dev_bbox.c | 4 | ||||
-rw-r--r-- | fitz/dev_list.c | 12 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 6 | ||||
-rw-r--r-- | fitz/res_path.c | 4 | ||||
-rw-r--r-- | fitz/res_text.c | 6 |
5 files changed, 17 insertions, 15 deletions
diff --git a/fitz/dev_bbox.c b/fitz/dev_bbox.c index 14372abe..94c88144 100644 --- a/fitz/dev_bbox.c +++ b/fitz/dev_bbox.c @@ -26,7 +26,7 @@ fz_bbox_fill_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, { fz_rect *result = dev->user; fz_rect r; - fz_union_rect(result, fz_bound_text(dev->ctx, text, ctm, &r)); + fz_union_rect(result, fz_bound_text(dev->ctx, text, NULL, ctm, &r)); } static void @@ -35,7 +35,7 @@ fz_bbox_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, { fz_rect *result = dev->user; fz_rect r; - fz_union_rect(result, fz_bound_text(dev->ctx, text, ctm, &r)); + fz_union_rect(result, fz_bound_text(dev->ctx, text, stroke, ctm, &r)); } static void diff --git a/fitz/dev_list.c b/fitz/dev_list.c index bd96381d..826d0c46 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -314,7 +314,7 @@ fz_list_fill_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, node = fz_new_display_node(ctx, FZ_CMD_FILL_TEXT, ctm, colorspace, color, alpha); fz_try(ctx) { - fz_bound_text(dev->ctx, text, ctm, &node->rect); + fz_bound_text(dev->ctx, text, NULL, ctm, &node->rect); node->item.text = fz_clone_text(dev->ctx, text); } fz_catch(ctx) @@ -335,8 +335,7 @@ fz_list_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, cons node->item.text = NULL; fz_try(ctx) { - fz_bound_text(dev->ctx, text, ctm, &node->rect); - fz_adjust_rect_for_stroke(&node->rect, stroke, ctm); + fz_bound_text(dev->ctx, text, stroke, ctm, &node->rect); node->item.text = fz_clone_text(dev->ctx, text); node->stroke = fz_keep_stroke_state(dev->ctx, stroke); } @@ -356,7 +355,7 @@ fz_list_clip_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, int accum node = fz_new_display_node(ctx, FZ_CMD_CLIP_TEXT, ctm, NULL, NULL, 0); fz_try(ctx) { - fz_bound_text(dev->ctx, text, ctm, &node->rect); + fz_bound_text(dev->ctx, text, NULL, ctm, &node->rect); node->item.text = fz_clone_text(dev->ctx, text); node->flag = accumulate; /* when accumulating, be conservative about culling */ @@ -379,8 +378,7 @@ fz_list_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, node = fz_new_display_node(ctx, FZ_CMD_CLIP_STROKE_TEXT, ctm, NULL, NULL, 0); fz_try(ctx) { - fz_bound_text(dev->ctx, text, ctm, &node->rect); - fz_adjust_rect_for_stroke(&node->rect, stroke, ctm); + fz_bound_text(dev->ctx, text, stroke, ctm, &node->rect); node->item.text = fz_clone_text(dev->ctx, text); node->stroke = fz_keep_stroke_state(dev->ctx, stroke); } @@ -400,7 +398,7 @@ fz_list_ignore_text(fz_device *dev, fz_text *text, const fz_matrix *ctm) node = fz_new_display_node(ctx, FZ_CMD_IGNORE_TEXT, ctm, NULL, NULL, 0); fz_try(ctx) { - fz_bound_text(dev->ctx, text, ctm, &node->rect); + fz_bound_text(dev->ctx, text, NULL, ctm, &node->rect); node->item.text = fz_clone_text(dev->ctx, text); } fz_catch(ctx) diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index 17a919d3..22947cf4 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -1202,8 +1202,8 @@ void fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *transfor 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, const fz_matrix *ctm, fz_rect *r); -fz_rect *fz_adjust_rect_for_stroke(fz_rect *r, fz_stroke_state *stroke, const fz_matrix *ctm); +fz_rect *fz_bound_path(fz_context *ctx, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r); +fz_rect *fz_adjust_rect_for_stroke(fz_rect *r, const fz_stroke_state *stroke, const fz_matrix *ctm); fz_stroke_state *fz_new_stroke_state(fz_context *ctx); fz_stroke_state *fz_new_stroke_state_with_len(fz_context *ctx, int len); @@ -1304,7 +1304,7 @@ struct fz_text_s fz_text *fz_new_text(fz_context *ctx, fz_font *face, const fz_matrix *trm, int wmode); void fz_add_text(fz_context *ctx, fz_text *text, int gid, int ucs, float x, float y); void fz_free_text(fz_context *ctx, fz_text *text); -fz_rect *fz_bound_text(fz_context *ctx, fz_text *text, const fz_matrix *ctm, fz_rect *r); +fz_rect *fz_bound_text(fz_context *ctx, fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r); fz_text *fz_clone_text(fz_context *ctx, fz_text *old); void fz_print_text(fz_context *ctx, FILE *out, fz_text*); diff --git a/fitz/res_path.c b/fitz/res_path.c index f8d1e8ce..b2e4f6f5 100644 --- a/fitz/res_path.c +++ b/fitz/res_path.c @@ -253,7 +253,7 @@ static inline fz_rect *bound_expand(fz_rect *r, const fz_point *p) } fz_rect * -fz_bound_path(fz_context *ctx, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r) +fz_bound_path(fz_context *ctx, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r) { fz_point p; int i = 0; @@ -321,7 +321,7 @@ fz_bound_path(fz_context *ctx, fz_path *path, fz_stroke_state *stroke, const fz_ } fz_rect * -fz_adjust_rect_for_stroke(fz_rect *r, fz_stroke_state *stroke, const fz_matrix *ctm) +fz_adjust_rect_for_stroke(fz_rect *r, const fz_stroke_state *stroke, const fz_matrix *ctm) { float expand; diff --git a/fitz/res_text.c b/fitz/res_text.c index 09a658b1..57e02cf9 100644 --- a/fitz/res_text.c +++ b/fitz/res_text.c @@ -53,7 +53,7 @@ fz_clone_text(fz_context *ctx, fz_text *old) } fz_rect * -fz_bound_text(fz_context *ctx, fz_text *text, const fz_matrix *ctm, fz_rect *bbox) +fz_bound_text(fz_context *ctx, fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *bbox) { fz_matrix tm, trm; fz_rect gbox; @@ -90,12 +90,16 @@ fz_bound_text(fz_context *ctx, fz_text *text, const fz_matrix *ctm, fz_rect *bbo } } + if (stroke) + fz_adjust_rect_for_stroke(bbox, stroke, ctm); + /* Compensate for the glyph cache limited positioning precision */ bbox->x0 -= 1; bbox->y0 -= 1; bbox->x1 += 1; bbox->y1 += 1; + return bbox; } |