emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r101328: Fix display of composed R2L


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101328: Fix display of composed R2L text on MS-Windows.
Date: Sat, 04 Sep 2010 18:16:08 +0300
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101328
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2010-09-04 18:16:08 +0300
message:
  Fix display of composed R2L text on MS-Windows.
  
   w32uniscribe.c (uniscribe_shape): Update commentary.  Don't
   try to reorder grapheme clusters, since LGSTRING should always
   hold them in the logical order.
   (uniscribe_encode_char, uniscribe_shape): Force ScriptShape to
   return glyph codes in the logical order.
modified:
  src/ChangeLog
  src/w32uniscribe.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-09-04 10:43:43 +0000
+++ b/src/ChangeLog     2010-09-04 15:16:08 +0000
@@ -1,3 +1,11 @@
+2010-09-04  Eli Zaretskii  <address@hidden>
+
+       * w32uniscribe.c (uniscribe_shape): Update commentary.  Don't
+       try to reorder grapheme clusters, since LGSTRING should always
+       hold them in the logical order.
+       (uniscribe_encode_char, uniscribe_shape): Force ScriptShape to
+       return glyph codes in the logical order.
+
 2010-09-04  Andreas Schwab  <address@hidden>
 
        * image.c (imagemagick_image_p): Replace bcopy by memcpy.

=== modified file 'src/w32uniscribe.c'
--- a/src/w32uniscribe.c        2010-07-07 22:18:28 +0000
+++ b/src/w32uniscribe.c        2010-09-04 15:16:08 +0000
@@ -180,17 +180,18 @@
 
 /* Uniscribe implementation of shape for font backend.
 
-   Shape text in LGSTRING.  See the docstring of `font-make-gstring'
-   for the format of LGSTRING.  If the (N+1)th element of LGSTRING
-   is nil, input of shaping is from the 1st to (N)th elements.  In
-   each input glyph, FROM, TO, CHAR, and CODE are already set.
+   Shape text in LGSTRING.  See the docstring of
+   `composition-get-gstring' for the format of LGSTRING.  If the
+   (N+1)th element of LGSTRING is nil, input of shaping is from the
+   1st to (N)th elements.  In each input glyph, FROM, TO, CHAR, and
+   CODE are already set.
 
    This function updates all fields of the input glyphs.  If the
    output glyphs (M) are more than the input glyphs (N), (N+1)th
    through (M)th elements of LGSTRING are updated possibly by making
    a new glyph object and storing it in LGSTRING.  If (M) is greater
-   than the length of LGSTRING, nil should be return.  In that case,
-   this function is called again with the larger LGSTRING.  */
+   than the length of LGSTRING, nil should be returned.  In that case,
+   this function is called again with a larger LGSTRING.  */
 static Lisp_Object
 uniscribe_shape (Lisp_Object lgstring)
 {
@@ -217,6 +218,9 @@
   max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring);
   done_glyphs = 0;
   chars = (wchar_t *) alloca (nchars * sizeof (wchar_t));
+  /* FIXME: This loop assumes that characters in the input LGSTRING
+     are all inside the BMP.  Need to encode characters beyond the BMP
+     as UTF-16.  */
   for (i = 0; i < nchars; i++)
     {
       /* lgstring can be bigger than the number of characters in it, in
@@ -248,9 +252,6 @@
       return Qnil;
     }
 
-  /* TODO: When we get BIDI support, we need to call ScriptLayout here.
-     Requires that we know the surrounding context.  */
-
   glyphs = alloca (max_glyphs * sizeof (WORD));
   clusters = alloca (nchars * sizeof (WORD));
   attributes = alloca (max_glyphs * sizeof (SCRIPT_VISATTR));
@@ -259,8 +260,12 @@
 
   for (i = 0; i < nitems; i++)
     {
-      int nglyphs, nchars_in_run, rtl = items[i].a.fRTL ? -1 : 1;
+      int nglyphs, nchars_in_run;
       nchars_in_run = items[i+1].iCharPos - items[i].iCharPos;
+      /* Force ScriptShape to generate glyphs in the same order as
+        they are in the input LGSTRING, which is in the logical
+        order.  */
+      items[i].a.fLogicalOrder = 1;
 
       /* Context may be NULL here, in which case the cache should be
          used without needing to select the font.  */
@@ -321,7 +326,7 @@
            {
              int j, nclusters, from, to;
 
-             from = rtl > 0 ? 0 : nchars_in_run - 1;
+             from = 0;
              to = from;
 
              for (j = 0; j < nglyphs; j++)
@@ -342,22 +347,19 @@
                  gl = glyphs[j];
                  LGLYPH_SET_CODE (lglyph, gl);
 
-                 /* Detect clusters, for linking codes back to characters.  */
+                 /* Detect clusters, for linking codes back to
+                    characters.  */
                  if (attributes[j].fClusterStart)
                    {
-                     while (from >= 0 && from < nchars_in_run
-                            && clusters[from] < j)
-                       from += rtl;
-                     if (from < 0)
-                       from = to = 0;
-                     else if (from >= nchars_in_run)
+                     while (from < nchars_in_run && clusters[from] < j)
+                       from++;
+                     if (from >= nchars_in_run)
                        from = to = nchars_in_run - 1;
                      else
                        {
                          int k;
-                         to = rtl > 0 ? nchars_in_run - 1 : 0;
-                         for (k = from + rtl; k >= 0 && k < nchars_in_run;
-                              k += rtl)
+                         to = nchars_in_run - 1;
+                         for (k = from + 1; k < nchars_in_run; k++)
                            {
                              if (clusters[k] > j)
                                {
@@ -486,6 +488,10 @@
           SCRIPT_VISATTR attrs[2];
           int nglyphs;
 
+         /* Force ScriptShape to generate glyphs in the logical
+            order.  */
+         items[0].a.fLogicalOrder = 1;
+
           result = ScriptShape (context, &(uniscribe_font->cache),
                                 ch, len, 2, &(items[0].a),
                                 glyphs, clusters, attrs, &nglyphs);


reply via email to

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