changeset 91294:299c64a7a9fb

(ftfont_drive_otf): Fix setting of FROM and TO slots of glyphs.
author Kenichi Handa <handa@m17n.org>
date Thu, 27 Dec 2007 01:15:39 +0000
parents c45d16b39212
children e05192ca2c8f
files src/ftfont.c
diffstat 1 files changed, 36 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ftfont.c	Thu Dec 27 01:14:29 2007 +0000
+++ b/src/ftfont.c	Thu Dec 27 01:15:39 2007 +0000
@@ -1307,25 +1307,52 @@
 	goto simple_copy;
       if (out->allocated < out->used + otf_gstring.used)
 	return -2;
-      for (i = 0, otfg = otf_gstring.glyphs; i < otf_gstring.used; i++, otfg++)
+      for (i = 0, otfg = otf_gstring.glyphs; i < otf_gstring.used; )
 	{
-	  MFLTGlyph *g = out->glyphs + out->used;
+	  OTF_Glyph *endg;
+	  MFLTGlyph *g;
+	  int min_from, max_to;
 	  int j;
 
+	  g = out->glyphs + out->used;
 	  *g = in->glyphs[from + otfg->f.index.from];
-	  g->c = 0;
-	  for (j = from + otfg->f.index.from; j <= from + otfg->f.index.to; j++)
-	    if (in->glyphs[j].code == otfg->glyph_id)
-	      {
-		g->c = in->glyphs[j].c;
-		break;
-	      }
 	  if (g->code != otfg->glyph_id)
 	    {
+	      g->c = 0;
 	      g->code = otfg->glyph_id;
 	      g->measured = 0;
 	    }
 	  out->used++;
+	  min_from = g->from;
+	  max_to = g->to;
+	  if (otfg->f.index.from < otfg->f.index.to)
+	    {
+	      /* OTFG substitutes multiple glyphs in IN.  */
+	      for (j = from + otfg->f.index.from + 1;
+		   j <= from + otfg->f.index.to; j++)
+		{
+		  if (min_from > in->glyphs[j].from)
+		    min_from = in->glyphs[j].from;
+		  if (max_to < in->glyphs[j].to)
+		    max_to = in->glyphs[j].to;
+		}
+	      g->from = min_from;
+	      g->to = max_to;
+	    }
+	  for (i++, otfg++; (i < otf_gstring.used
+			     && otfg->f.index.from == otfg[-1].f.index.from);
+	       i++, otfg++)
+	    {
+	      g = out->glyphs + out->used;
+	      *g = in->glyphs[from + otfg->f.index.to];
+	      if (g->code != otfg->glyph_id)
+		{
+		  g->c = 0;
+		  g->code = otfg->glyph_id;
+		  g->measured = 0;
+		}
+	      out->used++;
+	    }
 	}
     }
   else