(M0_3): Delete it.
[m17n/m17n-lib.git] / src / draw.c
index 4ea2041..0d1d48b 100644 (file)
@@ -440,7 +440,11 @@ compose_glyph_string (MFrame *frame, MText *mt, int from, int to,
                                                   NULL, prev->c)
                        != MCHAR_INVALID_CODE));
                   start--, prev--)
-               prev->code = code;
+               if (prev->rface->rfont != this->rface->rfont)
+                 {
+                   prev->rface->rfont = this->rface->rfont;
+                   prev->code = code;
+                 }
 
              for (g++;
                   (g->type == GLYPH_CHAR
@@ -601,7 +605,10 @@ layout_glyphs (MFrame *frame, MGlyphString *gstring, int from, int to,
          if (base->left_padding && base->lbearing < 0)
            {
              base->xoff = - base->lbearing;
-             base->width += base->xoff;
+             if (base->rbearing < 0)
+               base->width = base->rbearing - base->lbearing;
+             else
+               base->width += base->xoff;
              base->rbearing += base->xoff;
              base->lbearing = 0;
            }
@@ -609,9 +616,8 @@ layout_glyphs (MFrame *frame, MGlyphString *gstring, int from, int to,
            {
              base->width = base->rbearing;
            }
-         lbearing = (base->xoff + base->lbearing < 0
-                     ? base->xoff + base->lbearing : 0);
-         rbearing = base->xoff + base->rbearing;
+         lbearing = base->lbearing;
+         rbearing = base->rbearing;
        }
       else
        {
@@ -1261,7 +1267,8 @@ render_glyphs (MFrame *frame, MDrawWindow win, int x, int y, int width,
                gend--;
            }
          if (g != gend)
-           while (gend[-1].to == gend->to) gend++;
+           while (gend->type != GLYPH_ANCHOR && gend[-1].to == gend->to)
+             gend++;
        }
     }
 
@@ -1571,9 +1578,15 @@ truncate_gstring (MFrame *frame, MText *mt, MGlyphString *gstring)
        pos = gstring->to;
     }
   else if (i == 0)
-    pos++;
-  compose_glyph_string (frame, mt, gstring->from, pos, gstring);
-  layout_glyph_string (frame, gstring);
+    {
+      g = find_glyph_in_gstring (gstring, gstring->from, 1);
+      pos = g->to;
+    }
+  if (pos < gstring->to)
+    {
+      compose_glyph_string (frame, mt, gstring->from, pos, gstring);
+      layout_glyph_string (frame, gstring);
+    }
 }
 
 
@@ -2650,7 +2663,8 @@ mdraw_glyph_info (MFrame *frame, MText *mt, int from, int pos,
 
       info->prev_from = g_tmp->pos;
     }
-  else if (info->line_from > 0)
+  else if (info->line_from > 0
+          && gstring->from > 0)
     {
       /* The logically previous glyph is on the previous line.  */
       MGlyphString *gst = get_gstring (frame, mt, gstring->from - 1,
@@ -2845,7 +2859,7 @@ mdraw_glyph_list (MFrame *frame, MText *mt, int from, int to,
            {
              glyphs->font = (MFont *) g->rface->rfont;
              glyphs->font_type
-               = (g->rface->rfont->font->type == MFONT_SOURCE_X ? Mx
+               = (glyphs->font->source == MFONT_SOURCE_X ? Mx
                   : g->rface->rfont->driver == &mfont__ft_driver ? Mfreetype
                   : Mxft);
              glyphs->fontp = g->rface->rfont->fontp;