diff options
-rw-r--r-- | source/pdf/pdf-op-run.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c index faed37a5..dbd9386d 100644 --- a/source/pdf/pdf-op-run.c +++ b/source/pdf/pdf-op-run.c @@ -722,6 +722,7 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr) int doclip; int doinvisible; softmask_save softmask = { NULL }; + int knockout_group = 0; if (!pr->text) return gstate; @@ -749,6 +750,8 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr) fz_rect tb = pr->text_bbox; fz_transform_rect(&tb, &gstate->ctm); + if (dostroke) + fz_adjust_rect_for_stroke(ctx, &tb, gstate->stroke_state, &gstate->ctm); /* Don't bother sending a text group with nothing in it */ if (text->len == 0) @@ -757,6 +760,24 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr) if (dofill || dostroke) gstate = pdf_begin_group(ctx, pr, &tb, &softmask); + if (dofill && dostroke) + { + /* We may need to push a knockout group */ + if (gstate->stroke.alpha == 0) + { + /* No need for group, as stroke won't do anything */ + } + else if (gstate->stroke.alpha == 1.0f && gstate->blendmode == FZ_BLEND_NORMAL) + { + /* No need for group, as stroke won't show up */ + } + else + { + knockout_group = 1; + fz_begin_group(ctx, pr->dev, &tb, 0, 1, FZ_BLEND_NORMAL, 1); + } + } + if (doinvisible) fz_ignore_text(ctx, pr->dev, text, &gstate->ctm); @@ -819,6 +840,9 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr) } } + if (knockout_group) + fz_end_group(ctx, pr->dev); + if (dofill || dostroke) pdf_end_group(ctx, pr, &softmask); |