From e9de14eb4d841071c15e8aea7bc5d463ceb59622 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 30 Oct 2007 22:00:59 -0700 Subject: [PATCH] Force non-AA text when using a bitmap strike with only scaling transform. When the current font size matches one of the available fixed sizes, and the overall transform has only scaling components, FreeType will use the fixed size bitmaps by default. For glyphs which do not have bitmaps, force them to be rendered in monochrome instead of anti-aliased so that they all match nicely. (cherry picked from commit 06af5c2891b89da28581c30afcde06c5442884db) --- src/cairo-ft-font.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 914dc0b60..804ecc2ea 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -1512,6 +1512,30 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t *unscaled, return NULL; } + /* + * Force non-AA drawing when using a bitmap strike that + * won't be resampled due to non-scaling transform + */ + if (!unscaled->have_shape && + (scaled_font->ft_options.load_flags & FT_LOAD_NO_BITMAP) == 0 && + scaled_font->ft_options.base.antialias != CAIRO_ANTIALIAS_NONE && + (face->face_flags & FT_FACE_FLAG_FIXED_SIZES)) + { + int i; + FT_Size_Metrics *size_metrics = &face->size->metrics; + + for (i = 0; i < face->num_fixed_sizes; i++) + { + FT_Bitmap_Size *bitmap_size = &face->available_sizes[i]; + + if (bitmap_size->x_ppem == size_metrics->x_ppem * 64 && + bitmap_size->y_ppem == size_metrics->y_ppem * 64) + { + scaled_font->ft_options.base.antialias = CAIRO_ANTIALIAS_NONE; + break; + } + } + } metrics = &face->size->metrics;