From e5d059785625b81a635990f298667f51db41d2aa Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Wed, 9 Jul 2008 07:38:38 +0000 Subject: [PATCH] (ftfont_text_extents): Fix initial setting of metrics. --- src/ChangeLog | 2 ++ src/ftfont.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e5caa4c85dd..43d0dd3dfb4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -22,6 +22,7 @@ * xfont.c (xfont_open): Adjust it for the change of font_make_object. + (xfont_text_extents): Fix initial setting of metrics. * ftfont.c (struct ftfont_info): New member index, delete member fc_charset_idx. Make the member order compatible with struct @@ -49,6 +50,7 @@ (ftfont_has_char): Use ftfont_get_fc_charset. (ftfont_otf_features, ftfont_otf_capability): New functions. (ftfont_shape): Use ftfont_get_otf. + (ftfont_text_extents): Fix initial setting of metrics. * xftfont.c (struct xftfont_info): New member ft_size. Make the member order compatible with struct ftfont_info. diff --git a/src/ftfont.c b/src/ftfont.c index ba157119936..31286a182c5 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1171,18 +1171,29 @@ ftfont_text_extents (font, code, nglyphs, metrics) struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; int width = 0; - int i; + int i, first; if (ftfont_info->ft_size != ft_face->size) FT_Activate_Size (ftfont_info->ft_size); if (metrics) bzero (metrics, sizeof (struct font_metrics)); - for (i = 0; i < nglyphs; i++) + for (i = 0, first = 1; i < nglyphs; i++) { if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0) { FT_Glyph_Metrics *m = &ft_face->glyph->metrics; + if (first) + { + if (metrics) + { + metrics->lbearing = m->horiBearingX >> 6; + metrics->rbearing = (m->horiBearingX + m->width) >> 6; + metrics->ascent = m->horiBearingY >> 6; + metrics->descent = (m->horiBearingY + m->height) >> 6; + } + first = 0; + } if (metrics) { if (metrics->lbearing > width + (m->horiBearingX >> 6)) -- 2.39.2