- string_map_init (&options);
- string_map_insert_nocopy (&options, xstrdup ("paper-size"),
- c_xasprintf("%.2fx%.2fmm", width, height));
- string_map_insert_nocopy (&options, xstrdup ("left-margin"),
- c_xasprintf ("%.2fmm", left_margin));
- string_map_insert_nocopy (&options, xstrdup ("right-margin"),
- c_xasprintf ("%.2fmm", right_margin));
- string_map_insert_nocopy (&options, xstrdup ("top-margin"),
- c_xasprintf ("%.2fmm", top_margin));
- string_map_insert_nocopy (&options, xstrdup ("bottom-margin"),
- c_xasprintf ("%.2fmm", bottom_margin));
-
- view->print_xrd = xr_driver_create (get_cairo_context_from_print_context (context), &options);
-
- string_map_destroy (&options);
+ enum { H = TABLE_HORZ, V = TABLE_VERT };
+ int paper[TABLE_N_AXES] = {
+ [H] = gtk_page_setup_get_paper_width (ps, GTK_UNIT_POINTS) * XR_POINT,
+ [V] = gtk_page_setup_get_paper_height (ps, GTK_UNIT_POINTS) * XR_POINT,
+ };
+
+ /* These are all 1/2 inch. The "margins" that GTK+ gives us are useless:
+ they are the printer's imagable area. */
+ int margins[TABLE_N_AXES][2] = {
+ [H][0] = XR_POINT * 36,
+ [H][1] = XR_POINT * 36,
+ [V][0] = XR_POINT * 36,
+ [V][1] = XR_POINT * 36,
+ };
+
+ double size[TABLE_N_AXES];
+ for (int a = 0; a < TABLE_N_AXES; a++)
+ size[a] = paper[a] - margins[a][0] - margins[a][1];
+
+ view->page_style = xmalloc (sizeof *view->page_style);
+ *view->page_style = (struct xr_page_style) {
+ .ref_cnt = 1,
+
+ .margins = {
+ [H] = { margins[H][0], margins[H][1] },
+ [V] = { margins[V][0], margins[V][1] },
+ },
+ .initial_page_number = 1,
+ };
+
+ view->fsm_style = xmalloc (sizeof *view->fsm_style);
+ *view->fsm_style = (struct xr_fsm_style) {
+ .ref_cnt = 1,
+
+ .size = { [H] = size[H], [V] = size[V] },
+ .min_break = { [H] = size[H] / 2, [V] = size[V] / 2 },
+ .font = pango_font_description_from_string ("Sans Serif 10"),
+ .fg = CELL_COLOR_BLACK,
+ .use_system_colors = false,
+ .object_spacing = 12 * XR_POINT,
+ .font_resolution = 72.0
+ };
+
+ view->pager = xr_pager_create (view->page_style, view->fsm_style);