summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-04-12 17:20:25 +0100
committerRobin Watts <robin.watts@artifex.com>2016-04-26 15:15:43 +0100
commit4ecec105b46a096bc2da097003ff0f3e9d4473a6 (patch)
tree50490dd6f3fd77b717955fab2ca910a4b6cc92d0 /source/fitz
parent26f4d19a9a575eb44a6fac44c3a991beee8b589d (diff)
downloadmupdf-4ecec105b46a096bc2da097003ff0f3e9d4473a6.tar.xz
Allow text/graphics aa levels to be controlled separately.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/draw-edge.c75
-rw-r--r--source/fitz/draw-glyph.c4
-rw-r--r--source/fitz/font.c4
3 files changed, 74 insertions, 9 deletions
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));