emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110047: font.c (Ffont_shape_gstring)


From: Kenichi Handa
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110047: font.c (Ffont_shape_gstring): Don't adjust grapheme cluster here, but just check the validity of glyphs in the glyph-string.
Date: Sun, 16 Sep 2012 20:48:48 +0900
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110047 [merge]
committer: Kenichi Handa <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-16 20:48:48 +0900
message:
  font.c (Ffont_shape_gstring): Don't adjust grapheme cluster here, but just 
check the validity of glyphs in the glyph-string.
modified:
  src/ChangeLog
  src/font.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-09-16 10:25:24 +0000
+++ b/src/ChangeLog     2012-09-16 11:47:45 +0000
@@ -1,3 +1,8 @@
+2012-09-16  Kenichi Handa  <address@hidden>
+
+       * font.c (Ffont_shape_gstring): Don't adjust grapheme cluster
+       here, but just check the validity of glyphs in the glyph-string.
+
 2012-09-16  Martin Rudalics  <address@hidden>
 
        * window.c (Fwindow_parameter, Fset_window_parameter): Accept

=== modified file 'src/font.c'
--- a/src/font.c        2012-09-15 07:06:56 +0000
+++ b/src/font.c        2012-09-16 11:47:45 +0000
@@ -4295,7 +4295,10 @@
 header of the glyph-string.
 
 If the shaping was successful, the value is GSTRING itself or a newly
-created glyph-string.  Otherwise, the value is nil.  */)
+created glyph-string.  Otherwise, the value is nil.
+
+See the documentation of `composition-get-gstring' for the format of
+GSTRING.  */)
   (Lisp_Object gstring)
 {
   struct font *font;
@@ -4326,44 +4329,45 @@
   if (XINT (n) < LGSTRING_GLYPH_LEN (gstring))
     LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil);
 
+  /* Check FROM_IDX and TO_IDX of each GLYPH in GSTRING to assure that
+     GLYPHS covers all characters in GSTRING.  More formally, provided
+     that NCHARS is the number of characters in GSTRING, N is the
+     number of glyphs, and GLYPHS[i] is the ith glyph, FROM_IDX and
+     TO_IDX of each glyph must satisfy these conditions:
+
+       GLYPHS[0].FROM_IDX == 0
+       GLYPHS[i].FROM_IDX <= GLYPHS[i].TO_IDX
+       if (GLYPHS[i].FROM_IDX == GLYPHS[i-1].FROM_IDX)
+         ;; GLYPHS[i] and GLYPHS[i-1] belongs to the same grapheme cluster
+         GLYPHS[i].TO_IDX == GLYPHS[i-1].TO_IDX
+       else
+         ;; Be sure to cover all characters.
+         GLYPHS[i].FROM_IDX == GLYPHS[i-1].TO_IDX + 1
+       GLYPHS[N-1].TO_IDX == NCHARS - 1 */
   glyph = LGSTRING_GLYPH (gstring, 0);
   from = LGLYPH_FROM (glyph);
   to = LGLYPH_TO (glyph);
-  for (i = 1, j = 0; i < LGSTRING_GLYPH_LEN (gstring); i++)
+  if (from != 0 || to < from)
+    goto shaper_error;
+  for (i = 1; i < LGSTRING_GLYPH_LEN (gstring); i++)
     {
-      Lisp_Object this = LGSTRING_GLYPH (gstring, i);
-
-      if (NILP (this))
+      glyph = LGSTRING_GLYPH (gstring, i);
+      if (NILP (glyph))
        break;
-      if (NILP (LGLYPH_ADJUSTMENT (this)))
-       {
-         if (j < i - 1)
-           for (; j < i; j++)
-             {
-               glyph = LGSTRING_GLYPH (gstring, j);
-               LGLYPH_SET_FROM (glyph, from);
-               LGLYPH_SET_TO (glyph, to);
-             }
-         from = LGLYPH_FROM (this);
-         to = LGLYPH_TO (this);
-         j = i;
-       }
-      else
-       {
-         if (from > LGLYPH_FROM (this))
-           from = LGLYPH_FROM (this);
-         if (to < LGLYPH_TO (this))
-           to = LGLYPH_TO (this);
-       }
+      if (! (LGLYPH_FROM (glyph) <= LGLYPH_TO (glyph)
+            && (LGLYPH_FROM (glyph) == from
+                ? LGLYPH_TO (glyph) == to
+                : LGLYPH_FROM (glyph) == to + 1)))
+       goto shaper_error;
+      from = LGLYPH_FROM (glyph);
+      to = LGLYPH_TO (glyph);
     }
-  if (j < i - 1)
-    for (; j < i; j++)
-      {
-       glyph = LGSTRING_GLYPH (gstring, j);
-       LGLYPH_SET_FROM (glyph, from);
-       LGLYPH_SET_TO (glyph, to);
-      }
+  if (to != LGSTRING_CHAR_LEN (gstring) - 1)
+    goto shaper_error;
   return composition_gstring_put_cache (gstring, XINT (n));
+
+ shaper_error:
+  return Qnil;
 }
 
 DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]