summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/context.h35
-rw-r--r--source/fitz/draw-edge.c75
-rw-r--r--source/fitz/draw-glyph.c4
-rw-r--r--source/fitz/font.c4
-rw-r--r--source/tools/mudraw.c21
5 files changed, 124 insertions, 15 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index 37bcd5ed..789efc0a 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -213,12 +213,13 @@ void *fz_user_context(fz_context *ctx);
/*
fz_aa_level: Get the number of bits of antialiasing we are
- using. Between 0 and 8.
+ using (for graphics). Between 0 and 8.
*/
int fz_aa_level(fz_context *ctx);
/*
- fz_set_aa_level: Set the number of bits of antialiasing we should use.
+ fz_set_aa_level: Set the number of bits of antialiasing we should
+ use (for both text and graphics).
bits: The number of bits of antialiasing to use (values are clamped
to within the 0 to 8 range).
@@ -226,6 +227,36 @@ int fz_aa_level(fz_context *ctx);
void fz_set_aa_level(fz_context *ctx, int bits);
/*
+ fz_text_aa_level: Get the number of bits of antialiasing we are
+ using for text. Between 0 and 8.
+*/
+int fz_text_aa_level(fz_context *ctx);
+
+/*
+ fz_set_text_aa_level: Set the number of bits of antialiasing we
+ should use for text.
+
+ bits: The number of bits of antialiasing to use (values are clamped
+ to within the 0 to 8 range).
+*/
+void fz_set_text_aa_level(fz_context *ctx, int bits);
+
+/*
+ fz_graphics_aa_level: Get the number of bits of antialiasing we are
+ using for graphics. Between 0 and 8.
+*/
+int fz_graphics_aa_level(fz_context *ctx);
+
+/*
+ fz_set_graphics_aa_level: Set the number of bits of antialiasing we
+ should use for graphics.
+
+ bits: The number of bits of antialiasing to use (values are clamped
+ to within the 0 to 8 range).
+*/
+void fz_set_graphics_aa_level(fz_context *ctx, int bits);
+
+/*
fz_user_css: Get the user stylesheet source text.
*/
const char *fz_user_css(fz_context *ctx);
diff --git a/source/fitz/draw-edge.c b/source/fitz/draw-edge.c
index ac6da414..6c104ff2 100644
--- a/source/fitz/draw-edge.c
+++ b/source/fitz/draw-edge.c
@@ -22,6 +22,7 @@ struct fz_aa_context_s
int vscale;
int scale;
int bits;
+ int text_bits;
};
void fz_new_aa_context(fz_context *ctx)
@@ -32,11 +33,13 @@ void fz_new_aa_context(fz_context *ctx)
ctx->aa->vscale = 15;
ctx->aa->scale = 256;
ctx->aa->bits = 8;
+ ctx->aa->text_bits = 8;
#define fz_aa_hscale (ctx->aa->hscale)
#define fz_aa_vscale (ctx->aa->vscale)
#define fz_aa_scale (ctx->aa->scale)
#define fz_aa_bits (ctx->aa->bits)
+#define fz_aa_text_bits (ctx->aa->text_bits)
#define AA_SCALE(scale, x) ((x * scale) >> 8)
#endif
@@ -65,30 +68,35 @@ void fz_drop_aa_context(fz_context *ctx)
#define fz_aa_hscale 17
#define fz_aa_vscale 15
#define fz_aa_bits 8
+#define fz_aa_text_bits 8
#elif AA_BITS > 4
#define AA_SCALE(s, x) ((x * 255) >> 6)
#define fz_aa_hscale 8
#define fz_aa_vscale 8
#define fz_aa_bits 6
+#define fz_aa_text_bits 6
#elif AA_BITS > 2
#define AA_SCALE(s, x) (x * 17)
#define fz_aa_hscale 5
#define fz_aa_vscale 3
#define fz_aa_bits 4
+#define fz_aa_text_bits 4
#elif AA_BITS > 0
#define AA_SCALE(s, x) ((x * 255) >> 2)
#define fz_aa_hscale 2
#define fz_aa_vscale 2
#define fz_aa_bits 2
+#define fz_aa_text_bits 2
#else
#define AA_SCALE(s, x) (x * 255)
#define fz_aa_hscale 1
#define fz_aa_vscale 1
#define fz_aa_bits 0
+#define fz_aa_text_bits 0
#endif
#endif
@@ -99,12 +107,22 @@ fz_aa_level(fz_context *ctx)
return fz_aa_bits;
}
-void
-fz_set_aa_level(fz_context *ctx, int level)
+int
+fz_graphics_aa_level(fz_context *ctx)
+{
+ return fz_aa_bits;
+}
+
+int
+fz_text_aa_level(fz_context *ctx)
+{
+ return fz_aa_text_bits;
+}
+
+#ifndef AA_BITS
+static void
+set_gfx_level(fz_context *ctx, int level)
{
-#ifdef AA_BITS
- fz_warn(ctx, "anti-aliasing was compiled with a fixed precision of %d bits", fz_aa_bits);
-#else
if (level > 6)
{
fz_aa_hscale = 17;
@@ -136,9 +154,56 @@ fz_set_aa_level(fz_context *ctx, int level)
fz_aa_bits = 0;
}
fz_aa_scale = 0xFF00 / (fz_aa_hscale * fz_aa_vscale);
+}
+
+static void
+set_txt_level(fz_context *ctx, int level)
+{
+ if (level > 6)
+ fz_aa_text_bits = 8;
+ else if (level > 4)
+ fz_aa_text_bits = 6;
+ else if (level > 2)
+ fz_aa_text_bits = 4;
+ else if (level > 0)
+ fz_aa_text_bits = 2;
+ else
+ fz_aa_text_bits = 0;
+}
+#endif /* AA_BITS */
+
+void
+fz_set_aa_level(fz_context *ctx, int level)
+{
+#ifdef AA_BITS
+ fz_warn(ctx, "anti-aliasing was compiled with a fixed precision of %d bits", fz_aa_bits);
+#else
+ set_gfx_level(ctx, level);
+ set_txt_level(ctx, level);
#endif
}
+void
+fz_set_text_aa_level(fz_context *ctx, int level)
+{
+#ifdef AA_BITS
+ fz_warn(ctx, "anti-aliasing was compiled with a fixed precision of %d bits", fz_aa_bits);
+#else
+ set_txt_level(ctx, level);
+#endif
+}
+
+void
+fz_set_graphics_aa_level(fz_context *ctx, int level)
+{
+#ifdef AA_BITS
+ fz_warn(ctx, "anti-aliasing was compiled with a fixed precision of %d bits", fz_aa_bits);
+#else
+ set_gfx_level(ctx, level);
+#endif
+}
+
+
/*
* Global Edge List -- list of straight path segments for scan conversion
*
diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c
index 5445ee4d..691e426d 100644
--- a/source/fitz/draw-glyph.c
+++ b/source/fitz/draw-glyph.c
@@ -284,7 +284,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo
key.b = subpix_ctm.b * 65536;
key.c = subpix_ctm.c * 65536;
key.d = subpix_ctm.d * 65536;
- key.aa = fz_aa_level(ctx);
+ key.aa = fz_text_aa_level(ctx);
fz_lock(ctx, FZ_LOCK_GLYPHCACHE);
hash = do_hash((unsigned char *)&key, sizeof(key)) % GLYPH_HASH_LEN;
@@ -428,7 +428,7 @@ fz_render_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm,
{
if (font->ft_face)
{
- val = fz_render_ft_glyph_pixmap(ctx, font, gid, &subpix_ctm, fz_aa_level(ctx));
+ val = fz_render_ft_glyph_pixmap(ctx, font, gid, &subpix_ctm, fz_text_aa_level(ctx));
}
else if (font->t3procs)
{
diff --git a/source/fitz/font.c b/source/fitz/font.c
index c274995b..e67f64dc 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -643,7 +643,7 @@ retry_unhinted:
FT_Outline_Translate(&face->glyph->outline, -strength * 32, -strength * 32);
}
- fterr = FT_Render_Glyph(face->glyph, fz_aa_level(ctx) > 0 ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO);
+ fterr = FT_Render_Glyph(face->glyph, fz_text_aa_level(ctx) > 0 ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO);
if (fterr)
{
fz_warn(ctx, "freetype render glyph (gid %d): %s", gid, ft_error_string(fterr));
@@ -794,7 +794,7 @@ do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_mat
FT_Stroker_Done(stroker);
- fterr = FT_Glyph_To_Bitmap(&glyph, fz_aa_level(ctx) > 0 ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO, 0, 1);
+ fterr = FT_Glyph_To_Bitmap(&glyph, fz_text_aa_level(ctx) > 0 ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO, 0, 1);
if (fterr)
{
fz_warn(ctx, "FT_Glyph_To_Bitmap: %s", ft_error_string(fterr));
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 1effc070..0907ffa8 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -269,7 +269,8 @@ static pdf_document *pdfout = NULL;
static int ignore_errors = 0;
static int uselist = 1;
-static int alphabits = 8;
+static int alphabits_text = 8;
+static int alphabits_graphics = 8;
static int out_cs = CS_UNSET;
static float gamma_value = 1;
@@ -332,6 +333,7 @@ static void usage(void)
"\t-I\tinvert colors\n"
"\n"
"\t-A -\tnumber of bits of antialiasing (0 to 8)\n"
+ "\t-A -/-\tnumber of bits of antialiasing (0 to 8) (graphics, text)\n"
"\t-D\tdisable use of display list\n"
"\t-i\tignore errors\n"
"\t-L\tlow memory mode (avoid caching, clear objects after each page)\n"
@@ -447,7 +449,7 @@ static void drawband(fz_context *ctx, int savealpha, fz_page *page, fz_display_l
dev = fz_new_draw_device(ctx, pix);
if (lowmemory)
fz_enable_device_hints(ctx, dev, FZ_NO_CACHE);
- if (alphabits == 0)
+ if (alphabits_graphics == 0)
fz_enable_device_hints(ctx, dev, FZ_DONT_INTERPOLATE_IMAGES);
if (list)
fz_run_display_list(ctx, list, dev, ctm, tbounds, cookie);
@@ -1205,7 +1207,17 @@ int mudraw_main(int argc, char **argv)
if (strchr(fz_optarg, '5')) ++showmd5;
break;
- case 'A': alphabits = atoi(fz_optarg); break;
+ case 'A':
+ {
+ char *sep;
+ alphabits_graphics = atoi(fz_optarg);
+ sep = strchr(fz_optarg, '/');
+ if (sep)
+ alphabits_text = atoi(sep+1);
+ else
+ alphabits_text = alphabits_graphics;
+ break;
+ }
case 'D': uselist = 0; break;
case 'i': ignore_errors = 1; break;
@@ -1259,7 +1271,8 @@ int mudraw_main(int argc, char **argv)
}
}
- fz_set_aa_level(ctx, alphabits);
+ fz_set_text_aa_level(ctx, alphabits_text);
+ fz_set_graphics_aa_level(ctx, alphabits_graphics);
if (layout_css)
{