output: Add support for fonts.
[pspp] / src / output / table-provider.h
index a511e13bd5c95439dc0504b91abb64f414e7aedf..ae7f77d420b40cf7fa364cf2c87431f0c119c7cd 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef OUTPUT_TABLE_PROVIDER
 #define OUTPUT_TABLE_PROVIDER 1
 
+#include <stdint.h>
 #include "output/table.h"
 
 struct string;
@@ -42,6 +43,46 @@ struct cell_contents
 void cell_contents_format_footnote_markers (const struct cell_contents *,
                                             struct string *);
 
+struct cell_color
+  {
+    uint8_t r, g, b;
+  };
+
+#define CELL_COLOR(r, g, b) (struct cell_color) { r, g, b }
+#define CELL_COLOR_BLACK CELL_COLOR (0, 0, 0)
+#define CELL_COLOR_WHITE CELL_COLOR (255, 255, 255)
+
+static inline bool
+cell_color_equal (const struct cell_color *a, const struct cell_color *b)
+{
+  return a->r == b->r && a->g == b->g && a->b == b->b;
+}
+
+struct cell_style
+  {
+    struct cell_color fg, bg;
+    int margin[TABLE_N_AXES][2];
+    char *font;
+    int font_size;
+    bool bold, italic, underline;
+  };
+
+#define CELL_STYLE_INITIALIZER                                  \
+    {                                                           \
+      .fg = CELL_COLOR_BLACK,                                   \
+      .bg = CELL_COLOR_WHITE,                                   \
+      .margin = { [TABLE_HORZ][0] = 8, [TABLE_HORZ][1] = 11,    \
+                  [TABLE_VERT][0] = 1, [TABLE_VERT][1] = 1 },   \
+      .font = NULL,                                             \
+      .font_size = 0,                                           \
+      .bold = false,                                            \
+      .italic = false,                                          \
+      .underline = false,                                       \
+    }
+
+struct cell_style *cell_style_clone (const struct cell_style *);
+void cell_style_free (struct cell_style *);
+
 /* A cell in a table. */
 struct table_cell
   {
@@ -75,6 +116,8 @@ struct table_cell
     size_t n_contents;
     struct cell_contents inline_contents;
 
+    const struct cell_style *style;
+
     /* Called to free the cell's data, if nonnull. */
     void (*destructor) (void *destructor_aux);
     void *destructor_aux;