[cairo-commit] src/cairo-ft-font.c

Keith Packard keithp at kemper.freedesktop.org
Tue Oct 30 22:03:03 PDT 2007


 src/cairo-ft-font.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

New commits:
commit 06af5c2891b89da28581c30afcde06c5442884db
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Tue Oct 30 22:00:59 2007 -0700

    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.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index e8e7d1a..4a8f9a4 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1506,6 +1506,30 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
 	goto FAIL;
     }
 
+    /*
+     * 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;
 


More information about the cairo-commit mailing list