/* This file uses TABLE_HORZ and TABLE_VERT enough to warrant abbreviating. */
#define H TABLE_HORZ
#define V TABLE_VERT
-
+\f
struct xr_fsm_style *
xr_fsm_style_ref (const struct xr_fsm_style *style_)
{
return style;
}
+struct xr_fsm_style *
+xr_fsm_style_unshare (struct xr_fsm_style *old)
+{
+ assert (old->ref_cnt > 0);
+ if (old->ref_cnt == 1)
+ return old;
+
+ xr_fsm_style_unref (old);
+
+ struct xr_fsm_style *new = xmemdup (old, sizeof *old);
+ new->ref_cnt = 1;
+ for (int i = 0; i < XR_N_FONTS; i++)
+ if (old->fonts[i])
+ new->fonts[i] = pango_font_description_copy (old->fonts[i]);
+
+ return new;
+}
+
void
xr_fsm_style_unref (struct xr_fsm_style *style)
{
if (font_style->typeface)
desc = parse_font (
font_style->typeface,
- font_style->size ? font_style->size * 1000 * xr->style->font_scale : 10000,
+ (font_style->size ? font_style->size * 1000 : 10000) * xr->style->font_scale,
font_style->bold, font_style->italic);
if (!desc)
desc = xr->style->fonts[font_type];
.ops = &xrr_render_ops,
.aux = fsm,
.size = { [H] = style->size[H], [V] = style->size[V] },
- /* XXX font_size */
.line_widths = xr_line_widths,
.min_break = { [H] = style->min_break[H], [V] = style->min_break[V] },
.supports_margins = true,
int char_size[TABLE_N_AXES];
pango_layout_get_size (layout, &char_size[H], &char_size[V]);
- for (int j = 0; j < TABLE_N_AXES; j++)
+ for (int a = 0; a < TABLE_N_AXES; a++)
{
- int csj = pango_to_xr (char_size[j]);
- fsm->rp.font_size[j] = MAX (fsm->rp.font_size[j], csj);
+ int csa = pango_to_xr (char_size[a]);
+ fsm->rp.font_size[a] = MAX (fsm->rp.font_size[a], csa);
}
g_object_unref (G_OBJECT (layout));
}
}
-
/* This is primarily meant for use with screen rendering since the result is a
fixed value for charts. */
void
static int
xr_fsm_draw_table (struct xr_fsm *fsm, int space)
{
- int used = 0;
- while (render_pager_has_next (fsm->p))
- {
- int chunk = render_pager_draw_next (fsm->p, space - used);
- if (!chunk)
- return used;
-
- used += chunk;
- cairo_translate (fsm->cairo, 0, chunk);
- }
- return used;
-}
-
-static void
-xr_draw_chart (const struct chart_item *chart_item, cairo_t *cr,
- double width, double height)
-{
- struct xrchart_geometry geom;
-
- cairo_translate (cr, 0, height);
- cairo_scale (cr, 1.0, -1.0);
- xrchart_geometry_init (cr, &geom, width, height);
- if (is_boxplot (chart_item))
- xrchart_draw_boxplot (chart_item, cr, &geom);
- else if (is_histogram_chart (chart_item))
- xrchart_draw_histogram (chart_item, cr, &geom);
- else if (is_np_plot_chart (chart_item))
- xrchart_draw_np_plot (chart_item, cr, &geom);
- else if (is_piechart (chart_item))
- xrchart_draw_piechart (chart_item, cr, &geom);
- else if (is_barchart (chart_item))
- xrchart_draw_barchart (chart_item, cr, &geom);
- else if (is_roc_chart (chart_item))
- xrchart_draw_roc (chart_item, cr, &geom);
- else if (is_scree (chart_item))
- xrchart_draw_scree (chart_item, cr, &geom);
- else if (is_spreadlevel_plot_chart (chart_item))
- xrchart_draw_spreadlevel (chart_item, cr, &geom);
- else if (is_scatterplot_chart (chart_item))
- xrchart_draw_scatterplot (chart_item, cr, &geom);
- else
- NOT_REACHED ();
- xrchart_geometry_free (cr, &geom);
+ return (render_pager_has_next (fsm->p)
+ ? render_pager_draw_next (fsm->p, space)
+ : 0);
}
static int