diff options
author | Soeren Sandmann <sandmann@daimi.au.dk> | 2003-08-02 14:30:42 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2003-08-02 14:30:42 +0000 |
commit | bcf10a1085bdf9344e513785c1082f9b82278619 (patch) | |
tree | 8060bace8d1366f4fa92a9bae98f84d6893156d3 /pango/pangoft2.c | |
parent | 537660728317118a8c2bd1940b2607ccf0f036ba (diff) | |
download | pango-bcf10a1085bdf9344e513785c1082f9b82278619.tar.gz |
Add API to kern a complete glyph string. Remove API to kern individual
Sat Aug 2 16:40:19 2003 Soeren Sandmann <sandmann@daimi.au.dk>
Add API to kern a complete glyph string. Remove API to kern
individual glyph pairs.
* modules/basic/basic-fc.c (basic_engine_shape): use
pango_fc_font_kern_glyphs() instead of pango_fc_font_get_kerning().
* pango/pangoft2.c (pango_ft2_font_real_kern_glyphs): add this
function, remove pango_ft2_font_real_get_kerning().
* pango/pangoxft-font.c (pango_xft_font_real_kern_glyphs): add
this function, remove pango_xft_font_real_get_kerning().
* pango/pangofc-font.c (pango_fc_font_kern_glyphs): new
function. Remove pango_fc_font_get_kerning().
* pango/pangofc-font.h: remove pango_fc_font_get_kerning(), add
pango_fc_font_kern_glyphs().
Diffstat (limited to 'pango/pangoft2.c')
-rw-r--r-- | pango/pangoft2.c | 95 |
1 files changed, 62 insertions, 33 deletions
diff --git a/pango/pangoft2.c b/pango/pangoft2.c index c43e8912..517e952b 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -88,17 +88,16 @@ static PangoFontMetrics * pango_ft2_font_get_metrics (PangoFont * PangoLanguage *language); -static FT_Face pango_ft2_font_real_lock_face (PangoFcFont *font); -static void pango_ft2_font_real_unlock_face (PangoFcFont *font); -static gboolean pango_ft2_font_real_has_char (PangoFcFont *font, - gunichar wc); -static guint pango_ft2_font_real_get_glyph (PangoFcFont *font, - gunichar wc); -static PangoGlyph pango_ft2_font_real_get_unknown_glyph (PangoFcFont *font, - gunichar wc); -static int pango_ft2_font_real_get_kerning (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right); +static FT_Face pango_ft2_font_real_lock_face (PangoFcFont *font); +static void pango_ft2_font_real_unlock_face (PangoFcFont *font); +static gboolean pango_ft2_font_real_has_char (PangoFcFont *font, + gunichar wc); +static guint pango_ft2_font_real_get_glyph (PangoFcFont *font, + gunichar wc); +static PangoGlyph pango_ft2_font_real_get_unknown_glyph (PangoFcFont *font, + gunichar wc); +static void pango_ft2_font_real_kern_glyphs (PangoFcFont *font, + PangoGlyphString *glyphs); static GType pango_ft2_font_get_type (void); @@ -359,7 +358,7 @@ pango_ft2_font_class_init (PangoFT2FontClass *class) fc_font_class->has_char = pango_ft2_font_real_has_char; fc_font_class->get_glyph = pango_ft2_font_real_get_glyph; fc_font_class->get_unknown_glyph = pango_ft2_font_real_get_unknown_glyph; - fc_font_class->get_kerning = pango_ft2_font_real_get_kerning; + fc_font_class->kern_glyphs = pango_ft2_font_real_kern_glyphs; } static void @@ -633,7 +632,7 @@ pango_ft2_font_get_glyph_extents (PangoFont *font, * * Retrieves kerning information for a combination of two glyphs. * - * Use pango_fc_font_get_kerning() instead. + * Use pango_fc_font_kern_glyphs() instead. * * Return value: The amount of kerning (in Pango units) to apply for * the given combination of glyphs. @@ -643,7 +642,31 @@ pango_ft2_font_get_kerning (PangoFont *font, PangoGlyph left, PangoGlyph right) { - return pango_fc_font_get_kerning (PANGO_FC_FONT (font), left, right); + PangoFcFont *fc_font = PANGO_FC_FONT (font); + + FT_Face face; + FT_Error error; + FT_Vector kerning; + + face = pango_fc_font_lock_face (fc_font); + if (!face) + return 0; + + if (!FT_HAS_KERNING (face)) + { + pango_fc_font_unlock_face (fc_font); + return 0; + } + + error = FT_Get_Kerning (face, left, right, ft_kerning_default, &kerning); + if (error != FT_Err_Ok) + { + pango_fc_font_unlock_face (fc_font); + return 0; + } + + pango_fc_font_unlock_face (fc_font); + return PANGO_UNITS_26_6 (kerning.x); } static PangoFontMetrics * @@ -756,32 +779,38 @@ pango_ft2_font_real_get_unknown_glyph (PangoFcFont *font, return 0; } -static int -pango_ft2_font_real_get_kerning (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right) -{ +static void +pango_ft2_font_real_kern_glyphs (PangoFcFont *font, + PangoGlyphString *glyphs) +{ FT_Face face; FT_Error error; FT_Vector kerning; + int i; - face = pango_ft2_font_get_face ((PangoFont *)font); + face = pango_fc_font_lock_face (font); if (!face) - return 0; + return; if (!FT_HAS_KERNING (face)) - return 0; - - if (!left || !right) - return 0; - - error = FT_Get_Kerning (face, left, right, - ft_kerning_default, &kerning); - if (error != FT_Err_Ok) - g_warning ("FT_Get_Kerning returns error: %s", - _pango_ft2_ft_strerror (error)); - - return PANGO_UNITS_26_6 (kerning.x); + { + pango_fc_font_unlock_face (font); + return; + } + + for (i = 1; i < glyphs->num_glyphs; ++i) + { + error = FT_Get_Kerning (face, + glyphs->glyphs[i-1].glyph, + glyphs->glyphs[i].glyph, + ft_kerning_default, + &kerning); + + if (error == FT_Err_Ok) + glyphs->glyphs[i-1].geometry.width += PANGO_UNITS_26_6 (kerning.x); + } + + pango_fc_font_unlock_face (font); } static gboolean |