summaryrefslogtreecommitdiff
path: root/source/fitz/draw-device.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-05-03 15:29:24 +0100
committerRobin Watts <robin.watts@artifex.com>2016-05-04 16:07:36 +0100
commitafe9bc8f64fedf69014a6d9f8efe2731778d7fe2 (patch)
tree9a967e1d61c33cbc252d4bc8c10c3af6d976fbab /source/fitz/draw-device.c
parentce55bef1c70836a2b1f8b6543528d83417719e4f (diff)
downloadmupdf-afe9bc8f64fedf69014a6d9f8efe2731778d7fe2.tar.xz
Make minimum line thickness dependent on AA level.
The PDF spec says that line thickness of 0 should mean "1 device pixel". We have been doing some dodgy logic where if the line thickness as scaled by the ctm is small (< 0.1f), make it at least 1 device pixel. This can mean that a line can not qualify for being thickened at 36dpi, but can be thickened at 24dpi. The thickened line at 24dpi is much thicker than the unthickened line at 36dpi, meaning that we get a noticable shift in rendering. Why do we do this strange logic? Well, presumably it's to avoid thin lines dropping out completely. We therefore move to some new logic. Firstly, we create a fudged 'aa_level' value, dependent on the antialias level. With AA level 0 (no antialiasing), this corresponds to 1 device pixel. For maximum AA level (8), this corresponds to 1/5 of a device pixel. Thus we should get 'continuous' results across different dpis.
Diffstat (limited to 'source/fitz/draw-device.c')
-rw-r--r--source/fitz/draw-device.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index c32b8f60..5b512c44 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -332,14 +332,15 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const
float colorfv[FZ_MAX_COLORS];
fz_irect bbox;
int i;
+ float aa_level = 2.0f/(fz_graphics_aa_level(ctx)+2);
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
if (model == NULL)
model = fz_device_gray(ctx);
- if (linewidth * expansion < 0.1f)
- linewidth = 1 / expansion;
+ if (linewidth * expansion < aa_level)
+ linewidth = aa_level / expansion;
if (flatness < 0.001f)
flatness = 0.001f;
@@ -459,9 +460,10 @@ fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path,
fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
+ float aa_level = 2.0f/(fz_graphics_aa_level(ctx)+2);
- if (linewidth * expansion < 0.1f)
- linewidth = 1 / expansion;
+ if (linewidth * expansion < aa_level)
+ linewidth = aa_level / expansion;
if (flatness < 0.001f)
flatness = 0.001f;