tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: Ingo Schwarze <schwarze@usta.de>
Cc: tech@mdocml.bsd.lv
Subject: Re: \w'blah'u issues (really: 'u' scaling width)
Date: Tue, 12 Aug 2014 03:04:12 +0200	[thread overview]
Message-ID: <53E9680C.9050702@bsd.lv> (raw)
In-Reply-To: <20140809204126.GG30999@iris.usta.de>

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

Ingo,

Enclosed are the horizontal adjustments as per your suggestions.  (NOT 
the vertical ones yet.)  To test this, I simply ran mandoc and groff 
side-by-side with both -Tascii and -Tps with each test unit having a 
resulting non-zero length.  They're more-or-less similar, but if we want 
to be precisely the same, there's more work to be done.

Best,

Kristaps

[-- Attachment #2: hspaces.diff --]
[-- Type: text/plain, Size: 3326 bytes --]

Index: html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v
retrieving revision 1.160
diff -u -p -r1.160 html.c
--- html.c	10 Aug 2014 23:54:41 -0000	1.160
+++ html.c	12 Aug 2014 01:02:16 -0000
@@ -759,6 +759,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;
+	else if (SCALE_BU == su->unit)
+		v /= 24.0;
 
 	bufcat_fmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]);
 }
Index: term_ascii.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v
retrieving revision 1.28
diff -u -p -r1.28 term_ascii.c
--- term_ascii.c	10 Aug 2014 23:54:41 -0000	1.28
+++ term_ascii.c	12 Aug 2014 01:02:16 -0000
@@ -230,31 +230,41 @@ ascii_hspan(const struct termp *p, const
 	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 * 2750.0;
 		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;
 	}
 
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.63
diff -u -p -r1.63 term_ps.c
--- term_ps.c	10 Aug 2014 23:54:41 -0000	1.63
+++ term_ps.c	12 Aug 2014 01:02:17 -0000
@@ -1117,28 +1117,32 @@ ps_hspan(const struct termp *p, const st
 	 */
 
 	switch (su->unit) {
-	case SCALE_CM:
-		r = PNT2AFM(p, su->scale * 28.34);
-		break;
-	case SCALE_IN:
-		r = PNT2AFM(p, su->scale * 72.0);
+	case SCALE_BU:
+		r = PNT2AFM(p, su->scale * 6.0 / 240.0);
 		break;
-	case SCALE_PC:
-		r = PNT2AFM(p, su->scale * 12.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;

  reply	other threads:[~2014-08-12  1:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-09 17:01 Kristaps Dzonsons
2014-08-09 20:41 ` Ingo Schwarze
2014-08-12  1:04   ` Kristaps Dzonsons [this message]
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=53E9680C.9050702@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=schwarze@usta.de \
    --cc=tech@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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).