|| a->min_break[V] != b->min_break[V]
|| a->use_system_colors != b->use_system_colors
|| a->transparent != b->transparent
- || a->font_scale != b->font_scale)
+ || a->font_resolution != b->font_resolution)
return false;
for (size_t i = 0; i < XR_N_FONTS; i++)
if (font_style->typeface)
desc = parse_font (
font_style->typeface,
- (font_style->size ? font_style->size * 1000 : 10000) * xr->style->font_scale,
+ font_style->size ? font_style->size * 1000 : 10000,
font_style->bold, font_style->italic);
if (!desc)
desc = xr->style->fonts[font_type];
assert (xr->cairo);
PangoContext *context = pango_cairo_create_context (xr->cairo);
- if (xr->style->font_scale != 1.0)
- pango_cairo_context_set_resolution (context, 72.0);
+ 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;
for (int i = 0; i < XR_N_FONTS; i++)
{
- PangoLayout *layout = pango_cairo_create_layout (cr);
+ PangoContext *context = pango_cairo_create_context (cr);
+ 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);
static int
xr_render_page_heading (cairo_t *cairo, const PangoFontDescription *font,
const struct page_heading *ph, int page_number,
- int width, bool draw, int base_y)
+ int width, int base_y, double font_resolution)
{
- PangoLayout *layout = pango_cairo_create_layout (cairo);
+ PangoContext *context = pango_cairo_create_context (cairo);
+ pango_cairo_context_set_resolution (context, font_resolution);
+ PangoLayout *layout = pango_layout_new (context);
+ g_object_unref (context);
+
pango_layout_set_font_description (layout, font);
int y = 0;
: pp->halign == TABLE_HALIGN_MIXED ? PANGO_ALIGN_LEFT
: PANGO_ALIGN_RIGHT));
pango_layout_set_width (layout, xr_to_pango (width));
- if (draw)
- {
- cairo_save (cairo);
- cairo_translate (cairo, 0, xr_to_pt (y + base_y));
- pango_cairo_show_layout (cairo, layout);
- cairo_restore (cairo);
- }
+
+ cairo_save (cairo);
+ cairo_translate (cairo, 0, xr_to_pt (y + base_y));
+ pango_cairo_show_layout (cairo, layout);
+ cairo_restore (cairo);
y += pango_to_xr (get_layout_height (layout));
}
{
int *h = &heading_heights[i];
*h = xr_render_page_heading (cairo, fs->fonts[XR_FONT_PROPORTIONAL],
- &ps->headings[i], -1, fs->size[H], false,
- 0);
+ &ps->headings[i], -1, fs->size[H], 0,
+ fs->font_resolution);
if (*h)
*h += ps->object_spacing;
}
xr_pager_create (const struct xr_page_style *ps_,
const struct xr_fsm_style *fs_)
{
- printf ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
struct xr_page_style *ps = xr_page_style_ref (ps_);
struct xr_fsm_style *fs = xr_fsm_style_ref (fs_);
{
if (p)
{
- printf (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
xr_page_style_unref (p->page_style);
xr_fsm_style_unref (p->fsm_style);
void
xr_pager_add_item (struct xr_pager *p, const struct output_item *item)
{
- printf ("add_item\n");
assert (!p->item);
p->item = output_item_ref (item);
xr_pager_run (p);
void
xr_pager_add_page (struct xr_pager *p, cairo_t *cr)
{
- printf ("add_page\n");
assert (!p->cr);
cairo_save (cr);
p->cr = cr;
int page_number = p->page_index++ + ps->initial_page_number;
if (p->heading_heights[0])
xr_render_page_heading (cr, font, &ps->headings[0], page_number,
- fs->size[H], true, -p->heading_heights[0]);
+ fs->size[H], -p->heading_heights[0],
+ fs->font_resolution);
if (p->heading_heights[1])
xr_render_page_heading (cr, font, &ps->headings[1], page_number,
- fs->size[H], true,
- fs->size[V] + ps->object_spacing);
+ fs->size[H], fs->size[V] + ps->object_spacing,
+ fs->font_resolution);
xr_pager_run (p);
}
static void
xr_pager_run (struct xr_pager *p)
{
- printf ("run:\n");
if (p->item && p->cr && p->y < p->fsm_style->size[V])
{
if (!p->fsm)
{
- printf ("\tcreate fsm\n");
p->fsm = xr_fsm_create (p->item, p->fsm_style, p->cr);
if (!p->fsm)
{
- printf ("\t(was null)\n");
output_item_unref (p->item);
p->item = NULL;
for (;;)
{
- printf ("\tdraw slice\n");
int spacing = p->page_style->object_spacing;
int chunk = xr_fsm_draw_slice (p->fsm, p->cr,
p->fsm_style->size[V] - p->y);
if (xr_fsm_is_empty (p->fsm))
{
- printf ("\tfinished object\n");
xr_fsm_destroy (p->fsm);
p->fsm = NULL;
output_item_unref (p->item);
}
else if (!chunk)
{
- printf ("\tobject doesn't fit on page\n");
assert (p->y > 0);
p->y = INT_MAX;
return;
}
- printf ("\tneed to draw another slice\n");
}
}
- if (!p->item)
- printf ("\tno item\n");
- if (!p->cr)
- printf ("\tno page\n");
}
return desc;
}
-/* FONT_SCALE 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. */
static struct xr_driver *
-xr_allocate (const char *name, int device_type, struct string_map *o,
- double font_scale)
+xr_allocate (const char *name, int device_type, struct string_map *o)
{
struct xr_driver *xr = xzalloc (sizeof *xr);
struct output_driver *d = &xr->driver;
.fg = fg,
.use_system_colors = systemcolors,
.transparent = transparent,
- .font_scale = font_scale,
+ .font_resolution = 72.0,
};
return xr;
struct string_map *o, enum xr_output_type file_type)
{
const char *file_name = fh_get_file_name (fh);
- struct xr_driver *xr = xr_allocate (file_name, device_type, o, 72.0 / 128.0);
+ struct xr_driver *xr = xr_allocate (file_name, device_type, o);
double paper[TABLE_N_AXES];
for (int a = 0; a < TABLE_N_AXES; a++)