diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-08-13 22:09:29 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-08-13 22:09:29 +0000 |
commit | 6941377a4c2ff24016bdde7047952aa69e4f0781 (patch) | |
tree | e9a69bb3f2e2e0bfad4821a1768a6a679800906e /usr.bin/mandoc/term_ascii.c | |
parent | 01d83aa80185d40f50efd38905789a912c726d3c (diff) |
Begin cleanup of scaling units.
Note that we use 240u := 1i for all devices, even -Tps and -Tpdf.
Big fix of -Tascii rendering of f, m, and u.
Small fix of -Tascii rendering of c.
Big fix of -Thtml rendering of u.
Big fix of -Tps rendering of m, p, and u.
Clarify -Tps rendering of c.
Correct documentation of scaling units, in particular with respect to u.
This for example improves rendering of the OpenGL manuals.
Joint work with kristaps@.
Diffstat (limited to 'usr.bin/mandoc/term_ascii.c')
-rw-r--r-- | usr.bin/mandoc/term_ascii.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c index a1b02b525ff..2086699bca5 100644 --- a/usr.bin/mandoc/term_ascii.c +++ b/usr.bin/mandoc/term_ascii.c @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.16 2014/08/08 16:00:23 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.17 2014/08/13 22:09:28 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -209,32 +209,42 @@ ascii_hspan(const struct termp *p, const struct roffsu *su) double r; /* - * Approximate based on character width. These are generated - * entirely by eyeballing the screen, but appear to be correct. + * Approximate based on character width. + * None of these will be actually correct given that an inch on + * the screen depends on character size, terminal, etc., etc. */ - switch (su->unit) { + case SCALE_BU: + r = su->scale * 10.0 / 240.0; + break; case SCALE_CM: - r = su->scale * 4.0; + r = su->scale * 10.0 / 2.54; + break; + case SCALE_FS: + r = su->scale * 2730.666; break; case SCALE_IN: r = su->scale * 10.0; break; + case SCALE_MM: + r = su->scale / 100.0; + break; case SCALE_PC: - r = (su->scale * 10.0) / 6.0; + r = su->scale * 10.0 / 6.0; break; case SCALE_PT: - r = (su->scale * 10.0) / 72.0; - break; - case SCALE_MM: - r = su->scale / 1000.0; + r = su->scale * 10.0 / 72.0; break; case SCALE_VS: r = su->scale * 2.0 - 1.0; break; - default: + case SCALE_EN: + case SCALE_EM: r = su->scale; break; + case SCALE_MAX: + abort(); + break; } return(r); |