Vertically reflect the table borders for RTL locales
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 1 Dec 2015 17:35:50 +0000 (18:35 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 2 Dec 2015 13:22:17 +0000 (14:22 +0100)
When rendering in a right to left locale, the terminals where a horizontal table
border line meets a vertical border needs to be a mirror image of what is normal
in a left to right locale.  This change does that.

Reported by: Mohammad Haghighat <hosseinhg@hotmail.com>

src/output/ascii.c
src/output/cairo.c
src/output/render.c

index 636d9ecc4fc822ed949f35ddbcce291a2a686e65..bd30677f20fb0be5f065d079dade4ecb6fbf35f9 100644 (file)
@@ -127,7 +127,15 @@ static const ucs4_t unicode_box_chars[N_BOX] =
 static inline int
 make_box_index (int left, int right, int top, int bottom)
 {
-  return ((right * RENDER_N_LINES + bottom) * RENDER_N_LINES + left) * RENDER_N_LINES + top;
+  int start_side = left;
+  int end_side = right;
+  if (render_direction_rtl ())
+    {
+      start_side = right;
+      end_side = left;
+    }
+    
+  return ((end_side * RENDER_N_LINES + bottom) * RENDER_N_LINES + start_side) * RENDER_N_LINES + top;
 }
 
 /* How to emphasize text. */
index 122d1b786f2a28430380e7220b399d0fd5822540..4452b46a8c40b569a06b7cbbf9fc6a8581edd4b9 100644 (file)
@@ -711,9 +711,9 @@ xr_draw_line (void *xr_, int bb[TABLE_N_AXES][2],
   const int x3 = bb[H][1];
   const int y3 = bb[V][1];
   const int top = styles[H][0];
-  const int left = styles[V][0];
   const int bottom = styles[H][1];
-  const int right = styles[V][1];
+  const int start_of_line = render_direction_rtl() ? styles[V][1]: styles[V][0];
+  const int end_of_line   = render_direction_rtl() ? styles[V][0]: styles[V][1];
 
   /* The algorithm here is somewhat subtle, to allow it to handle
      all the kinds of intersections that we need.
@@ -753,7 +753,7 @@ xr_draw_line (void *xr_, int bb[TABLE_N_AXES][2],
      (It doesn't make sense to have different kinds of line on the
      same axis, so we don't try to gracefully handle that case.) */
   bool double_vert = top == RENDER_LINE_DOUBLE || bottom == RENDER_LINE_DOUBLE;
-  bool double_horz = left == RENDER_LINE_DOUBLE || right == RENDER_LINE_DOUBLE;
+  bool double_horz = start_of_line == RENDER_LINE_DOUBLE || end_of_line == RENDER_LINE_DOUBLE;
 
   /* When horizontal lines are doubled,
      the left-side line along y1 normally runs from x0 to x2,
@@ -788,8 +788,8 @@ xr_draw_line (void *xr_, int bb[TABLE_N_AXES][2],
   int x1 = xc - horz_line_ofs;
   int x2 = xc + horz_line_ofs;
 
-  bool shorten_x1_lines = left == RENDER_LINE_DOUBLE;
-  bool shorten_x2_lines = right == RENDER_LINE_DOUBLE;
+  bool shorten_x1_lines = start_of_line == RENDER_LINE_DOUBLE;
+  bool shorten_x2_lines = end_of_line == RENDER_LINE_DOUBLE;
   bool shorten_xc_line = shorten_x1_lines && shorten_x2_lines;
   int vert_line_ofs = double_horz ? double_line_ofs : 0;
   int yc = (y0 + y3) / 2;
@@ -797,11 +797,11 @@ xr_draw_line (void *xr_, int bb[TABLE_N_AXES][2],
   int y2 = yc + vert_line_ofs;
 
   if (!double_horz)
-    horz_line (xr, x0, x1, x2, x3, yc, left, right, shorten_yc_line);
+    horz_line (xr, x0, x1, x2, x3, yc, start_of_line, end_of_line, shorten_yc_line);
   else
     {
-      horz_line (xr, x0, x1, x2, x3, y1, left, right, shorten_y1_lines);
-      horz_line (xr, x0, x1, x2, x3, y2, left, right, shorten_y2_lines);
+      horz_line (xr, x0, x1, x2, x3, y1, start_of_line, end_of_line, shorten_y1_lines);
+      horz_line (xr, x0, x1, x2, x3, y2, start_of_line, end_of_line, shorten_y2_lines);
     }
 
   if (!double_vert)
index b3eb6c93d459251668a8eefc4fafbef42076b92b..642881e08aabe872580a8428dad647da1cc10b25 100644 (file)
@@ -1032,8 +1032,8 @@ render_rule (const struct render_page *page, const int ofs[TABLE_N_AXES],
       if (render_direction_rtl ())
        {
          int temp = bb[H][0];
-         bb[H][0] = page->params->size[H] - bb[H][1];
-         bb[H][1] = page->params->size[H] - temp;
+         bb[H][0] = render_page_get_size (page, H) - bb[H][1];
+         bb[H][1] = render_page_get_size (page, H) - temp;
        }
       bb[V][0] = ofs[V] + page->cp[V][d[V]];
       bb[V][1] = ofs[V] + page->cp[V][d[V] + 1];
@@ -1054,8 +1054,8 @@ render_cell (const struct render_page *page, const int ofs[TABLE_N_AXES],
   if (render_direction_rtl ())
     {
       int temp = bb[H][0];
-      bb[H][0] = clip[H][0] = page->params->size[H] - bb[H][1];
-      bb[H][1] = clip[H][1] = page->params->size[H] - temp;
+      bb[H][0] = clip[H][0] = render_page_get_size (page, H) - bb[H][1];
+      bb[H][1] = clip[H][1] = render_page_get_size (page, H) - temp;
     }
   bb[V][0] = clip[V][0] = ofs[V] + page->cp[V][cell->d[V][0] * 2 + 1];
   bb[V][1] = clip[V][1] = ofs[V] + page->cp[V][cell->d[V][1] * 2];