-static int
-ascii_layout_subtable (struct ascii_driver *a,
- const struct cell_contents *contents,
- int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2] UNUSED,
- int *widthp)
-{
- const struct table *table = contents->table;
- struct render_params params;
- struct render_page *page;
- int r[TABLE_N_AXES][2];
- int width, height;
- int i;
-
- params.draw_line = ascii_draw_line;
- params.measure_cell_width = ascii_measure_cell_width;
- params.measure_cell_height = ascii_measure_cell_height;
- params.adjust_break = NULL;
- params.draw_cell = ascii_draw_cell,
- params.aux = a;
- params.size[H] = bb[TABLE_HORZ][1] - bb[TABLE_HORZ][0];
- params.size[V] = bb[TABLE_VERT][1] - bb[TABLE_VERT][0];
- params.font_size[H] = 1;
- params.font_size[V] = 1;
- for (i = 0; i < RENDER_N_LINES; i++)
- {
- int width = i == RENDER_LINE_NONE ? 0 : 1;
- params.line_widths[H][i] = width;
- params.line_widths[V][i] = width;
- }
-
- page = render_page_create (¶ms, table);
- width = render_page_get_size (page, TABLE_HORZ);
- height = render_page_get_size (page, TABLE_VERT);
-
- /* r = intersect(bb, clip) - bb. */
- for (i = 0; i < TABLE_N_AXES; i++)
- {
- r[i][0] = MAX (bb[i][0], clip[i][0]) - bb[i][0];
- r[i][1] = MIN (bb[i][1], clip[i][1]) - bb[i][0];
- }
-
- if (r[H][0] < r[H][1] && r[V][0] < r[V][1])
- {
- unsigned int alignment = contents->options & TAB_ALIGNMENT;
- int save_x = a->x;
-
- a->x += bb[TABLE_HORZ][0];
- if (alignment == TAB_RIGHT)
- a->x += params.size[H] - width;
- else if (alignment == TAB_CENTER)
- a->x += (params.size[H] - width) / 2;
- a->y += bb[TABLE_VERT][0];
- render_page_draw (page);
- a->y -= bb[TABLE_VERT][0];
- a->x = save_x;
- }
- render_page_unref (page);
-
- if (width > *widthp)
- *widthp = width;
- return bb[V][0] + height;
-}
-