version 1.16, 2010/06/29 14:18:05 |
version 1.18, 2010/06/30 11:45:21 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <stdarg.h> |
#include <stdarg.h> |
|
#include <stdint.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
Line 373 static void ps_setfont(struct termp *, enum termfon |
|
Line 374 static void ps_setfont(struct termp *, enum termfon |
|
|
|
|
|
void * |
void * |
ps_alloc(void) |
ps_alloc(char *outopts) |
{ |
{ |
struct termp *p; |
struct termp *p; |
size_t pagex, pagey, margin; |
size_t pagex, pagey, margin, lineheight; |
|
const char *toks[2]; |
|
const char *paper; |
|
char *v; |
|
|
if (NULL == (p = term_alloc(TERMENC_ASCII))) |
if (NULL == (p = term_alloc(TERMENC_ASCII))) |
return(NULL); |
return(NULL); |
|
|
pagex = 612; |
|
pagey = 792; |
|
margin = 72; |
|
|
|
p->type = TERMTYPE_PS; |
p->type = TERMTYPE_PS; |
p->letter = ps_letter; |
p->letter = ps_letter; |
p->begin = ps_begin; |
p->begin = ps_begin; |
|
|
p->endline = ps_endline; |
p->endline = ps_endline; |
p->width = ps_width; |
p->width = ps_width; |
|
|
|
toks[0] = "paper"; |
|
toks[1] = NULL; |
|
|
|
while (outopts && *outopts) |
|
switch (getsubopt(&outopts, UNCONST(toks), &v)) { |
|
case (0): |
|
paper = v; |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
if (0 == strcasecmp(paper, "a4")) { |
|
pagex = 595 * 100; |
|
pagey = 842 * 100; |
|
} else { |
|
pagex = 612 * 100; |
|
pagey = 792 * 100; |
|
} |
|
|
|
margin = 72 * 100; |
|
lineheight = 12 * 100; |
|
|
assert(margin * 2 < pagex); |
assert(margin * 2 < pagex); |
assert(margin * 2 < pagey); |
assert(margin * 2 < pagey); |
|
|
|
|
p->engine.ps.footer = (margin / 2); |
p->engine.ps.footer = (margin / 2); |
p->engine.ps.bottom = margin; |
p->engine.ps.bottom = margin; |
p->engine.ps.left = margin; |
p->engine.ps.left = margin; |
p->engine.ps.lineheight = 12; |
p->engine.ps.lineheight = lineheight; |
|
|
p->defrmargin = pagex - (margin * 2); |
p->defrmargin = pagex - (margin * 2); |
return(p); |
return(p); |
Line 587 ps_pletter(struct termp *p, int c) |
|
Line 610 ps_pletter(struct termp *p, int c) |
|
|
|
if ( ! (PS_INLINE & p->engine.ps.psstate)) { |
if ( ! (PS_INLINE & p->engine.ps.psstate)) { |
ps_printf(p, "%zu %zu moveto\n(", |
ps_printf(p, "%zu %zu moveto\n(", |
p->engine.ps.pscol, |
(size_t)(p->engine.ps.pscol / 100), |
p->engine.ps.psrow); |
(size_t)(p->engine.ps.psrow / 100)); |
p->engine.ps.psstate |= PS_INLINE; |
p->engine.ps.psstate |= PS_INLINE; |
} |
} |
|
|
Line 617 ps_pletter(struct termp *p, int c) |
|
Line 640 ps_pletter(struct termp *p, int c) |
|
|
|
if (c <= 32 || (c - 32 > MAXCHAR)) { |
if (c <= 32 || (c - 32 > MAXCHAR)) { |
ps_putchar(p, ' '); |
ps_putchar(p, ' '); |
p->engine.ps.pscol += (fonts[f].gly[0].wx / 100); |
p->engine.ps.pscol += fonts[f].gly[0].wx; |
return; |
return; |
} |
} |
|
|
ps_putchar(p, c); |
ps_putchar(p, c); |
c -= 32; |
c -= 32; |
p->engine.ps.pscol += (fonts[f].gly[c].wx / 100); |
p->engine.ps.pscol += fonts[f].gly[c].wx; |
} |
} |
|
|
|
|
Line 793 ps_width(const struct termp *p, char c) |
|
Line 816 ps_width(const struct termp *p, char c) |
|
{ |
{ |
|
|
if (c <= 32 || c - 32 >= MAXCHAR) |
if (c <= 32 || c - 32 >= MAXCHAR) |
return(fonts[(int)TERMFONT_NONE].gly[0].wx / 100); |
return(fonts[(int)TERMFONT_NONE].gly[0].wx); |
|
|
c -= 32; |
c -= 32; |
return(fonts[(int)TERMFONT_NONE].gly[(int)c].wx / 100); |
return(fonts[(int)TERMFONT_NONE].gly[(int)c].wx); |
} |
} |