=================================================================== RCS file: /cvs/mandoc/term_ps.c,v retrieving revision 1.13 retrieving revision 1.15 diff -u -p -r1.13 -r1.15 --- mandoc/term_ps.c 2010/06/28 13:45:28 1.13 +++ mandoc/term_ps.c 2010/06/28 23:26:09 1.15 @@ -1,4 +1,4 @@ -/* $Id: term_ps.c,v 1.13 2010/06/28 13:45:28 kristaps Exp $ */ +/* $Id: term_ps.c,v 1.15 2010/06/28 23:26:09 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -31,14 +31,21 @@ #include "main.h" #include "term.h" +/* TODO: all this will go away with different paper sizes. */ +#define PS_CHAR_HEIGHT 12 +#define PS_CHAR_TOPMARG (792 - 24) +#define PS_CHAR_TOP (PS_CHAR_TOPMARG - 36) +#define PS_CHAR_LEFT 36 +#define PS_CHAR_BOTMARG 24 +#define PS_CHAR_BOT (PS_CHAR_BOTMARG + 36) + struct glyph { int wx; /* WX in AFM */ }; -#define MAXCHAR 95 - struct font { const char *name; /* FontName in AFM */ +#define MAXCHAR 95 /* total characters we can handle */ struct glyph gly[MAXCHAR]; /* glyph metrics */ }; @@ -342,13 +349,7 @@ static const struct font fonts[3] = { } }, }; -#define PS_CHAR_HEIGHT 12 -#define PS_CHAR_TOPMARG (792 - 24) -#define PS_CHAR_TOP (PS_CHAR_TOPMARG - 36) -#define PS_CHAR_LEFT 36 -#define PS_CHAR_BOTMARG 24 -#define PS_CHAR_BOT (PS_CHAR_BOTMARG + 36) - +/* These work the buffer used by the header and footer. */ #define PS_BUFSLOP 128 #define PS_GROWBUF(p, sz) \ do if ((p)->engine.ps.psmargcur + (sz) > \ @@ -387,8 +388,7 @@ ps_alloc(void) if (NULL == (p = term_alloc(TERMENC_ASCII))) return(NULL); - p->defrmargin = 78; - p->tabwidth = 5; + p->defrmargin = 612 - (PS_CHAR_LEFT * 2); p->type = TERMTYPE_PS; p->letter = ps_letter; @@ -551,6 +551,7 @@ ps_begin(struct termp *p) static void ps_pletter(struct termp *p, int c) { + int f; /* * If we're not in a PostScript "word" context, then open one @@ -585,21 +586,17 @@ ps_pletter(struct termp *p, int c) /* Write the character and adjust where we are on the page. */ - /* - * FIXME: at this time we emit only blacnks on non-ASCII - * letters. - */ + f = (int)p->engine.ps.lastf; - if (c < 32 || (c - 32 > MAXCHAR)) { + if (c <= 32 || (c - 32 > MAXCHAR)) { ps_putchar(p, ' '); - p->engine.ps.pscol += - (fonts[p->engine.ps.lastf].gly[32].wx / 100); + p->engine.ps.pscol += (fonts[f].gly[0].wx / 100); return; } ps_putchar(p, c); - p->engine.ps.pscol += - (fonts[p->engine.ps.lastf].gly[(int)c - 32].wx / 100); + c -= 32; + p->engine.ps.pscol += (fonts[f].gly[c].wx / 100); } @@ -709,8 +706,7 @@ ps_advance(struct termp *p, size_t len) */ ps_fclose(p); - p->engine.ps.pscol += 0 == len ? 0 : - len * (fonts[p->engine.ps.lastf].gly[0].wx / 100); + p->engine.ps.pscol += len; } @@ -763,5 +759,9 @@ static size_t ps_width(const struct termp *p, char c) { - return(1); + if (c <= 32 || c - 32 >= MAXCHAR) + return(fonts[(int)TERMFONT_NONE].gly[0].wx / 100); + + c -= 32; + return(fonts[(int)TERMFONT_NONE].gly[(int)c].wx / 100); }