version 1.68, 2014/10/28 17:36:19 |
version 1.72, 2015/01/21 19:40:54 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* 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 |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "mandoc_aux.h" |
#include "out.h" |
#include "out.h" |
#include "main.h" |
|
#include "term.h" |
#include "term.h" |
|
#include "main.h" |
|
|
/* These work the buffer used by the header and footer. */ |
/* These work the buffer used by the header and footer. */ |
#define PS_BUFSLOP 128 |
#define PS_BUFSLOP 128 |
Line 61 struct termp_ps { |
|
Line 60 struct termp_ps { |
|
#define PS_NEWPAGE (1 << 2) /* new page, no words yet */ |
#define PS_NEWPAGE (1 << 2) /* new page, no words yet */ |
#define PS_BACKSP (1 << 3) /* last character was backspace */ |
#define PS_BACKSP (1 << 3) /* last character was backspace */ |
size_t pscol; /* visible column (AFM units) */ |
size_t pscol; /* visible column (AFM units) */ |
|
size_t pscolnext; /* used for overstrike */ |
size_t psrow; /* visible row (AFM units) */ |
size_t psrow; /* visible row (AFM units) */ |
char *psmarg; /* margin buf */ |
char *psmarg; /* margin buf */ |
size_t psmargsz; /* margin buf size */ |
size_t psmargsz; /* margin buf size */ |
Line 541 pspdf_alloc(const struct mchars *mchars, char *outopts |
|
Line 541 pspdf_alloc(const struct mchars *mchars, char *outopts |
|
p = mandoc_calloc(1, sizeof(struct termp)); |
p = mandoc_calloc(1, sizeof(struct termp)); |
p->symtab = mchars; |
p->symtab = mchars; |
p->enc = TERMENC_ASCII; |
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->ps = mandoc_calloc(1, sizeof(struct termp_ps)); |
|
|
p->advance = ps_advance; |
p->advance = ps_advance; |
Line 635 ps_setwidth(struct termp *p, int iop, size_t width) |
|
Line 638 ps_setwidth(struct termp *p, int iop, size_t width) |
|
size_t lastwidth; |
size_t lastwidth; |
|
|
lastwidth = p->ps->width; |
lastwidth = p->ps->width; |
if (0 < iop) |
if (iop > 0) |
p->ps->width += width; |
p->ps->width += width; |
else if (0 > iop) |
else if (iop == 0) |
|
p->ps->width = width ? width : p->ps->lastwidth; |
|
else if (p->ps->width > width) |
p->ps->width -= width; |
p->ps->width -= width; |
else |
else |
p->ps->width = width ? width : p->ps->lastwidth; |
p->ps->width = 0; |
p->ps->lastwidth = lastwidth; |
p->ps->lastwidth = lastwidth; |
} |
} |
|
|
Line 1068 ps_fclose(struct termp *p) |
|
Line 1073 ps_fclose(struct termp *p) |
|
static void |
static void |
ps_letter(struct termp *p, int arg) |
ps_letter(struct termp *p, int arg) |
{ |
{ |
size_t savecol; |
size_t savecol, wx; |
char c; |
char c; |
|
|
c = arg >= 128 || arg <= 0 ? '?' : arg; |
c = arg >= 128 || arg <= 0 ? '?' : arg; |
Line 1140 ps_letter(struct termp *p, int arg) |
|
Line 1145 ps_letter(struct termp *p, int arg) |
|
ps_setfont(p, p->ps->nextf); |
ps_setfont(p, p->ps->nextf); |
} |
} |
p->ps->nextf = TERMFONT_NONE; |
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); |
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; |
|
} |
} |
} |
|
|
/* |
/* |
Line 1154 ps_letter(struct termp *p, int arg) |
|
Line 1182 ps_letter(struct termp *p, int arg) |
|
|
|
/* |
/* |
* For an overstrike, back up to the previous position. |
* 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 (savecol != SIZE_MAX) { |
|
if (p->ps->pscolnext < p->ps->pscol) |
|
p->ps->pscolnext = p->ps->pscol; |
ps_pclose(p); |
ps_pclose(p); |
p->ps->pscol = savecol; |
p->ps->pscol = savecol; |
p->ps->flags &= ~PS_BACKSP; |
p->ps->flags &= ~PS_BACKSP; |
} |
} else |
|
p->ps->pscolnext = 0; |
} |
} |
|
|
static void |
static void |