diff options
author | Sven Neumann <sven@gimp.org> | 2003-04-03 11:13:18 +0000 |
---|---|---|
committer | Sven Neumann <neo@src.gnome.org> | 2003-04-03 11:13:18 +0000 |
commit | f6fdd34661bd9fe23452b5eb98ece8488a12ce8f (patch) | |
tree | 7701ae103fec9303510088cf8ba93a366b096ef2 /pango/pangoft2.c | |
parent | e1d94da9614cf5fa3a8f804961b7d0f511eaa820 (diff) | |
download | pango-f6fdd34661bd9fe23452b5eb98ece8488a12ce8f.tar.gz |
disable antialiasing if requested. Fixes bug #109370.
2003-04-03 Sven Neumann <sven@gimp.org>
* pango/pangoft2.c (pango_ft2_font_get_face)
(pango_ft2_font_render_glyph): disable antialiasing if requested.
Fixes bug #109370.
* pango/pangoft2.c (pango_ft2_render): fixed rendering of
monochrome bitmaps.
Diffstat (limited to 'pango/pangoft2.c')
-rw-r--r-- | pango/pangoft2.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/pango/pangoft2.c b/pango/pangoft2.c index c283e1f8..d4ffdfa6 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -34,6 +34,11 @@ #include "pangoft2.h" #include "pangoft2-private.h" +/* for compatibility with older freetype versions */ +#ifndef FT_LOAD_TARGET_MONO +#define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME +#endif + #define PANGO_TYPE_FT2_FONT (pango_ft2_font_get_type ()) #define PANGO_FT2_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FT2_FONT, PangoFT2Font)) #define PANGO_FT2_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FT2_FONT, PangoFT2FontClass)) @@ -196,33 +201,42 @@ load_fallback_face (PangoFT2Font *ft2font, * Return value: a pointer to a #FT_Face structure, with the size set correctly **/ FT_Face -pango_ft2_font_get_face (PangoFont *font) +pango_ft2_font_get_face (PangoFont *font) { PangoFT2Font *ft2font = (PangoFT2Font *)font; FT_Error error; FcPattern *pattern; FcChar8 *filename; - FcBool hinting, autohint; + FcBool antialias, hinting, autohint; int id; pattern = ft2font->font_pattern; if (!ft2font->face) { - /* If we add support for not antialising, then we should - * need to conditionalize NO_BITMAP on that. - */ - ft2font->load_flags = FT_LOAD_NO_BITMAP; + ft2font->load_flags = 0; + + /* disable antialiasing if requested */ + if (FcPatternGetBool (pattern, + FC_ANTIALIAS, 0, &antialias) != FcResultMatch) + antialias = FcTrue; + + if (antialias) + ft2font->load_flags |= FT_LOAD_NO_BITMAP; + else + ft2font->load_flags |= FT_LOAD_TARGET_MONO; /* disable hinting if requested */ - if (FcPatternGetBool (pattern, FC_HINTING, 0, &hinting) != FcResultMatch) + if (FcPatternGetBool (pattern, + FC_HINTING, 0, &hinting) != FcResultMatch) hinting = FcTrue; if (!hinting) ft2font->load_flags |= FT_LOAD_NO_HINTING; /* force autohinting if requested */ - if (FcPatternGetBool (pattern, FC_AUTOHINT, 0, &autohint) != FcResultMatch) + if (FcPatternGetBool (pattern, + FC_AUTOHINT, 0, &autohint) != FcResultMatch) autohint = FcFalse; if (autohint) @@ -246,7 +260,8 @@ pango_ft2_font_get_face (PangoFont *font) if (!set_unicode_charmap (ft2font->face)) { - g_warning ("Unable to load unicode charmap from font file %s", filename); + g_warning ("Unable to load unicode charmap from font file %s", + filename); FT_Done_Face (ft2font->face); ft2font->face = NULL; @@ -342,11 +357,13 @@ pango_ft2_font_render_glyph (PangoFont *font, if (face) { - PangoFT2Font *ft2font = (PangoFT2Font *)font; - + PangoFT2Font *ft2font = (PangoFT2Font *) font; + /* Draw glyph */ FT_Load_Glyph (face, glyph_index, ft2font->load_flags); - FT_Render_Glyph (face->glyph, ft_render_mode_normal); + FT_Render_Glyph (face->glyph, + (ft2font->load_flags & FT_LOAD_TARGET_MONO ? + ft_render_mode_mono : ft_render_mode_normal)); rendered->bitmap = face->glyph->bitmap; rendered->bitmap.buffer = g_memdup (face->glyph->bitmap.buffer, @@ -463,7 +480,7 @@ pango_ft2_render (FT_Bitmap *bitmap, for (ix = x_start; ix < x_limit; ix++) { if ((*src) & (1 << (7 - (ix % 8)))) - *dest |= (1 << (7 - (ix % 8))); + *dest |= 0xff; if ((ix % 8) == 7) src++; dest++; |