help / color / mirror / Atom feed
From: Kristaps Dzonsons <>
Subject: \w'blah'u issues (really: 'u' scaling width)
Date: Sat, 09 Aug 2014 19:01:40 +0200	[thread overview]
Message-ID: <> (raw)

[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]


Earlier I mentioned, as an aside, that OpenGL manuals look bad.  Try 
rendering gluPerspective to see what I mean.  (Attached.)

I tracked this down to the following:

.TP \w'\fIaspect\fP\ \ 'u
Specifies the field of view angle, in degrees, in the \f2y\fP direction.

Note that the width of the TP head is being set to the contents of 
\w'xxx'.  So this should be interpreted as

.Tp <width of "aspect  ">u

which should amount to 8 character widths.

However, in roff.c:630, we multiply this width by 24.  As a result, 
everything's wonky.  (8 * 24 = a long line)

At first I thought that we should just yank the 24.  But in running a 
little test, it seems that the \w'' doesn't calculate the string width 
in characters, but in magic internal units.  So it's not that we 
shouldn't multiply by 24, but instead that the "u" scaling unit should 
*divide* by 24.

The test was:

.TP \w'h'u
.TP 24u
.TP 48u

These now display similarly between mandoc and nroff with the enclosed 
patch, though I haven't tested it exhaustively.  Thoughts?



[-- Attachment #2: gluPerspective.3 --]
[-- Type: text/plain, Size: 2653 bytes --]

'\" e  
'\"macro stdmacro
.ds Vn Version 1.2
.ds Dt 6 March 1997
.ds Re Release 1.2.0
.ds Dp May 22 14:54
.ds Dm 0 May 22 14:
.ds Xs 14699     5
.B "gluPerspective
\- set up a perspective projection matrix

void \f3gluPerspective\fP(
GLdouble \fIfovy\fP,
.ta \w'\f3void \fPgluPerspective( 'u
	GLdouble \fIaspect\fP,
	GLdouble \fIzNear\fP,
	GLdouble \fIzFar\fP )

.TP \w'\fIaspect\fP\ \ 'u 
Specifies the field of view angle, in degrees, in the \f2y\fP direction.
Specifies the aspect ratio that determines
the field of view in the \f2x\fP direction.
The aspect ratio is the ratio of \f2x\fP (width) to \f2y\fP (height).
Specifies the distance from the viewer to the near clipping plane
(always positive).
Specifies the distance from the viewer to the far clipping plane
(always positive).
\%\f3gluPerspective\fP specifies a viewing frustum into the world coordinate system.
In general, the aspect ratio in \%\f3gluPerspective\fP should match the aspect ratio
of the associated viewport. For example, aspect = 2.0 means 
the viewer's
angle of view is twice as wide in \f2x\fP as it is in \f2y\fP.
If the viewport is
twice as wide as it is tall, it displays the image without distortion.
The matrix generated by \%\f3gluPerspective\fP is multipled by the current matrix,
just as if \f3glMultMatrix\fP were called with the generated matrix.
To load the perspective matrix onto the current matrix stack instead,
precede the call to \%\f3gluPerspective\fP with a call to \f3glLoadIdentity\fP.
Given \f2f\fP defined as follows:
f  = cotangent(fovy/2)

The generated matrix is
.Bd -literal
 ------------       0              0              0

     0              f              0              0

                               zFar+zNear    2*zFar*zNear
     0              0          ----------    ------------
                               zNear-zFar     zNear-zFar

     0              0              -1             0


Depth buffer precision is affected by the values specified for
\f2zNear\fP and \f2zFar\fP.
The greater the ratio of \f2zFar\fP to \f2zNear\fP is,
the less effective the depth buffer will be at distinguishing between
surfaces that are near each other.

r = zFar/zNear

roughly log2(r) bits of depth buffer precision are lost.
Because r approaches infinity as \f2zNear\fP approaches 0,
\f2zNear\fP must never be set to 0.
\f3glFrustum\fP, \f3glLoadIdentity\fP,
\f3glMultMatrix\fP, \%\f3gluOrtho2D\fP

[-- Attachment #3: scale.diff --]
[-- Type: text/plain, Size: 2010 bytes --]

Index: term_ps.c
RCS file: /usr/vhosts/,v
retrieving revision 1.62
diff -u -p -r1.62 term_ps.c
--- term_ps.c	1 Aug 2014 19:25:52 -0000	1.62
+++ term_ps.c	9 Aug 2014 16:59:03 -0000
@@ -1145,6 +1145,9 @@ ps_hspan(const struct termp *p, const st
 	case SCALE_VS:
 		r = su->scale * p->ps->lineheight;
+	case SCALE_BU:
+		r = PNT2AFM(p, su->scale / 3.0);
+		break;
 		r = su->scale;
Index: term_ascii.c
RCS file: /usr/vhosts/,v
retrieving revision 1.27
diff -u -p -r1.27 term_ascii.c
--- term_ascii.c	1 Aug 2014 19:25:52 -0000	1.27
+++ term_ascii.c	9 Aug 2014 16:59:04 -0000
@@ -255,6 +255,9 @@ ascii_hspan(const struct termp *p, const
 	case SCALE_VS:
 		r = su->scale * 2.0 - 1.0;
+	case SCALE_BU:
+		r = su->scale / 24.0;
+		break;
 		r = su->scale;
Index: term.c
RCS file: /usr/vhosts/,v
retrieving revision 1.226
diff -u -p -r1.226 term.c
--- term.c	1 Aug 2014 19:38:29 -0000	1.226
+++ term.c	9 Aug 2014 16:59:04 -0000
@@ -786,6 +786,9 @@ term_vspan(const struct termp *p, const 
 	case SCALE_VS:
 		r = su->scale;
+	case SCALE_BU:
+		r = su->scale / 24.0;
+		break;
 		r = su->scale - 1.0;
Index: html.c
RCS file: /usr/vhosts/,v
retrieving revision 1.159
diff -u -p -r1.159 html.c
--- html.c	23 Jul 2014 15:00:08 -0000	1.159
+++ html.c	9 Aug 2014 16:59:04 -0000
@@ -761,6 +761,8 @@ bufcat_su(struct html *h, const char *p,
 	v = su->scale;
 	if (SCALE_MM == su->unit && 0.0 == (v /= 100.0))
 		v = 1.0;
+	if (SCALE_BU == su->unit)
+		v /= 24.0;
 	bufcat_fmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]);

             reply	other threads:[~2014-08-09 17:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-09 17:01 Kristaps Dzonsons [this message]
2014-08-09 20:41 ` Ingo Schwarze
2014-08-12  1:04   ` Kristaps Dzonsons
2014-08-12  2:43     ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).