summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2014-07-18 22:15:12 +0200
committerTor Andersson <tor.andersson@artifex.com>2014-08-19 17:09:11 +0200
commita27c538cc3262377166251c73c9b09ff7f67192b (patch)
tree6fd8c99dd2d244f5a751c6ae144f533a4555c816
parentdac6ec31abd2a4e19f1bee26b95bcbb508522bf1 (diff)
downloadmupdf-a27c538cc3262377166251c73c9b09ff7f67192b.tar.xz
don't render non-empty dashing with zero-length phase
Adobe Reader and Microsoft XPS viewer differ in their handling of non-empty dashed strokes where the phase is 0: Adobe Reader considers these to be faulty and omits them while Microsoft XPS Viewer renders them the same as an empty dash (i.e. solid). This patch makes Fitz no longer render such strokes and ensures that MuXPS never emits them so that the desired behavior results (this is the easier implementation since XPS rendering code renders stroked paths in a single location whereas PDF rendering does it all over the place). See https://code.google.com/p/sumatrapdf/issues/detail?id=2339 for a testcase.
-rw-r--r--source/fitz/draw-path.c2
-rw-r--r--source/xps/xps-path.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c
index b1bcb11b..d184fad2 100644
--- a/source/fitz/draw-path.c
+++ b/source/fitz/draw-path.c
@@ -980,6 +980,8 @@ fz_flatten_dash_path(fz_gel *gel, fz_path *path, const fz_stroke_state *stroke,
phase_len = 0;
for (i = 0; i < stroke->dash_len; i++)
phase_len += stroke->dash_list[i];
+ if (stroke->dash_len > 0 && phase_len == 0)
+ return;
fz_gel_scissor(gel, &s.rect);
if (fz_try_invert_matrix(&inv, ctm))
return;
diff --git a/source/xps/xps-path.c b/source/xps/xps-path.c
index 84ee53f0..7b71575f 100644
--- a/source/xps/xps-path.c
+++ b/source/xps/xps-path.c
@@ -957,6 +957,16 @@ xps_parse_path(xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_reso
while (*s && *s != ' ')
s++;
}
+ if (dash_len > 0)
+ {
+ /* fz_stroke_path doesn't draw non-empty paths with phase length zero */
+ float phase_len = 0;
+ int i;
+ for (i = 0; i < dash_len; i++)
+ phase_len += stroke->dash_list[i];
+ if (phase_len == 0)
+ dash_len = 0;
+ }
stroke->dash_len = dash_len;
}
}