changeset 91307:0afaa00ae397

(Ffont_shape_text): If the font driver doesn't have a shaper function, make zero-width glyphs to have at least one-pixel width.
author Kenichi Handa <handa@m17n.org>
date Mon, 07 Jan 2008 02:02:05 +0000
parents 88a38e465627
children 9b6270bcd1a7
files src/font.c
diffstat 1 files changed, 40 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/font.c	Thu Jan 03 17:51:06 2008 +0000
+++ b/src/font.c	Mon Jan 07 02:02:05 2008 +0000
@@ -3567,12 +3567,42 @@
     }
 
   CHECK_FONT_GET_OBJECT (font_object, font);
-  if (! font->driver->shape)
-    return from;
-
   len = end - start;
   gstring = Ffont_make_gstring (font_object, make_number (len));
   Ffont_fill_gstring (gstring, font_object, from, to, string);
+  if (! font->driver->shape)
+    {
+      /* Make zero-width glyphs to have one pixel width to make the
+	 display routine not lose the cursor.  */
+      for (i = 0; i < len; i++)
+	{
+	  Lisp_Object g = LGSTRING_GLYPH (gstring, i);
+	  unsigned code = LGLYPH_CODE (g);
+	  struct font_metrics metrics;
+
+	  if (font->driver->text_extents (font, &code, 1, &metrics) == 0)
+	    {
+	      Lisp_Object gstr = Ffont_make_gstring (font_object,
+						     make_number (1));
+	      LGSTRING_SET_WIDTH (gstr, 1);
+	      LGSTRING_SET_LBEARING (gstr, metrics.lbearing);
+	      LGSTRING_SET_RBEARING (gstr, metrics.rbearing + 1);
+	      LGSTRING_SET_ASCENT (gstr, metrics.ascent);
+	      LGSTRING_SET_DESCENT (gstr, metrics.descent);
+	      LGLYPH_SET_FROM (g, 0);
+	      LGLYPH_SET_TO (g, 1);
+	      LGSTRING_SET_GLYPH (gstr, 0, g);
+	      from = make_number (start + i);
+	      to = make_number (start + i + 1);
+	      if (NILP (string))
+		Fcompose_region_internal (from, to, gstr, Qnil);
+	      else
+		Fcompose_region_internal (string, from, to, gstr, Qnil);
+	    }
+	}
+      return make_number (end);
+    }
+
   
   /* Try at most three times with larger gstring each time.  */
   for (i = 0; i < 3; i++)
@@ -3653,7 +3683,13 @@
 	  LGSTRING_SET_ASCENT (gstr, metrics.ascent);
 	  LGSTRING_SET_DESCENT (gstr, metrics.descent);
 	  for (k = i; i < j; i++)
-	    LGSTRING_SET_GLYPH (gstr, i - k, LGSTRING_GLYPH (gstring, i));
+	    {
+	      Lisp_Object g = LGSTRING_GLYPH (gstring, i);
+
+	      LGLYPH_SET_FROM (g, LGLYPH_FROM (g) - this_from);
+	      LGLYPH_SET_TO (g, LGLYPH_TO (g) - this_to);
+	      LGSTRING_SET_GLYPH (gstr, i - k, LGSTRING_GLYPH (gstring, i));
+	    }
 	  from = make_number (start + this_from);
 	  to = make_number (start + this_to);
 	  if (NILP (string))