diff options
author | Owen Taylor <otaylor@redhat.com> | 2004-07-10 20:50:53 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2004-07-10 20:50:53 +0000 |
commit | 5bf0c1d04b6ed75ad2c88fbed1e1eaecf0dcbfa2 (patch) | |
tree | 82f722e254dbc6b5cb1446b87103e27c8b0aecf8 /pango/pangoft2.c | |
parent | 19dea7b162bb2d12911d38770d8cc87accc40fe7 (diff) | |
download | pango-5bf0c1d04b6ed75ad2c88fbed1e1eaecf0dcbfa2.tar.gz |
Add hinted/transform flags to the font structure to allow efficient
Sat Jul 10 16:39:44 2004 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-font.[ch]: Add hinted/transform flags
to the font structure to allow efficient conditionalization
of behavior rather than repeatedly extracting the information
from the FcPattern.
* pango/pangofc-font.c pango/pangofc-private.h pango/pangoft2.c:
Move the glyph metrics computation into a
_pango_fc_font_get_raw_extents() function that can be
shared with the Xft backend.
* pango/pangoxft.c: When a transform is in effect, don't
get glyph extents from Xft ... they are device space
and not useful, use _pango_fc_font_get_raw_extents() instead.
Diffstat (limited to 'pango/pangoft2.c')
-rw-r--r-- | pango/pangoft2.c | 60 |
1 files changed, 7 insertions, 53 deletions
diff --git a/pango/pangoft2.c b/pango/pangoft2.c index 3963299e..f787f00d 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -31,6 +31,7 @@ #include "pangoft2.h" #include "pangoft2-private.h" #include "pangofc-fontmap.h" +#include "pangofc-private.h" /* for compatibility with older freetype versions */ #ifndef FT_LOAD_TARGET_MONO @@ -558,72 +559,25 @@ pango_ft2_render (FT_Bitmap *bitmap, pango_ft2_render_transformed (bitmap, NULL, font, glyphs, x * PANGO_SCALE, y * PANGO_SCALE); } -static FT_Glyph_Metrics * -pango_ft2_get_per_char (PangoFont *font, - guint32 glyph_index) -{ - PangoFT2Font *ft2font = (PangoFT2Font *)font; - FT_Face face; - - face = pango_ft2_font_get_face (font); - - FT_Load_Glyph (face, glyph_index, ft2font->load_flags); - return &face->glyph->metrics; -} - static PangoFT2GlyphInfo * pango_ft2_font_get_glyph_info (PangoFont *font, PangoGlyph glyph, gboolean create) { PangoFT2Font *ft2font = (PangoFT2Font *)font; + PangoFcFont *fcfont = (PangoFcFont *)font; PangoFT2GlyphInfo *info; - FT_Glyph_Metrics *gm; info = g_hash_table_lookup (ft2font->glyph_info, GUINT_TO_POINTER (glyph)); if ((info == NULL) && create) { - FT_Face face = pango_ft2_font_get_face (font); - info = g_new0 (PangoFT2GlyphInfo, 1); - - if (glyph && (gm = pango_ft2_get_per_char (font, glyph))) - { - info->ink_rect.x = PANGO_UNITS_26_6 (gm->horiBearingX); - info->ink_rect.width = PANGO_UNITS_26_6 (gm->width); - info->ink_rect.y = -PANGO_UNITS_26_6 (gm->horiBearingY); - info->ink_rect.height = PANGO_UNITS_26_6 (gm->height); - - info->logical_rect.x = 0; - info->logical_rect.width = PANGO_UNITS_26_6 (gm->horiAdvance); - if (ft2font->load_flags & FT_LOAD_NO_HINTING) - { - FT_Fixed ascender, descender; - - ascender = FT_MulFix (face->ascender, face->size->metrics.y_scale); - descender = FT_MulFix (face->descender, face->size->metrics.y_scale); + info = g_new0 (PangoFT2GlyphInfo, 1); - info->logical_rect.y = - PANGO_UNITS_26_6 (ascender); - info->logical_rect.height = PANGO_UNITS_26_6 (ascender - descender); - } - else - { - info->logical_rect.y = - PANGO_UNITS_26_6 (face->size->metrics.ascender); - info->logical_rect.height = PANGO_UNITS_26_6 (face->size->metrics.ascender - face->size->metrics.descender); - } - } - else - { - info->ink_rect.x = 0; - info->ink_rect.width = 0; - info->ink_rect.y = 0; - info->ink_rect.height = 0; - - info->logical_rect.x = 0; - info->logical_rect.width = 0; - info->logical_rect.y = 0; - info->logical_rect.height = 0; - } + _pango_fc_font_get_raw_extents (fcfont, ft2font->load_flags, + glyph, + &info->ink_rect, + &info->logical_rect); g_hash_table_insert (ft2font->glyph_info, GUINT_TO_POINTER(glyph), info); } |