aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term_ps.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-04 19:24:00 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-04 19:24:00 +0000
commit7594f901ccc16751800a8c5d6c5f6439c47d4c4a (patch)
tree98e7f60ec9a4859be5808b55ccaa874f4c569ee9 /term_ps.c
parent2bf37620ef83f5dee8d8b36139c6392f41502252 (diff)
downloadmandoc-7594f901ccc16751800a8c5d6c5f6439c47d4c4a.tar.gz
mandoc-7594f901ccc16751800a8c5d6c5f6439c47d4c4a.tar.zst
mandoc-7594f901ccc16751800a8c5d6c5f6439c47d4c4a.zip
Backed out margin calculations in favour of much simpler rule of thumb:
margins are 1/9 the length/width.
Diffstat (limited to 'term_ps.c')
-rw-r--r--term_ps.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/term_ps.c b/term_ps.c
index e78274f0..1bed1886 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -1,4 +1,4 @@
-/* $Id: term_ps.c,v 1.27 2010/07/04 10:53:04 kristaps Exp $ */
+/* $Id: term_ps.c,v 1.28 2010/07/04 19:24:00 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -393,7 +393,7 @@ void *
ps_alloc(char *outopts)
{
struct termp *p;
- size_t pagex, pagey, margin, lineheight, m1, m2;
+ size_t pagex, pagey, marginx, marginy, lineheight;
const char *toks[2];
const char *pp;
char *v;
@@ -476,28 +476,23 @@ ps_alloc(char *outopts)
pagex = PNT2AFM(p, ((double)pagex * 2.834));
pagey = PNT2AFM(p, ((double)pagey * 2.834));
- /*
- * Calculate margins. First get the minimum text width: either
- * page minus margins or width of 65 'm' characters. Set total
- * margins to page size minus text width.
- */
+ /* Margins are 1/9 the page x and y. */
- m1 = ps_width(p, 'm') * 65;
- m2 = pagex - (2 * PNT2AFM(p, MINMARGIN_PNT));
- margin = (pagex - (m1 < m2 ? m1 : m2)) / 2;
+ marginx = (size_t)((double)pagex / 9.0);
+ marginy = (size_t)((double)pagey / 9.0);
lineheight = PNT2AFM(p, 16);
p->engine.ps.width = pagex;
p->engine.ps.height = pagey;
- p->engine.ps.header = pagey - (margin / 2) - (lineheight / 2);
- p->engine.ps.top = pagey - margin;
- p->engine.ps.footer = (margin / 2) - (lineheight / 2);
- p->engine.ps.bottom = margin;
- p->engine.ps.left = margin;
+ p->engine.ps.header = pagey - (marginy / 2) - (lineheight / 2);
+ p->engine.ps.top = pagey - marginy;
+ p->engine.ps.footer = (marginy / 2) - (lineheight / 2);
+ p->engine.ps.bottom = marginy;
+ p->engine.ps.left = marginx;
p->engine.ps.lineheight = lineheight;
- p->defrmargin = pagex - (margin * 2);
+ p->defrmargin = pagex - (marginx * 2);
return(p);
}