+static enum outp_justification
+translate_justification (unsigned int opt)
+{
+ switch (opt & TAB_ALIGN_MASK)
+ {
+ case TAB_RIGHT:
+ return OUTP_RIGHT;
+ case TAB_LEFT:
+ return OUTP_LEFT;
+ case TAB_CENTER:
+ return OUTP_CENTER;
+ default:
+ NOT_REACHED ();
+ }
+}
+
+/* Returns the line style to use for drawing a rule of the given
+ TYPE. */
+static enum outp_line_style
+rule_to_draw_type (unsigned char type)
+{
+ switch (type)
+ {
+ case TAL_0:
+ case TAL_GAP:
+ return OUTP_L_NONE;
+ case TAL_1:
+ return OUTP_L_SINGLE;
+ case TAL_2:
+ return OUTP_L_DOUBLE;
+ default:
+ NOT_REACHED ();
+ }
+}
+
+/* Returns the horizontal rule at the given column and row. */
+static int
+get_hrule (int c, int r)
+{
+ return t->rh[c + r * t->cf];
+}
+
+/* Returns the vertical rule at the given column and row. */
+static int
+get_vrule (int c, int r)
+{
+ return t->rv[c + r * (t->cf + 1)];
+}
+
+/* Renders the horizontal rule at the given column and row
+ at (X,Y) on the page. */
+static void
+render_horz_rule (int x, int y, int c, int r)
+{
+ enum outp_line_style style = rule_to_draw_type (get_hrule (c, r));
+ if (style != OUTP_L_NONE)
+ d->class->line (d, x, y, x + t->w[c], y + t->hrh[r],
+ OUTP_L_NONE, style, OUTP_L_NONE, style);
+}
+
+/* Renders the vertical rule at the given column and row
+ at (X,Y) on the page. */
+static void
+render_vert_rule (int x, int y, int c, int r)
+{
+ enum outp_line_style style = rule_to_draw_type (get_vrule (c, r));
+ if (style != OUTP_L_NONE)
+ d->class->line (d, x, y, x + t->wrv[c], y + t->h[r],
+ style, OUTP_L_NONE, style, OUTP_L_NONE);
+}