(compose_glyph_string): When the script `inherited' and
[m17n/m17n-lib.git] / src / draw.c
index f35d058..f5b23cf 100644 (file)
@@ -1,5 +1,5 @@
 /* draw.c -- drawing module.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -238,30 +238,6 @@ visual_order (MGlyphString *gstring)
     }
 }
 
-#if 0
-static void
-reorder_combining_chars (MGlyphString *gstring, int from, int to)
-{
-  MGlyph *g, *gbeg = MGLYPH (from + 1), *gend = MGLYPH (to), temp;
-  int reordered = 1;
-  
-  while (reordered)
-    {
-      reordered = 0;
-      for (g = gbeg; g != gend; g++)
-       if (COMBINING_CODE_CLASS (g->combining_code) > 0
-           && (COMBINING_CODE_CLASS (g[-1].combining_code)
-               > COMBINING_CODE_CLASS (g->combining_code)))
-         {
-           reordered = 1;
-           temp = *g;
-           *g = g[-1];
-           g[-1] = temp;
-         }
-    }
-}
-#endif
-
 static MSymbol
 font_id (MFLTFont *font)
 {
@@ -278,6 +254,7 @@ run_flt (MGlyphString *gstring, int from, int to, MRealizedFace *rface)
   MFLT *flt;
   int from_pos = MGLYPH (from)->g.from;
   int len = to - from;
+  int catcode;
   int i;
 
   flt = mflt_get (layouter);
@@ -297,6 +274,7 @@ run_flt (MGlyphString *gstring, int from, int to, MRealizedFace *rface)
   font.rfont = rfont;
   mflt_font_id = font_id;
   mflt_iterate_otf_feature = rfont->driver->iterate_otf_feature;
+  mflt_try_otf = rfont->driver->try_otf;
   for (i = 0; i < 3; i++)
     {
       to = mflt_run (&flt_gstr, from, to, &font.font, flt);
@@ -308,7 +286,7 @@ run_flt (MGlyphString *gstring, int from, int to, MRealizedFace *rface)
     }
   if (from + len != to)
     gstring->used += to - (from + len);
-  for (i = from; i < to; i++)
+  for (i = from, catcode = -1; i < to; i++)
     {
       MGlyph *g = MGLYPH (i);
 
@@ -323,6 +301,17 @@ run_flt (MGlyphString *gstring, int from, int to, MRealizedFace *rface)
       g->g.xoff >>= 6;
       g->g.yoff >>= 6;
       g->rface = rface;
+      if (catcode < 0 || g->g.from != g[-1].g.from)
+       {
+         MSymbol category = mchar_get_prop (g->g.c, Mcategory);
+
+         catcode = (category == McatCf
+                    ? GLYPH_CATEGORY_FORMATTER
+                    : category != Mnil && MSYMBOL_NAME (category)[0] == 'M'
+                    ? GLYPH_CATEGORY_MODIFIER
+                    : GLYPH_CATEGORY_NORMAL);
+       }
+      g->category = catcode;
     }
   return to;
 }
@@ -494,6 +483,8 @@ compose_glyph_string (MFrame *frame, MText *mt, int from, int to,
                    break;
                  }
            }
+         if (this_script == Minherited || this_script == Mcommon)
+           this_script = (MSymbol) mchar_get_prop (c, Mblock);
        }
 
       pos = g->g.from;
@@ -557,7 +548,6 @@ compose_glyph_string (MFrame *frame, MText *mt, int from, int to,
 
              for (g++;
                   (g->type == GLYPH_CHAR
-                   && g->g.from != gstring->control.cursor_pos
                    && g->rface->layouter == this->rface->layouter
                    && (g->rface->rfont == this->rface->rfont
                        || (g->category == GLYPH_CATEGORY_FORMATTER
@@ -1771,6 +1761,8 @@ mdraw__init ()
   M_kinsoku_bol = msymbol ("kb");
   M_kinsoku_eol = msymbol ("ke");
 
+  mflt_enable_new_feature = 1;
+
   return 0;
 }