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 | |
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().
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 20 | ||||
-rw-r--r-- | modules/basic/basic-fc.c | 10 | ||||
-rw-r--r-- | pango/pangofc-font.c | 24 | ||||
-rw-r--r-- | pango/pangofc-font.h | 44 | ||||
-rw-r--r-- | pango/pangoft2.c | 95 | ||||
-rw-r--r-- | pango/pangoxft-font.c | 58 |
10 files changed, 224 insertions, 107 deletions
@@ -1,3 +1,23 @@ +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(). + Tue Jul 29 09:58:13 2003 Owen Taylor <otaylor@redhat.com> * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 32b4ca64..c2980f89 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,23 @@ +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(). + Tue Jul 29 09:58:13 2003 Owen Taylor <otaylor@redhat.com> * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 32b4ca64..c2980f89 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,23 @@ +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(). + Tue Jul 29 09:58:13 2003 Owen Taylor <otaylor@redhat.com> * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 32b4ca64..c2980f89 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,23 @@ +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(). + Tue Jul 29 09:58:13 2003 Owen Taylor <otaylor@redhat.com> * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 32b4ca64..c2980f89 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,23 @@ +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(). + Tue Jul 29 09:58:13 2003 Owen Taylor <otaylor@redhat.com> * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c index c9d64c9e..99e8c361 100644 --- a/modules/basic/basic-fc.c +++ b/modules/basic/basic-fc.c @@ -118,12 +118,6 @@ set_glyph (PangoFont *font, pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect); glyphs->glyphs[i].geometry.width = logical_rect.width; - - if (i > 0) - glyphs->glyphs[i-1].geometry.width += - pango_fc_font_get_kerning ((PangoFcFont *)font, - glyphs->glyphs[i-1].glyph, - glyphs->glyphs[i].glyph); } static void @@ -228,7 +222,9 @@ basic_engine_shape (PangoFont *font, start = end; } } - + + pango_fc_font_kern_glyphs (fc_font, glyphs); + pango_fc_font_unlock_face (fc_font); } diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c index 64d20ab8..aadb2e08 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -152,24 +152,18 @@ pango_fc_font_get_unknown_glyph (PangoFcFont *font, } /** - * pango_fc_font_get_kerning: - * @font: a #PangoFcFont. - * @left: the left #PangoGlyph - * @right: the right #PangoGlyph + * pango_fc_font_kern_glyphs + * @font: a #PangoFcFont + * @glyphs: a #PangoGlyphString * - * Retrieves kerning information for a combination of two glyphs. + * Adjust each adjacent pair of glyphs in @glyphs according to + * kerning information in @font. * - * Return value: The amount of kerning (in Pango units) to apply for - * the given combination of glyphs. - * * Since: 1.4 **/ -int -pango_fc_font_get_kerning (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right) +void +pango_fc_font_kern_glyphs (PangoFcFont *font, + PangoGlyphString *glyphs) { - g_return_val_if_fail (PANGO_IS_FC_FONT (font), 0); - - return PANGO_FC_FONT_GET_CLASS (font)->get_kerning (font, left, right); + PANGO_FC_FONT_GET_CLASS (font)->kern_glyphs (font, glyphs); } diff --git a/pango/pangofc-font.h b/pango/pangofc-font.h index 809a0e12..6e666542 100644 --- a/pango/pangofc-font.h +++ b/pango/pangofc-font.h @@ -24,6 +24,7 @@ #include <freetype/freetype.h> #include <pango/pango-font.h> +#include <pango/pango-glyph.h> #if defined(PANGO_ENABLE_ENGINE) || defined(PANGO_ENABLE_BACKEND) @@ -52,17 +53,16 @@ struct _PangoFcFontClass PangoFontClass parent_class; /*< public >*/ - FT_Face (*lock_face) (PangoFcFont *font); - void (*unlock_face) (PangoFcFont *font); - gboolean (*has_char) (PangoFcFont *font, - gunichar wc); - guint (*get_glyph) (PangoFcFont *font, - gunichar wc); - PangoGlyph (*get_unknown_glyph) (PangoFcFont *font, - gunichar wc); - int (*get_kerning) (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right); + FT_Face (*lock_face) (PangoFcFont *font); + void (*unlock_face) (PangoFcFont *font); + gboolean (*has_char) (PangoFcFont *font, + gunichar wc); + guint (*get_glyph) (PangoFcFont *font, + gunichar wc); + PangoGlyph (*get_unknown_glyph) (PangoFcFont *font, + gunichar wc); + void (*kern_glyphs) (PangoFcFont *font, + PangoGlyphString *glyphs); /*< private >*/ /* Padding for future expansion */ @@ -76,17 +76,17 @@ struct _PangoFcFontClass GType pango_fc_font_get_type (void); -FT_Face pango_fc_font_lock_face (PangoFcFont *font); -void pango_fc_font_unlock_face (PangoFcFont *font); -gboolean pango_fc_font_has_char (PangoFcFont *font, - gunichar wc); -guint pango_fc_font_get_glyph (PangoFcFont *font, - gunichar wc); -PangoGlyph pango_fc_font_get_unknown_glyph (PangoFcFont *font, - gunichar wc); -int pango_fc_font_get_kerning (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right); +FT_Face pango_fc_font_lock_face (PangoFcFont *font); +void pango_fc_font_unlock_face (PangoFcFont *font); +gboolean pango_fc_font_has_char (PangoFcFont *font, + gunichar wc); +guint pango_fc_font_get_glyph (PangoFcFont *font, + gunichar wc); +PangoGlyph pango_fc_font_get_unknown_glyph (PangoFcFont *font, + gunichar wc); +void pango_fc_font_kern_glyphs (PangoFcFont *font, + PangoGlyphString *glyphs); + G_END_DECLS #endif /* PANGO_ENABLE_ENGINE || PANGO_ENABLE_BACKEND */ 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 diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c index d3340e8b..1c11fb0b 100644 --- a/pango/pangoxft-font.c +++ b/pango/pangoxft-font.c @@ -75,17 +75,16 @@ static void pango_xft_font_get_glyph_extents (PangoFont static PangoFontMetrics * pango_xft_font_get_metrics (PangoFont *font, PangoLanguage *language); -static FT_Face pango_xft_font_real_lock_face (PangoFcFont *font); -static void pango_xft_font_real_unlock_face (PangoFcFont *font); -static gboolean pango_xft_font_real_has_char (PangoFcFont *font, - gunichar wc); -static guint pango_xft_font_real_get_glyph (PangoFcFont *font, - gunichar wc); -static PangoGlyph pango_xft_font_real_get_unknown_glyph (PangoFcFont *font, - gunichar wc); -static int pango_xft_font_real_get_kerning (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right); +static FT_Face pango_xft_font_real_lock_face (PangoFcFont *font); +static void pango_xft_font_real_unlock_face (PangoFcFont *font); +static gboolean pango_xft_font_real_has_char (PangoFcFont *font, + gunichar wc); +static guint pango_xft_font_real_get_glyph (PangoFcFont *font, + gunichar wc); +static PangoGlyph pango_xft_font_real_get_unknown_glyph (PangoFcFont *font, + gunichar wc); +static void pango_xft_font_real_kern_glyphs (PangoFcFont *font, + PangoGlyphString *glyphs); static XftFont *xft_font_get_font (PangoFont *font); @@ -145,7 +144,7 @@ pango_xft_font_class_init (PangoXftFontClass *class) fc_font_class->has_char = pango_xft_font_real_has_char; fc_font_class->get_glyph = pango_xft_font_real_get_glyph; fc_font_class->get_unknown_glyph = pango_xft_font_real_get_unknown_glyph; - fc_font_class->get_kerning = pango_xft_font_real_get_kerning; + fc_font_class->kern_glyphs = pango_xft_font_real_kern_glyphs; } PangoXftFont * @@ -785,39 +784,38 @@ pango_xft_font_real_get_unknown_glyph (PangoFcFont *font, return wc | PANGO_XFT_UNKNOWN_FLAG; } -static int -pango_xft_font_real_get_kerning (PangoFcFont *font, - PangoGlyph left, - PangoGlyph right) +static void +pango_xft_font_real_kern_glyphs (PangoFcFont *font, + PangoGlyphString *glyphs) { FT_Face face; FT_Error error; FT_Vector kerning; + int i; face = pango_fc_font_lock_face (font); if (!face) - return 0; + return; if (!FT_HAS_KERNING (face)) { pango_fc_font_unlock_face (font); - return 0; + return; } - - if (!left || !right) + + for (i = 1; i < glyphs->num_glyphs; ++i) { - pango_fc_font_unlock_face (font); - return 0; + 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); } - - error = FT_Get_Kerning (face, left, right, - ft_kerning_default, &kerning); - if (error != FT_Err_Ok) - kerning.x = 0; - + pango_fc_font_unlock_face (font); - - return PANGO_UNITS_26_6 (kerning.x); } /** |