diff options
-rw-r--r-- | include/fitz/draw_path.h | 4 | ||||
-rw-r--r-- | raster/pathstroke.c | 8 | ||||
-rw-r--r-- | raster/render.c | 12 |
3 files changed, 15 insertions, 9 deletions
diff --git a/include/fitz/draw_path.h b/include/fitz/draw_path.h index 9091c776..8ca7f6e1 100644 --- a/include/fitz/draw_path.h +++ b/include/fitz/draw_path.h @@ -40,6 +40,6 @@ fz_error *fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_irect clip, fz_pixmap *pix, unsigned char *argb, int over); fz_error *fz_fillpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness); -fz_error *fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness); -fz_error *fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness); +fz_error *fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth); +fz_error *fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth); diff --git a/raster/pathstroke.c b/raster/pathstroke.c index f1afb825..cafcd663 100644 --- a/raster/pathstroke.c +++ b/raster/pathstroke.c @@ -458,7 +458,7 @@ strokebezier(struct sctx *s, } fz_error * -fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness) +fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth) { fz_error *error; struct sctx s; @@ -471,7 +471,7 @@ fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness) s.linecap = path->linecap; s.linejoin = path->linejoin; - s.linewidth = path->linewidth * 0.5; + s.linewidth = linewidth * 0.5; /* hairlines use a different value from the path value */ s.miterlimit = path->miterlimit; s.sn = 0; s.bn = 0; @@ -653,7 +653,7 @@ dashbezier(struct sctx *s, } fz_error * -fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness) +fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth) { fz_error *error; struct sctx s; @@ -666,7 +666,7 @@ fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness) s.linecap = path->linecap; s.linejoin = path->linejoin; - s.linewidth = path->linewidth * 0.5; + s.linewidth = linewidth * 0.5; s.miterlimit = path->miterlimit; s.sn = 0; s.bn = 0; diff --git a/raster/render.c b/raster/render.c index 4e010179..596bedab 100644 --- a/raster/render.c +++ b/raster/render.c @@ -187,8 +187,9 @@ renderpath(fz_renderer *gc, fz_pathnode *path, fz_matrix ctm) float flatness; fz_irect gbox; fz_irect clip; + float expansion = fz_matrixexpansion(ctm); - flatness = 0.3 / fz_matrixexpansion(ctm); + flatness = 0.3 / expansion; if (flatness < 0.1) flatness = 0.1; @@ -196,10 +197,15 @@ renderpath(fz_renderer *gc, fz_pathnode *path, fz_matrix ctm) if (path->paint == FZ_STROKE) { + float lw = path->linewidth; + // Check for hairline + if (lw * expansion < 0.2) { + lw = 1.0f / expansion; + } if (path->dash) - error = fz_dashpath(gc->gel, path, ctm, flatness); + error = fz_dashpath(gc->gel, path, ctm, flatness, lw); else - error = fz_strokepath(gc->gel, path, ctm, flatness); + error = fz_strokepath(gc->gel, path, ctm, flatness, lw); } else error = fz_fillpath(gc->gel, path, ctm, flatness); |