aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-07-09 07:38:38 +0000
committerKenichi Handa2008-07-09 07:38:38 +0000
commite5d059785625b81a635990f298667f51db41d2aa (patch)
tree870a94ce33eb6effa7dec3d97904b14f45dd6815 /src
parent73353585888363f73ca00f2c91626844554bf955 (diff)
downloademacs-e5d059785625b81a635990f298667f51db41d2aa.tar.gz
emacs-e5d059785625b81a635990f298667f51db41d2aa.zip
(ftfont_text_extents): Fix initial setting of metrics.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog2
-rw-r--r--src/ftfont.c15
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 @@
22 22
23 * xfont.c (xfont_open): Adjust it for the change of 23 * xfont.c (xfont_open): Adjust it for the change of
24 font_make_object. 24 font_make_object.
25 (xfont_text_extents): Fix initial setting of metrics.
25 26
26 * ftfont.c (struct ftfont_info): New member index, delete member 27 * ftfont.c (struct ftfont_info): New member index, delete member
27 fc_charset_idx. Make the member order compatible with struct 28 fc_charset_idx. Make the member order compatible with struct
@@ -49,6 +50,7 @@
49 (ftfont_has_char): Use ftfont_get_fc_charset. 50 (ftfont_has_char): Use ftfont_get_fc_charset.
50 (ftfont_otf_features, ftfont_otf_capability): New functions. 51 (ftfont_otf_features, ftfont_otf_capability): New functions.
51 (ftfont_shape): Use ftfont_get_otf. 52 (ftfont_shape): Use ftfont_get_otf.
53 (ftfont_text_extents): Fix initial setting of metrics.
52 54
53 * xftfont.c (struct xftfont_info): New member ft_size. Make the 55 * xftfont.c (struct xftfont_info): New member ft_size. Make the
54 member order compatible with struct ftfont_info. 56 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)
1171 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1171 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
1172 FT_Face ft_face = ftfont_info->ft_size->face; 1172 FT_Face ft_face = ftfont_info->ft_size->face;
1173 int width = 0; 1173 int width = 0;
1174 int i; 1174 int i, first;
1175 1175
1176 if (ftfont_info->ft_size != ft_face->size) 1176 if (ftfont_info->ft_size != ft_face->size)
1177 FT_Activate_Size (ftfont_info->ft_size); 1177 FT_Activate_Size (ftfont_info->ft_size);
1178 if (metrics) 1178 if (metrics)
1179 bzero (metrics, sizeof (struct font_metrics)); 1179 bzero (metrics, sizeof (struct font_metrics));
1180 for (i = 0; i < nglyphs; i++) 1180 for (i = 0, first = 1; i < nglyphs; i++)
1181 { 1181 {
1182 if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0) 1182 if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0)
1183 { 1183 {
1184 FT_Glyph_Metrics *m = &ft_face->glyph->metrics; 1184 FT_Glyph_Metrics *m = &ft_face->glyph->metrics;
1185 1185
1186 if (first)
1187 {
1188 if (metrics)
1189 {
1190 metrics->lbearing = m->horiBearingX >> 6;
1191 metrics->rbearing = (m->horiBearingX + m->width) >> 6;
1192 metrics->ascent = m->horiBearingY >> 6;
1193 metrics->descent = (m->horiBearingY + m->height) >> 6;
1194 }
1195 first = 0;
1196 }
1186 if (metrics) 1197 if (metrics)
1187 { 1198 {
1188 if (metrics->lbearing > width + (m->horiBearingX >> 6)) 1199 if (metrics->lbearing > width + (m->horiBearingX >> 6))