changeset 96568:ff2262b8b0f2

(ftfont_text_extents): Fix initial setting of metrics.
author Kenichi Handa <handa@m17n.org>
date Wed, 09 Jul 2008 07:36:33 +0000
parents dea344114c62
children 3892f90421a9
files src/ftfont.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ftfont.c	Wed Jul 09 02:09:11 2008 +0000
+++ b/src/ftfont.c	Wed Jul 09 07:36:33 2008 +0000
@@ -1171,18 +1171,29 @@
   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))