below for the allowed forms of @var{dimension} Default: @code{0.5in}.
@item @option{-O prop-font=@var{font-name}}
-@itemx @option{-O fixed-font=@var{font-name}}
-Sets the font used for proportional, or fixed-pitch text. Most
-systems support CSS-like font names such as ``serif'' and
-``monospace'', but a wide range of system-specific font are likely to
-be supported as well.
+Sets the default font used for ordinary text. Most systems support
+CSS-like font names such as ``Sans Serif'', but a wide range of
+system-specific fonts are likely to be supported as well.
-Default: proportional font @code{serif}, fixed-pitch font @code{monospace}.
+Default: proportional font @code{Sans Serif}.
@item @option{-O font-size=@var{font-size}}
Sets the size of the default fonts, in thousandths of a point. Default:
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]);
+ if (old->font)
+ new->font = pango_font_description_copy (old->font);
return new;
}
assert (style->ref_cnt > 0);
if (!--style->ref_cnt)
{
- for (size_t i = 0; i < XR_N_FONTS; i++)
- pango_font_description_free (style->fonts[i]);
+ pango_font_description_free (style->font);
free (style);
}
}
|| a->size[V] != b->size[V]
|| a->min_break[H] != b->min_break[H]
|| a->min_break[V] != b->min_break[V]
+ || !pango_font_description_equal (a->font, b->font)
|| a->use_system_colors != b->use_system_colors
|| a->font_resolution != b->font_resolution)
return false;
- for (size_t i = 0; i < XR_N_FONTS; i++)
- if (!pango_font_description_equal (a->fonts[i], b->fonts[i]))
- return false;
-
return true;
}
\f
enum table_axis Y = !X;
int R = options & TAB_ROTATE ? 0 : 1;
- enum xr_font_type font_type = (options & TAB_FIX
- ? XR_FONT_FIXED
- : XR_FONT_PROPORTIONAL);
PangoFontDescription *desc = NULL;
if (font_style->typeface)
desc = parse_font (
font_style->size ? font_style->size * 1000 : 10000,
font_style->bold, font_style->italic);
if (!desc)
- desc = xr->style->fonts[font_type];
+ desc = xr->style->font;
assert (xr->cairo);
PangoContext *context = pango_cairo_create_context (xr->cairo);
pango_layout_set_attributes (layout, NULL);
- if (desc != xr->style->fonts[font_type])
+ if (desc != xr->style->font)
pango_font_description_free (desc);
g_object_unref (G_OBJECT (layout));
fsm->cairo = NULL;
}
- for (int i = 0; i < XR_N_FONTS; i++)
- {
- 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]);
+ /* Get font size. */
+ 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_text (layout, "0", 1);
+ pango_layout_set_font_description (layout, style->font);
- int char_size[TABLE_N_AXES];
- pango_layout_get_size (layout, &char_size[H], &char_size[V]);
- for (int a = 0; a < TABLE_N_AXES; a++)
- {
- int csa = pango_to_xr (char_size[a]);
- fsm->rp.font_size[a] = MAX (fsm->rp.font_size[a], csa);
- }
+ pango_layout_set_text (layout, "0", 1);
- g_object_unref (G_OBJECT (layout));
+ int char_size[TABLE_N_AXES];
+ pango_layout_get_size (layout, &char_size[H], &char_size[V]);
+ for (int a = 0; a < TABLE_N_AXES; a++)
+ {
+ 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));
+
return fsm;
}
(Thus, XR_POINT units represent one point.) */
#define XR_POINT PANGO_SCALE
-enum xr_font_type
- {
- XR_FONT_PROPORTIONAL,
- XR_FONT_FIXED,
- XR_N_FONTS
- };
-
struct xr_fsm_style
{
int ref_cnt;
int size[TABLE_N_AXES]; /* Page size. */
int min_break[TABLE_N_AXES]; /* Minimum cell size to allow breaking. */
- PangoFontDescription *fonts[XR_N_FONTS];
+ PangoFontDescription *font;
struct cell_color fg;
bool use_system_colors;
for (int i = 0; i < 2; i++)
{
int *h = &heading_heights[i];
- *h = xr_render_page_heading (cairo, fs->fonts[XR_FONT_PROPORTIONAL],
+ *h = xr_render_page_heading (cairo, fs->font,
&ps->headings[i], -1, fs->size[H], 0,
fs->font_resolution);
if (*h)
xr_to_pt (ps->margins[H][0]),
xr_to_pt (ps->margins[V][0]));
- const PangoFontDescription *font = fs->fonts[XR_FONT_PROPORTIONAL];
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,
+ xr_render_page_heading (cr, fs->font, &ps->headings[0], page_number,
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,
+ xr_render_page_heading (cr, fs->font, &ps->headings[1], page_number,
fs->size[H], fs->size[V] + ps->object_spacing,
fs->font_resolution);
min_break[a] = size[a] / 2;
int font_size = parse_int (opt (d, o, "font-size", "10000"), 1000, 1000000);
- PangoFontDescription *fixed_font = parse_font_option
- (d, o, "fixed-font", "monospace", font_size, false, false);
- PangoFontDescription *proportional_font = parse_font_option (
- d, o, "prop-font", "sans serif", font_size, false, false);
+ PangoFontDescription *font = parse_font_option (
+ d, o, "prop-font", "Sans Serif", font_size, false, false);
struct cell_color fg = parse_color (opt (d, o, "foreground-color", "black"));
.ref_cnt = 1,
.size = { [H] = size[H], [V] = size[V] },
.min_break = { [H] = min_break[H], [V] = min_break[V] },
- .fonts = {
- [XR_FONT_PROPORTIONAL] = proportional_font,
- [XR_FONT_FIXED] = fixed_font,
- },
+ .font = font,
.fg = fg,
.use_system_colors = systemcolors,
.font_resolution = font_resolution,
[H] = setup->paper[H] * scale / 2,
[V] = setup->paper[V] * scale / 2,
},
+ .font = pango_font_description_copy (old_fs->font),
.fg = old_fs->fg,
.use_system_colors = old_fs->use_system_colors,
.font_resolution = old_fs->font_resolution,
};
- for (size_t i = 0; i < XR_N_FONTS; i++)
- xr->fsm_style->fonts[i] = pango_font_description_copy (old_fs->fonts[i]);
xr_fsm_style_unref (old_fs);
xr_set_surface_size (xr->dest_surface, xr->output_type,
const struct table_cell *cell)
{
const char *s = cell->text;
- if (cell->options & TAB_FIX)
- escape_tag (html->file, "tt", s, " ", "<br>");
- else
- {
- s += strspn (s, CC_SPACES);
- escape_string (html->file, s, " ", "<br>");
- }
+ s += strspn (s, CC_SPACES);
+ escape_string (html->file, s, " ", "<br>");
if (cell->n_subscripts)
{
enum
{
TAB_NONE = 0,
- TAB_FIX = 1 << 1, /* Use fixed font. */
TAB_MARKUP = 1 << 2, /* Text contains Pango markup. */
TAB_NUMERIC = 1 << 3, /* Cell contents are numeric. */
TAB_ROTATE = 1 << 4, /* Rotate cell contents 90 degrees. */
int opts = 0;
if (text_item->style.markup)
opts |= TAB_MARKUP;
- if (text_item->type == TEXT_ITEM_SYNTAX || text_item->type == TEXT_ITEM_LOG)
- opts |= TAB_FIX;
table_text (tab, 0, 0, opts, text_item_get_text (text_item));
struct table_item *table_item = table_item_create (tab);
text_item_unref (text_item);
PangoFontDescription *pf;
gtk_style_context_get (context, state, "font", &pf, NULL);
- PangoFontDescription *ff = pango_font_description_from_string ("Monospace");
- pango_font_description_set_size (ff, pango_font_description_get_size (pf));
struct xr_fsm_style *style = xmalloc (sizeof *style);
*style = (struct xr_fsm_style) {
.ref_cnt = 1,
.size = { [TABLE_HORZ] = xr_width, [TABLE_VERT] = INT_MAX },
.min_break = { [TABLE_HORZ] = xr_width / 2, [TABLE_VERT] = 0 },
- .fonts = {
- [XR_FONT_PROPORTIONAL] = pf,
- [XR_FONT_FIXED] = ff,
- },
+ .font = pf,
.use_system_colors = true,
.font_resolution = 96.0,
};
for (int a = 0; a < TABLE_N_AXES; a++)
size[a] = paper[a] - margins[a][0] - margins[a][1];
- PangoFontDescription *proportional_font
- = pango_font_description_from_string ("Sans Serif 10");
- PangoFontDescription *fixed_font
- = pango_font_description_from_string ("Monospace 10");
-
view->page_style = xmalloc (sizeof *view->page_style);
*view->page_style = (struct xr_page_style) {
.ref_cnt = 1,
.size = { [H] = size[H], [V] = size[V] },
.min_break = { [H] = size[H] / 2, [V] = size[V] / 2 },
- .fonts = {
- [XR_FONT_PROPORTIONAL] = proportional_font,
- [XR_FONT_FIXED] = fixed_font,
- },
+ .font = pango_font_description_from_string ("Sans Serif 10"),
.fg = CELL_COLOR_BLACK,
.use_system_colors = false,
.font_resolution = 72.0