diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-03-02 16:45:41 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-03-02 16:45:41 +0000 |
commit | d3c5aaa494431ae3a2463cc5ca6c9b8f3bf733c0 (patch) | |
tree | 753baea8b04e6b54660a1e68b1d9fe4e18f51002 /term_ps.c | |
parent | 2612bc21b4df390b151333c85302d3829cb86e93 (diff) | |
download | src-d3c5aaa494431ae3a2463cc5ca6c9b8f3bf733c0.tar.gz src-d3c5aaa494431ae3a2463cc5ca6c9b8f3bf733c0.zip |
Import CVS snapshot of mandoc as of 20150302
Notes
Notes:
svn path=/vendor/mdocml/dist/; revision=279524
Diffstat (limited to 'term_ps.c')
-rw-r--r-- | term_ps.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/term_ps.c b/term_ps.c index e3299d70640b..12ca7d67165c 100644 --- a/term_ps.c +++ b/term_ps.c @@ -1,7 +1,7 @@ -/* $Id: term_ps.c,v 1.70 2014/12/01 08:05:52 schwarze Exp $ */ +/* $Id: term_ps.c,v 1.72 2015/01/21 19:40:54 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -60,6 +60,7 @@ struct termp_ps { #define PS_NEWPAGE (1 << 2) /* new page, no words yet */ #define PS_BACKSP (1 << 3) /* last character was backspace */ size_t pscol; /* visible column (AFM units) */ + size_t pscolnext; /* used for overstrike */ size_t psrow; /* visible row (AFM units) */ char *psmarg; /* margin buf */ size_t psmargsz; /* margin buf size */ @@ -540,6 +541,9 @@ pspdf_alloc(const struct mchars *mchars, char *outopts) p = mandoc_calloc(1, sizeof(struct termp)); p->symtab = mchars; p->enc = TERMENC_ASCII; + p->fontq = mandoc_reallocarray(NULL, + (p->fontsz = 8), sizeof(enum termfont)); + p->fontq[0] = p->fontl = TERMFONT_NONE; p->ps = mandoc_calloc(1, sizeof(struct termp_ps)); p->advance = ps_advance; @@ -1069,7 +1073,7 @@ ps_fclose(struct termp *p) static void ps_letter(struct termp *p, int arg) { - size_t savecol; + size_t savecol, wx; char c; c = arg >= 128 || arg <= 0 ? '?' : arg; @@ -1141,7 +1145,30 @@ ps_letter(struct termp *p, int arg) ps_setfont(p, p->ps->nextf); } p->ps->nextf = TERMFONT_NONE; + + /* + * For an overstrike, if a previous character + * was wider, advance to center the new one. + */ + + if (p->ps->pscolnext) { + wx = fonts[p->ps->lastf].gly[(int)p->ps->last-32].wx; + if (p->ps->pscol + wx < p->ps->pscolnext) + p->ps->pscol = (p->ps->pscol + + p->ps->pscolnext - wx) / 2; + } + ps_pletter(p, p->ps->last); + + /* + * For an overstrike, if a previous character + * was wider, advance to the end of the old one. + */ + + if (p->ps->pscol < p->ps->pscolnext) { + ps_pclose(p); + p->ps->pscol = p->ps->pscolnext; + } } /* @@ -1155,13 +1182,19 @@ ps_letter(struct termp *p, int arg) /* * For an overstrike, back up to the previous position. + * If the previous character is wider than any it overstrikes, + * remember the current position, because it might also be + * wider than all that will overstrike it. */ if (savecol != SIZE_MAX) { + if (p->ps->pscolnext < p->ps->pscol) + p->ps->pscolnext = p->ps->pscol; ps_pclose(p); p->ps->pscol = savecol; p->ps->flags &= ~PS_BACKSP; - } + } else + p->ps->pscolnext = 0; } static void |