diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-07-17 18:15:54 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-07-17 18:15:54 +0200 |
commit | c47b3796f4f0314a86e4a82f7d467f8130c96b6c (patch) | |
tree | 25509ca71274251a50ab93e3779c9ba2c44250ef /draw/draw_device.c | |
parent | 4091b7a357728aed033216baafed540b795bcf9e (diff) | |
download | mupdf-c47b3796f4f0314a86e4a82f7d467f8130c96b6c.tar.xz |
Fall back to character path rendering if stroked text uses a dash pattern.
The FT_Stroker doesn't support dash patterns. Fall back to the normal
path rendering, same as with glyphs that are too big to fit the cache.
Diffstat (limited to 'draw/draw_device.c')
-rw-r--r-- | draw/draw_device.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c index 2eaf1d49..b4cc606e 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -524,7 +524,6 @@ fz_draw_fill_text(fz_device *devp, fz_text *text, fz_matrix ctm, fz_draw_fill_path(devp, path, 0, fz_identity, colorspace, color, alpha); fz_free_path(dev->ctx, path); } - else { fz_warn(dev->ctx, "cannot render glyph"); @@ -543,11 +542,12 @@ fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_ fz_draw_device *dev = devp->user; unsigned char colorbv[FZ_MAX_COLORS + 1]; float colorfv[FZ_MAX_COLORS]; - fz_matrix tm, trm; + fz_matrix tm, trm, trunc_trm; fz_pixmap *glyph; int i, x, y, gid; fz_draw_state *state = &dev->stack[dev->top]; fz_colorspace *model = state->dest->colorspace; + fz_bbox scissor = state->scissor; if (state->blendmode & FZ_BLEND_KNOCKOUT) state = fz_knockout_begin(dev); @@ -570,12 +570,15 @@ fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_ trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); - trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); - trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); - // TODO: dash state + trunc_trm = trm; + trunc_trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); + trunc_trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); + + scissor.x0 -= x; scissor.x1 -= x; + scissor.y0 -= y; scissor.y1 -= y; - glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trm, ctm, stroke, state->scissor); + glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trunc_trm, ctm, stroke, scissor); if (glyph) { draw_glyph(colorbv, state->dest, glyph, x, y, state->scissor); @@ -583,6 +586,19 @@ fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_ draw_glyph(colorbv, state->shape, glyph, x, y, state->scissor); fz_drop_pixmap(dev->ctx, glyph); } + else + { + fz_path *path = fz_outline_glyph(dev->ctx, text->font, gid, trm); + if (path) + { + fz_draw_stroke_path(devp, path, stroke, fz_identity, colorspace, color, alpha); + fz_free_path(dev->ctx, path); + } + else + { + fz_warn(dev->ctx, "cannot render glyph"); + } + } } if (state->blendmode & FZ_BLEND_KNOCKOUT) @@ -675,6 +691,11 @@ fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate) draw_glyph(NULL, state[1].shape, glyph, x, y, bbox); fz_drop_pixmap(dev->ctx, glyph); } + else + { + fz_warn(dev->ctx, "cannot draw glyph for clipping (unimplemented case)"); + // TODO: outline/non-cached case + } } } } @@ -742,6 +763,11 @@ fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke draw_glyph(NULL, shape, glyph, x, y, bbox); fz_drop_pixmap(dev->ctx, glyph); } + else + { + fz_warn(dev->ctx, "cannot draw glyph for clipping (unimplemented case)"); + // TODO: outline/non-cached case + } } } } |