summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-10 10:23:41 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-10 13:07:03 +0000
commitc88fa306d0b23403aa70ada5a2f03817b85c5d7a (patch)
tree647651a941513ef42dfada697a6fe4844d6293a0
parent4e1a495e671cf423663a0c36a35fc4acc7d44754 (diff)
downloadmupdf-c88fa306d0b23403aa70ada5a2f03817b85c5d7a.tar.xz
Add minimum line width configuration option.
-rw-r--r--include/mupdf/fitz/context.h16
-rw-r--r--source/fitz/draw-device.c6
-rw-r--r--source/fitz/draw-edge.c19
3 files changed, 41 insertions, 0 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index 47aa8fa5..c84629e4 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -323,6 +323,22 @@ int fz_graphics_aa_level(fz_context *ctx);
void fz_set_graphics_aa_level(fz_context *ctx, int bits);
/*
+ fz_graphics_min_line_width: Get the minimum line width to be
+ used for stroked lines.
+
+ min_line_width: The minimum line width to use (in pixels).
+*/
+float fz_graphics_min_line_width(fz_context *ctx);
+
+/*
+ fz_set_graphics_min_line_width: Set the minimum line width to be
+ used for stroked lines.
+
+ min_line_width: The minimum line width to use (in pixels).
+*/
+void fz_set_graphics_min_line_width(fz_context *ctx, float min_line_width);
+
+/*
fz_user_css: Get the user stylesheet source text.
*/
const char *fz_user_css(fz_context *ctx);
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index d6d17782..d6d8c38e 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -350,10 +350,13 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const
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;
+ float mlw = fz_graphics_min_line_width(ctx);
if (colorspace == NULL && model != NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "color destination requires source color");
+ if (mlw > aa_level)
+ aa_level = mlw;
if (linewidth * expansion < aa_level)
linewidth = aa_level / expansion;
if (flatness < 0.001f)
@@ -500,7 +503,10 @@ fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path,
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
float aa_level = 2.0f/(fz_graphics_aa_level(ctx)+2);
+ float mlw = fz_graphics_min_line_width(ctx);
+ if (mlw > aa_level)
+ aa_level = mlw;
if (linewidth * expansion < aa_level)
linewidth = aa_level / expansion;
if (flatness < 0.001f)
diff --git a/source/fitz/draw-edge.c b/source/fitz/draw-edge.c
index 0da45331..4465d90a 100644
--- a/source/fitz/draw-edge.c
+++ b/source/fitz/draw-edge.c
@@ -23,6 +23,7 @@ struct fz_aa_context_s
int scale;
int bits;
int text_bits;
+ float min_line_width;
};
void fz_new_aa_context(fz_context *ctx)
@@ -205,6 +206,24 @@ fz_set_graphics_aa_level(fz_context *ctx, int level)
#endif
}
+void
+fz_set_graphics_min_line_width(fz_context *ctx, float min_line_width)
+{
+ if (!ctx || !ctx->aa)
+ return;
+
+ ctx->aa->min_line_width = min_line_width;
+}
+
+float
+fz_graphics_min_line_width(fz_context *ctx)
+{
+ if (!ctx || !ctx->aa)
+ return 0;
+
+ return ctx->aa->min_line_width;
+}
+
/*
* Global Edge List -- list of straight path segments for scan conversion
*