/* 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)
{
pango_cairo_context_set_resolution (context, xr->style->font_resolution);
PangoLayout *layout = pango_layout_new (context);
g_object_unref (context);
+
pango_layout_set_font_description (layout, desc);
const char *text = cell->text;
.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,
pango_cairo_context_set_resolution (context, style->font_resolution);
PangoLayout *layout = pango_layout_new (context);
g_object_unref (context);
+
pango_layout_set_font_description (layout, style->fonts[i]);
pango_layout_set_text (layout, "0", 1);
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;
+ return (render_pager_has_next (fsm->p)
+ ? render_pager_draw_next (fsm->p, space)
+ : 0);
}
static int