int headings_height[2];
/* Internal state. */
- struct render_params *params;
double font_scale;
int char_width, char_height;
cairo_t *cairo;
xr_set_cairo (struct xr_driver *xr, cairo_t *cairo)
{
xr->cairo = cairo;
-
cairo_set_line_width (xr->cairo, xr_to_pt (XR_LINE_WIDTH));
-
- xr_measure_fonts (xr->cairo, xr->fonts, &xr->char_width, &xr->char_height);
-
- for (int i = 0; i < XR_N_FONTS; i++)
- {
- struct xr_font *font = &xr->fonts[i];
- font->layout = pango_cairo_create_layout (cairo);
- pango_layout_set_font_description (font->layout, font->desc);
- }
-
- if (xr->params == NULL)
- {
- static const struct render_ops xr_render_ops = {
- .draw_line = xr_draw_line,
- .measure_cell_width = xr_measure_cell_width,
- .measure_cell_height = xr_measure_cell_height,
- .adjust_break = xr_adjust_break,
- .draw_cell = xr_draw_cell,
- };
-
- xr->params = xmalloc (sizeof *xr->params);
- xr->params->ops = &xr_render_ops;
- xr->params->aux = xr;
- xr->params->size[H] = xr->width;
- xr->params->size[V] = xr->length;
- xr->params->font_size[H] = xr->char_width;
- xr->params->font_size[V] = xr->char_height;
-
- enum { LW = XR_LINE_WIDTH, LS = XR_LINE_SPACE };
- static const int xr_line_widths[RENDER_N_LINES] =
- {
- [RENDER_LINE_NONE] = 0,
- [RENDER_LINE_SINGLE] = LW,
- [RENDER_LINE_DASHED] = LW,
- [RENDER_LINE_THICK] = LW * 2,
- [RENDER_LINE_THIN] = LW / 2,
- [RENDER_LINE_DOUBLE] = 2 * LW + LS,
- };
- xr->params->line_widths = xr_line_widths;
-
- for (int i = 0; i < TABLE_N_AXES; i++)
- xr->params->min_break[i] = xr->min_break[i];
- xr->params->supports_margins = true;
- xr->params->rtl = render_direction_rtl ();
- }
-
if (!xr->systemcolors)
cairo_set_source_rgb (xr->cairo,
xr->fg.r / 255.0, xr->fg.g / 255.0, xr->fg.b / 255.0);
g_object_unref (font->layout);
}
- free (xr->params);
free (xr);
}
xr_driver_next_page (xr, xr->cairo);
}
- xr_driver_output_item (xr, output_item);
- while (xr_driver_need_new_page (xr))
+ struct xr_fsm *fsm = xr_fsm_create (output_item, driver->style, xr->cairo);
+ for (;;)
{
- cairo_restore (xr->cairo);
+ int used = xr_fsm_draw_slice (fsm, xr->cairo, xr->length - xr->y);
+ cairo_translate (xr->cairo, 0, used);
+ if (xr_fsm_is_empty (fsm))
+ break;
+
cairo_show_page (xr->cairo);
- cairo_save (xr->cairo);
xr_driver_next_page (xr, xr->cairo);
}
}
xr_render_page_heading (xr->cairo, xr->fonts[XR_FONT_PROPORTIONAL].desc,
&xr->headings[1], xr->page_number, xr->width, true,
xr->length);
-
- xr_driver_run_fsm (xr);
}
/* Start rendering OUTPUT_ITEM to XR. Only valid if XR is not in the middle of
output_driver_destroy (&xr->driver);
}
}
+
static void
xr_draw_chart (const struct chart_item *chart_item, cairo_t *cr,
double x, double y, double width, double height)