- int object_spacing = (parse_dimension (opt (d, o, "object-spacing", NULL))
- * scale);
-
- /* Convert to inch/(XR_POINT * 72). */
- xr->left_margin = left_margin * scale;
- xr->right_margin = right_margin * scale;
- xr->top_margin = top_margin * scale;
- xr->bottom_margin = bottom_margin * scale;
- xr->width = (paper_width - left_margin - right_margin) * scale;
- xr->length = (paper_length - top_margin - bottom_margin) * scale;
- xr->min_break[H] = min_break[H] >= 0 ? min_break[H] : xr->width / 2;
- xr->min_break[V] = min_break[V] >= 0 ? min_break[V] : xr->length / 2;
- xr->object_spacing = object_spacing >= 0 ? object_spacing : XR_POINT * 12;
-
- /* There are no headings so headings_height can stay 0. */
-}
-
-static struct xr_driver *
-xr_allocate (const char *name, int device_type, struct string_map *o,
- double font_scale)
-{
- struct xr_driver *xr = xzalloc (sizeof *xr);
- struct output_driver *d = &xr->driver;
-
- output_driver_init (d, &cairo_driver_class, name, device_type);
-
- /* This is a nasty kluge for an issue that does not make sense. On any
- surface other than a screen (e.g. for output to PDF or PS or SVG), the
- fonts are way too big by default. A "9-point" font seems to appear about
- 16 points tall. We use a scale factor for these surfaces to help, but the
- underlying issue is a mystery. */
- xr->font_scale = font_scale;
-
- apply_options (xr, o);
-
- return xr;
-}
-
-static int
-pango_to_xr (int pango)
-{
- return (XR_POINT != PANGO_SCALE
- ? ceil (pango * (1. * XR_POINT / PANGO_SCALE))
- : pango);
-}
-
-static int
-xr_to_pango (int xr)
-{
- return (XR_POINT != PANGO_SCALE
- ? ceil (xr * (1. / XR_POINT * PANGO_SCALE))
- : xr);
-}
-
-static void
-xr_measure_fonts (cairo_t *cairo, PangoFontDescription *fonts[XR_N_FONTS],
- int *char_width, int *char_height)
-{
- *char_width = 0;
- *char_height = 0;
- for (int i = 0; i < XR_N_FONTS; i++)
- {
- PangoLayout *layout = pango_cairo_create_layout (cairo);
- pango_layout_set_font_description (layout, fonts[i]);
-
- pango_layout_set_text (layout, "0", 1);
-
- int cw, ch;
- pango_layout_get_size (layout, &cw, &ch);
- *char_width = MAX (*char_width, pango_to_xr (cw));
- *char_height = MAX (*char_height, pango_to_xr (ch));
-
- g_object_unref (G_OBJECT (layout));
- }
-}
-
-static int
-get_layout_height (PangoLayout *layout)
-{
- int w, h;
- pango_layout_get_size (layout, &w, &h);
- return h;
-}