(ftfont_text_extents): Fix initial setting of metrics.
authorKenichi Handa <handa@m17n.org>
Wed, 9 Jul 2008 07:38:38 +0000 (07:38 +0000)
committerKenichi Handa <handa@m17n.org>
Wed, 9 Jul 2008 07:38:38 +0000 (07:38 +0000)
src/ChangeLog
src/ftfont.c

index e5caa4c..43d0dd3 100644 (file)
@@ -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.
index ba15711..31286a1 100644 (file)
@@ -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))