shithub: neatpost

Download patch

ref: 08f6359a2348f2413fbef498e9dd5e975683c0a4
parent: 14fafdadb05a2ea128a8aa3ce43ac2010f77c5e0
author: mtbakerguy <mtbakerguy@yahoo.com>
date: Fri Apr 16 17:17:43 EDT 2021

post: landscape option to swap width and height

--- a/post.c
+++ b/post.c
@@ -513,7 +513,7 @@
 			return;
 		}
 	}
-	/* custom paper size in mm, like 2100x2970 for a4 */
+	/* custom paper size in tenth of mm; example: 2100x2970 for a4 */
 	if (isdigit(s[0]) && strchr(s, 'x')) {
 		ps_pagewidth = atoi(s);
 		ps_pageheight = atoi(strchr(s, 'x') + 1);
@@ -619,11 +619,13 @@
 	"  -p size \tset paper size (letter); e.g., a4, 2100x2970\n"
 	"  -t title\tspecify document title\n"
 	"  -w lwid \tdrawing line thickness in thousandths of an em (40)\n"
+	"  -l      \tlandscape mode\n"
 	"  -n      \talways draw glyphs by name (ps glyphshow)\n";
 
 int main(int argc, char *argv[])
 {
 	int i;
+	int landscape = 0;
 	for (i = 1; i < argc; i++) {
 		if (argv[i][0] == '-' && argv[i][1] == 'F') {
 			strcpy(postdir, argv[i][2] ? argv[i] + 2 : argv[++i]);
@@ -635,10 +637,17 @@
 			outgname(1);
 		} else if (argv[i][0] == '-' && argv[i][1] == 't') {
 			ps_title = argv[i][2] ? argv[i] + 2 : argv[++i];
+		} else if (argv[i][0] == '-' && argv[i][1] == 'l') {
+			landscape = 1;
 		} else {
 			printf("%s", usage);
 			return 0;
 		}
+	}
+	if (landscape) {
+		int t = ps_pagewidth;
+		ps_pagewidth = ps_pageheight;
+		ps_pageheight = t;
 	}
 	post();
 	doctrailer(o_pages);