summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-08-13 22:09:29 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-08-13 22:09:29 +0000
commit6941377a4c2ff24016bdde7047952aa69e4f0781 (patch)
treee9a69bb3f2e2e0bfad4821a1768a6a679800906e
parent01d83aa80185d40f50efd38905789a912c726d3c (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@.
-rw-r--r--share/man/man7/roff.716
-rw-r--r--usr.bin/mandoc/html.c4
-rw-r--r--usr.bin/mandoc/term_ascii.c32
-rw-r--r--usr.bin/mandoc/term_ps.c40
4 files changed, 60 insertions, 32 deletions
diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7
index ef2c03ae4bf..299d67fce7b 100644
--- a/share/man/man7/roff.7
+++ b/share/man/man7/roff.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: roff.7,v 1.34 2014/07/07 11:34:41 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.35 2014/08/13 22:09:28 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: July 7 2014 $
+.Dd $Mdocdate: August 13 2014 $
.Dt ROFF 7
.Os
.Sh NAME
@@ -237,8 +237,9 @@ pica (~1/6 inch)
.It p
point (~1/72 inch)
.It f
-synonym for
+scale
.Sq u
+by 65536
.It v
default vertical span
.It m
@@ -252,7 +253,7 @@ width of rendered
.Pq en
character
.It u
-default horizontal span
+default horizontal span for the terminal
.It M
mini-em (~1/100 em)
.El
@@ -260,7 +261,6 @@ mini-em (~1/100 em)
Using anything other than
.Sq m ,
.Sq n ,
-.Sq u ,
or
.Sq v
is necessarily non-portable across output media.
@@ -1346,6 +1346,12 @@ refers to groff version 1.15.
.Pp
.Bl -dash -compact
.It
+The
+.Sq u
+scaling unit is the default terminal unit.
+In traditional troff systems, this unit would change depending on the
+output media.
+.It
In mandoc, the
.Sx \&EQ ,
.Sx \&TE ,
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index 9cf447c7e4e..27a0a0949d1 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.39 2014/08/13 15:19:24 schwarze Exp $ */
+/* $Id: html.c,v 1.40 2014/08/13 22:09:28 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -758,6 +758,8 @@ bufcat_su(struct html *h, const char *p, const struct roffsu *su)
v = su->scale;
if (SCALE_MM == su->unit && 0.0 == (v /= 100.0))
v = 1.0;
+ else if (SCALE_BU == su->unit)
+ v /= 24.0;
bufcat_fmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]);
}
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);
diff --git a/usr.bin/mandoc/term_ps.c b/usr.bin/mandoc/term_ps.c
index 542a7c37853..5f0fdc31a5d 100644
--- a/usr.bin/mandoc/term_ps.c
+++ b/usr.bin/mandoc/term_ps.c
@@ -1,4 +1,4 @@
-/* $Id: term_ps.c,v 1.27 2014/08/08 16:00:23 schwarze Exp $ */
+/* $Id: term_ps.c,v 1.28 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>
@@ -1110,31 +1110,41 @@ ps_hspan(const struct termp *p, const struct roffsu *su)
* All of these measurements are derived by converting from the
* native measurement to AFM units.
*/
-
switch (su->unit) {
- case SCALE_CM:
- r = PNT2AFM(p, su->scale * 28.34);
- break;
- case SCALE_IN:
- r = PNT2AFM(p, su->scale * 72.0);
- break;
- case SCALE_PC:
- r = PNT2AFM(p, su->scale * 12.0);
+ case SCALE_BU:
+ /*
+ * Traditionally, the default unit is fixed to the
+ * output media. So this would refer to the point. In
+ * mandoc(1), however, we stick to the default terminal
+ * scaling unit so that output is the same regardless
+ * the media.
+ */
+ r = PNT2AFM(p, su->scale * 72.0 / 240.0);
break;
- case SCALE_PT:
- r = PNT2AFM(p, su->scale * 100.0);
+ case SCALE_CM:
+ r = PNT2AFM(p, su->scale * 72.0 / 2.54);
break;
case SCALE_EM:
r = su->scale *
fonts[(int)TERMFONT_NONE].gly[109 - 32].wx;
break;
- case SCALE_MM:
- r = PNT2AFM(p, su->scale * 2.834);
- break;
case SCALE_EN:
r = su->scale *
fonts[(int)TERMFONT_NONE].gly[110 - 32].wx;
break;
+ case SCALE_IN:
+ r = PNT2AFM(p, su->scale * 72.0);
+ break;
+ case SCALE_MM:
+ r = su->scale *
+ fonts[(int)TERMFONT_NONE].gly[109 - 32].wx / 100.0;
+ break;
+ case SCALE_PC:
+ r = PNT2AFM(p, su->scale * 12.0);
+ break;
+ case SCALE_PT:
+ r = PNT2AFM(p, su->scale * 1.0);
+ break;
case SCALE_VS:
r = su->scale * p->ps->lineheight;
break;