ref: d6306656f955b87f37634bcc5f6bd699b71fdfb1
parent: 5e6396ef72ed72ebc3ad0c2429c29066f74cd5d9
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Jul 17 11:27:10 EDT 2014
post: support rotation with "x X rotate n" The escape sequence \X'rotate n' in neatroff rotates the current page n degrees counter-clockwise around the current point.
--- a/out.c
+++ b/out.c
@@ -9,6 +9,8 @@
static int p_f, p_s, p_m; /* output postscript font */
static int o_qtype; /* queued character type */
static int o_qv, o_qh, o_qend; /* queued character position */
+static int o_rh, o_rv, o_rdeg; /* previous rotation position and degree */
+
char o_fonts[FNLEN * NFONTS] = " ";
static void outvf(char *s, va_list ap)
@@ -41,6 +43,7 @@
p_s = 0;
p_f = 0;
p_m = 0;
+ o_rdeg = 0;
}
static void o_queue(struct glyph *g)
@@ -144,6 +147,18 @@
void outcolor(int c)
{
o_m = c;
+}
+
+void outrotate(int deg)
+{
+ o_flush();
+ out_fontup(o_f);
+ if (o_rdeg)
+ outf("%d %d %d rot\n", -o_rdeg, o_rh, o_rv);
+ o_rdeg = deg;
+ o_rh = o_h;
+ o_rv = o_v;
+ outf("%d %d %d rot\n", deg, o_h, o_v);
}
static int draw_path; /* number of path segments */
--- a/post.c
+++ b/post.c
@@ -209,6 +209,8 @@
readln(arg);
if (!strcmp("PS", cmd) || !strcmp("ps", cmd))
out("%s\n", arg);
+ if (!strcmp("rotate", cmd))
+ outrotate(atoi(arg));
if (!strcmp("BeginObject", cmd))
drawmbeg(arg);
if (!strcmp("EndObject", cmd))
--- a/post.h
+++ b/post.h
@@ -70,6 +70,7 @@
void outfont(int f);
void outsize(int s);
void outcolor(int c);
+void outrotate(int deg);
void outpage(void);
void outmnt(int f);
extern char o_fonts[];
--- a/ps.c
+++ b/ps.c
@@ -46,6 +46,7 @@
"/m {neg moveto} bind def\n"
"/g {neg moveto {glyphshow} forall} bind def\n"
"/rgb {255 div 3 1 roll 255 div 3 1 roll 255 div 3 1 roll setrgbcolor} bind def\n"
+ "/rot {/y exch def /x exch def x y neg translate rotate x neg y translate} bind def\n"
"/done {/lastpage where {pop lastpage} if} def\n"
"\n"
"% caching fonts, as selectfont is supposed to be doing\n"