]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix display of R2L lines when the last character fits only partially.
authorEli Zaretskii <eliz@gnu.org>
Fri, 1 Aug 2014 09:39:04 +0000 (12:39 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 1 Aug 2014 09:39:04 +0000 (12:39 +0300)
 See http://lists.gnu.org/archive/html/emacs-devel/2014-07/msg00476.html
 for the details.
 src/xdisp.c (extend_face_to_end_of_line): If the last glyph of an
 R2L row is visible only partially, give the row a negative x
 offset.
 (display_line): Fix the calculation of the glyph whose pixel width
 is used to decide whether the last produced glyph fits on the
 line.  When the last glyph fits only partially, give the row a
 negative x offset.

src/ChangeLog
src/xdisp.c

index 9d5e76871108827120bcde10090533bc57e48866..13415734c798530372edbd181b5ad5417cac3a8f 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-01  Eli Zaretskii  <eliz@gnu.org>
+
+       Fix display of R2L lines when the last character fits only partially.
+       See http://lists.gnu.org/archive/html/emacs-devel/2014-07/msg00476.html
+       for the details.
+       * xdisp.c (extend_face_to_end_of_line): If the last glyph of an
+       R2L row is visible only partially, give the row a negative x
+       offset.
+       (display_line): Fix the calculation of the glyph whose pixel width
+       is used to decide whether the last produced glyph fits on the
+       line.  When the last glyph fits only partially, give the row a
+       negative x offset.
+
 2014-07-29  Eli Zaretskii  <eliz@gnu.org>
 
        Fix hscroll of R2L lines that begin with a TAB or another wide glyph.
index e9e8ad6594e10fc8c30a760097b0aff4a9a7716d..776e4d000eeaa1818cf1552c3365b2335bc4d8b8 100644 (file)
@@ -19316,6 +19316,12 @@ extend_face_to_end_of_line (struct it *it)
              it->face_id = saved_face_id;
              it->start_of_box_run_p = saved_box_start;
            }
+         /* If stretch_width comes out negative, it means that the
+            last glyph is only partially visible.  In R2L rows, we
+            want the leftmost glyph to be partially visible, so we
+            need to give the row the corresponding left offset.  */
+         if (stretch_width < 0)
+           it->glyph_row->x = stretch_width;
        }
 #endif /* HAVE_WINDOW_SYSTEM */
     }
@@ -20207,7 +20213,13 @@ display_line (struct it *it)
 
          for (i = 0; i < nglyphs; ++i, x = new_x)
            {
-             glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
+             /* Identify the glyphs added by the last call to
+                PRODUCE_GLYPHS.  In R2L rows, they are prepended to
+                the previous glyphs.  */
+             if (!row->reversed_p)
+               glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
+             else
+               glyph = row->glyphs[TEXT_AREA] + nglyphs - 1 - i;
              new_x = x + glyph->pixel_width;
 
              if (/* Lines are continued.  */
@@ -20415,6 +20427,12 @@ display_line (struct it *it)
                       suitable change to the stretch glyph that is
                       the leftmost glyph of the line.  */
                    row->x = x - it->first_visible_x;
+                 /* When the last glyph of an R2L row only fits
+                    partially on the line, we need to set row->x to a
+                    negative offset, so that the leftmost glyph is
+                    the one that is partially visible.  */
+                 if (row->reversed_p && new_x > it->last_visible_x)
+                   row->x = it->last_visible_x - new_x;
                }
              else
                {