From c88fa306d0b23403aa70ada5a2f03817b85c5d7a Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 10 Nov 2016 10:23:41 +0000 Subject: Add minimum line width configuration option. --- include/mupdf/fitz/context.h | 16 ++++++++++++++++ source/fitz/draw-device.c | 6 ++++++ source/fitz/draw-edge.c | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+) 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 @@ -322,6 +322,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. */ 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 * -- cgit v1.2.3