SETTINGS_VALUE_SHOW_DEFAULT);
char *label = in->label ? xstrdup (in->label) : NULL;
struct text_item *item = text_item_create_nocopy (type, text, label);
- const struct font_style *font = value->font_style;
- if (font)
+
+ if (value->font_style)
{
- item->bold = font->bold;
- item->italic = font->italic;
- item->underline = font->underline;
- item->markup = font->markup;
- if (font->typeface)
- item->typeface = xstrdup (font->typeface);
- item->size = font->size;
+ font_style_uninit (&item->style);
+ font_style_copy (NULL, &item->style, value->font_style);
}
text_item_submit (item);
}
fputs (" underline", stdout);
}
+bool
+font_style_equal (const struct font_style *a, const struct font_style *b)
+{
+ return (a->bold == b->bold
+ && a->italic == b->italic
+ && a->underline == b->underline
+ && a->markup == b->markup
+ && cell_color_equal (&a->fg[0], &b->fg[0])
+ && cell_color_equal (&a->fg[1], &b->fg[1])
+ && cell_color_equal (&a->bg[0], &b->bg[0])
+ && cell_color_equal (&a->bg[1], &b->bg[1])
+ && !strcmp (a->typeface ? a->typeface : "",
+ b->typeface ? b->typeface : "")
+ && a->size == b->size);
+}
+
void
cell_style_dump (const struct cell_style *c)
{
.output_item.label = label,
.text = text,
.type = type,
+ .style = FONT_STYLE_INITIALIZER,
};
+
+ if (type == TEXT_ITEM_SYNTAX || type == TEXT_ITEM_LOG)
+ {
+ free (item->style.typeface);
+ item->style.typeface = xstrdup ("Monospaced");
+ }
+
return item;
}
.output_item = OUTPUT_ITEM_CLONE_INITIALIZER (&old->output_item),
.text = xstrdup (old->text),
.type = old->type,
- .bold = old->bold,
- .italic = old->italic,
- .underline = old->underline,
- .markup = old->markup,
- .typeface = old->typeface ? xstrdup (old->typeface) : NULL,
- .size = old->size
};
+ font_style_copy (NULL, &new->style, &old->style);
return new;
}
|| (dst->type != TEXT_ITEM_SYNTAX && dst->type != TEXT_ITEM_LOG)
|| strcmp (output_item_get_label (&dst->output_item),
output_item_get_label (&src->output_item))
- || dst->bold != src->bold
- || dst->italic != src->italic
- || dst->underline != src->underline
- || dst->markup
- || src->markup
- || strcmp (dst->typeface ? dst->typeface : "",
- src->typeface ? src->typeface : "")
- || dst->size != src->size)
+ || !font_style_equal (&dst->style, &src->style)
+ || dst->style.markup)
return false;
else
{
struct table *tab = table_create (1, 1, 0, 0, 0, 0);
struct table_area_style *style = pool_alloc (tab->container, sizeof *style);
- *style = (struct table_area_style) { TABLE_AREA_STYLE_INITIALIZER__,
- .cell_style.halign = TABLE_HALIGN_LEFT };
- struct font_style *font_style = &style->font_style;
- if (text_item->typeface)
- font_style->typeface = pool_strdup (tab->container, text_item->typeface);
- font_style->size = text_item->size;
- font_style->bold = text_item->bold;
- font_style->italic = text_item->italic;
- font_style->underline = text_item->underline;
- font_style->markup = text_item->markup;
+ *style = (struct table_area_style) {
+ .cell_style = CELL_STYLE_INITIALIZER,
+ .cell_style.halign = TABLE_HALIGN_LEFT,
+ };
+ font_style_copy (tab->container, &style->font_style, &text_item->style);
tab->styles[0] = style;
int opts = 0;
- if (text_item->markup)
+ if (text_item->style.markup)
opts |= TAB_MARKUP;
if (text_item->type == TEXT_ITEM_SYNTAX || text_item->type == TEXT_ITEM_LOG)
opts |= TAB_FIX;
{
struct text_item *item = to_text_item (output_item);
free (item->text);
- free (item->typeface);
+ font_style_uninit (&item->style);
free (item);
}
#include <stdbool.h>
#include "libpspp/compiler.h"
#include "output/output-item.h"
+#include "output/table.h"
enum text_item_type
{
struct output_item output_item;
char *text; /* The content. */
enum text_item_type type; /* Type. */
-
- bool bold, italic, underline, markup;
- char *typeface;
- int size;
+ struct font_style style;
};
struct text_item *text_item_create (enum text_item_type,