summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-07-17 18:15:54 +0200
committerTor Andersson <tor.andersson@artifex.com>2012-07-17 18:15:54 +0200
commitc47b3796f4f0314a86e4a82f7d467f8130c96b6c (patch)
tree25509ca71274251a50ab93e3779c9ba2c44250ef /draw
parent4091b7a357728aed033216baafed540b795bcf9e (diff)
downloadmupdf-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')
-rw-r--r--draw/draw_device.c38
-rw-r--r--draw/draw_glyph.c4
2 files changed, 36 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
+ }
}
}
}
diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c
index e7e7f03a..de2f47c2 100644
--- a/draw/draw_glyph.c
+++ b/draw/draw_glyph.c
@@ -98,7 +98,11 @@ fz_pixmap *
fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke, fz_bbox scissor)
{
if (font->ft_face)
+ {
+ if (stroke->dash_len > 0)
+ return NULL;
return fz_render_ft_stroked_glyph(ctx, font, gid, trm, ctm, stroke);
+ }
return fz_render_glyph(ctx, font, gid, trm, NULL, scissor);
}