=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/term_ps.c,v retrieving revision 1.36 retrieving revision 1.37 diff -c -r1.36 -r1.37 *** src/usr.bin/mandoc/term_ps.c 2014/12/19 17:10:42 1.36 --- src/usr.bin/mandoc/term_ps.c 2015/01/21 19:40:22 1.37 *************** *** 1,7 **** ! /* $OpenBSD: term_ps.c,v 1.36 2014/12/19 17:10:42 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons ! * Copyright (c) 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above --- 1,7 ---- ! /* $OpenBSD: term_ps.c,v 1.37 2015/01/21 19:40:22 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons ! * Copyright (c) 2014, 2015 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above *************** *** 58,63 **** --- 58,64 ---- #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 */ *************** *** 1067,1073 **** static void ps_letter(struct termp *p, int arg) { ! size_t savecol; char c; c = arg >= 128 || arg <= 0 ? '?' : arg; --- 1068,1074 ---- static void ps_letter(struct termp *p, int arg) { ! size_t savecol, wx; char c; c = arg >= 128 || arg <= 0 ? '?' : arg; *************** *** 1139,1145 **** --- 1140,1169 ---- 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; + } } /* *************** *** 1153,1165 **** /* * For an overstrike, back up to the previous position. */ if (savecol != SIZE_MAX) { ps_pclose(p); p->ps->pscol = savecol; p->ps->flags &= ~PS_BACKSP; ! } } static void --- 1177,1195 ---- /* * 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