summaryrefslogtreecommitdiffstats
path: root/tbl_html.c
diff options
context:
space:
mode:
Diffstat (limited to 'tbl_html.c')
-rw-r--r--tbl_html.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/tbl_html.c b/tbl_html.c
index b230c9c3..16474440 100644
--- a/tbl_html.c
+++ b/tbl_html.c
@@ -31,22 +31,48 @@
static void html_tblopen(struct html *, const struct tbl_span *);
static size_t html_tbl_len(size_t, void *);
static size_t html_tbl_strlen(const char *, void *);
+static size_t html_tbl_sulen(const struct roffsu *, void *);
static size_t
html_tbl_len(size_t sz, void *arg)
{
-
return sz;
}
static size_t
html_tbl_strlen(const char *p, void *arg)
{
-
return strlen(p);
}
+static size_t
+html_tbl_sulen(const struct roffsu *su, void *arg)
+{
+ switch (su->unit) {
+ case SCALE_FS: /* 2^16 basic units */
+ return su->scale * 65536.0 / 24.0;
+ case SCALE_IN: /* 10 characters per inch */
+ return su->scale * 10.0;
+ case SCALE_CM: /* 2.54 cm per inch */
+ return su->scale * 10.0 / 2.54;
+ case SCALE_PC: /* 6 pica per inch */
+ case SCALE_VS:
+ return su->scale * 10.0 / 6.0;
+ case SCALE_EN:
+ case SCALE_EM:
+ return su->scale;
+ case SCALE_PT: /* 12 points per pica */
+ return su->scale * 10.0 / 6.0 / 12.0;
+ case SCALE_BU: /* 24 basic units per character */
+ return su->scale / 24.0;
+ case SCALE_MM: /* 1/1000 inch */
+ return su->scale / 100.0;
+ default:
+ abort();
+ }
+}
+
static void
html_tblopen(struct html *h, const struct tbl_span *sp)
{
@@ -56,6 +82,7 @@ html_tblopen(struct html *h, const struct tbl_span *sp)
if (h->tbl.cols == NULL) {
h->tbl.len = html_tbl_len;
h->tbl.slen = html_tbl_strlen;
+ h->tbl.sulen = html_tbl_sulen;
tblcalc(&h->tbl, sp, 0);
}