]> git.cameronkatri.com Git - mandoc.git/commitdiff
Fix vertical scaling. Obviously, nobody ever had a serious look at this.
authorIngo Schwarze <schwarze@openbsd.org>
Tue, 23 Dec 2014 06:16:46 +0000 (06:16 +0000)
committerIngo Schwarze <schwarze@openbsd.org>
Tue, 23 Dec 2014 06:16:46 +0000 (06:16 +0000)
Basic units, centimeters, points, ens, ems, and the rounding algorithm
were all wrong, only inches, pica, and the default vertical span worked.

term.c

diff --git a/term.c b/term.c
index 72ec556f0f5804f3f742037cab218f54a5e17405..8d05afc41225a54ed73f3b5361bbac10119aa159 100644 (file)
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/*     $Id: term.c,v 1.238 2014/12/19 17:12:04 schwarze Exp $ */
+/*     $Id: term.c,v 1.239 2014/12/23 06:16:46 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -776,32 +776,43 @@ term_vspan(const struct termp *p, const struct roffsu *su)
        double           r;
 
        switch (su->unit) {
+       case SCALE_BU:
+               r = su->scale / 40.0;
+               break;
        case SCALE_CM:
-               r = su->scale * 2.0;
+               r = su->scale * 6.0 / 2.54;
+               break;
+       case SCALE_FS:
+               r = su->scale * 65536.0 / 40.0;
                break;
        case SCALE_IN:
                r = su->scale * 6.0;
                break;
+       case SCALE_MM:
+               r = su->scale * 0.006;
+               break;
        case SCALE_PC:
                r = su->scale;
                break;
        case SCALE_PT:
-               r = su->scale / 8.0;
+               r = su->scale / 12.0;
                break;
-       case SCALE_MM:
-               r = su->scale / 1000.0;
+       case SCALE_EN:
+               /* FALLTHROUGH */
+       case SCALE_EM:
+               r = su->scale * 0.6;
                break;
        case SCALE_VS:
                r = su->scale;
                break;
        default:
-               r = su->scale - 1.0;
-               break;
+               abort();
+               /* NOTREACHED */
        }
 
        if (r < 0.0)
                r = 0.0;
-       return((size_t)(r + 0.0005));
+       return((size_t)(r + 0.4995));
 }
 
 size_t