summaryrefslogtreecommitdiff
path: root/draw/draw_device.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-07-17 18:05:05 +0200
committerTor Andersson <tor.andersson@artifex.com>2012-07-17 18:05:05 +0200
commit4091b7a357728aed033216baafed540b795bcf9e (patch)
treead0cd73cc428bc8922d1eaa94663479c04192edb /draw/draw_device.c
parent2b857ab9878d5ca8acd862ae58dafa8d269bc502 (diff)
downloadmupdf-4091b7a357728aed033216baafed540b795bcf9e.tar.xz
Handle glyphs that are too large to render as pixmaps.
Diffstat (limited to 'draw/draw_device.c')
-rw-r--r--draw/draw_device.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 6f74eabf..2eaf1d49 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -463,11 +463,12 @@ fz_draw_fill_text(fz_device *devp, fz_text *text, fz_matrix ctm,
unsigned char colorbv[FZ_MAX_COLORS + 1];
unsigned char shapebv;
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);
@@ -491,10 +492,15 @@ fz_draw_fill_text(fz_device *devp, fz_text *text, fz_matrix ctm,
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);
- glyph = fz_render_glyph(dev->ctx, text->font, gid, trm, model);
+ 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_glyph(dev->ctx, text->font, gid, trunc_trm, model, scissor);
if (glyph)
{
if (glyph->n == 1)
@@ -510,6 +516,20 @@ fz_draw_fill_text(fz_device *devp, fz_text *text, fz_matrix ctm,
}
fz_drop_pixmap(dev->ctx, glyph);
}
+ else
+ {
+ fz_path *path = fz_outline_glyph(dev->ctx, text->font, gid, trm);
+ if (path)
+ {
+ 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");
+ }
+ }
}
if (state->blendmode & FZ_BLEND_KNOCKOUT)
@@ -553,7 +573,9 @@ fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trm, ctm, stroke);
+ // TODO: dash state
+
+ glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trm, ctm, stroke, state->scissor);
if (glyph)
{
draw_glyph(colorbv, state->dest, glyph, x, y, state->scissor);
@@ -645,7 +667,7 @@ fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate)
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_glyph(dev->ctx, text->font, gid, trm, model);
+ glyph = fz_render_glyph(dev->ctx, text->font, gid, trm, model, bbox);
if (glyph)
{
draw_glyph(NULL, mask, glyph, x, y, bbox);
@@ -712,7 +734,7 @@ fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trm, ctm, stroke);
+ glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trm, ctm, stroke, bbox);
if (glyph)
{
draw_glyph(NULL, mask, glyph, x, y, bbox);