source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Fix vertical scaling.
Date: Tue, 23 Dec 2014 01:17:16 -0500 (EST)	[thread overview]
Message-ID: <7594080228836124645.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Fix vertical scaling.  Obviously, nobody ever had a serious look at this.
Basic units, centimeters, points, ens, ems, and the rounding algorithm
were all wrong, only inches, pica, and the default vertical span worked.

Modified Files:
--------------
    mdocml:
        term.c

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/term.c,v
retrieving revision 1.238
retrieving revision 1.239
diff -Lterm.c -Lterm.c -u -p -r1.238 -r1.239
--- term.c
+++ term.c
@@ -776,32 +776,43 @@ term_vspan(const struct termp *p, const 
 	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
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-12-23  6:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=7594080228836124645.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@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).