version 1.237, 2014/12/02 10:08:06 |
version 1.239, 2014/12/23 06:16:46 |
Line 43 term_free(struct termp *p) |
|
Line 43 term_free(struct termp *p) |
|
{ |
{ |
|
|
free(p->buf); |
free(p->buf); |
|
free(p->fontq); |
free(p); |
free(p); |
} |
} |
|
|
Line 329 term_vspace(struct termp *p) |
|
Line 330 term_vspace(struct termp *p) |
|
(*p->endline)(p); |
(*p->endline)(p); |
} |
} |
|
|
|
/* Swap current and previous font; for \fP and .ft P */ |
void |
void |
term_fontlast(struct termp *p) |
term_fontlast(struct termp *p) |
{ |
{ |
Line 339 term_fontlast(struct termp *p) |
|
Line 341 term_fontlast(struct termp *p) |
|
p->fontq[p->fonti] = f; |
p->fontq[p->fonti] = f; |
} |
} |
|
|
|
/* Set font, save current, discard previous; for \f, .ft, .B etc. */ |
void |
void |
term_fontrepl(struct termp *p, enum termfont f) |
term_fontrepl(struct termp *p, enum termfont f) |
{ |
{ |
Line 347 term_fontrepl(struct termp *p, enum termfont f) |
|
Line 350 term_fontrepl(struct termp *p, enum termfont f) |
|
p->fontq[p->fonti] = f; |
p->fontq[p->fonti] = f; |
} |
} |
|
|
|
/* Set font, save previous. */ |
void |
void |
term_fontpush(struct termp *p, enum termfont f) |
term_fontpush(struct termp *p, enum termfont f) |
{ |
{ |
|
|
assert(p->fonti + 1 < 10); |
|
p->fontl = p->fontq[p->fonti]; |
p->fontl = p->fontq[p->fonti]; |
p->fontq[++p->fonti] = f; |
if (++p->fonti == p->fontsz) { |
|
p->fontsz += 8; |
|
p->fontq = mandoc_reallocarray(p->fontq, |
|
p->fontsz, sizeof(enum termfont *)); |
|
} |
|
p->fontq[p->fonti] = f; |
} |
} |
|
|
const void * |
/* Retrieve pointer to current font. */ |
|
const enum termfont * |
term_fontq(struct termp *p) |
term_fontq(struct termp *p) |
{ |
{ |
|
|
return(&p->fontq[p->fonti]); |
return(&p->fontq[p->fonti]); |
} |
} |
|
|
enum termfont |
/* Flush to make the saved pointer current again. */ |
term_fonttop(struct termp *p) |
|
{ |
|
|
|
return(p->fontq[p->fonti]); |
|
} |
|
|
|
void |
void |
term_fontpopq(struct termp *p, const void *key) |
term_fontpopq(struct termp *p, const enum termfont *key) |
{ |
{ |
|
|
while (p->fonti >= 0 && key < (void *)(p->fontq + p->fonti)) |
while (p->fonti >= 0 && key < p->fontq + p->fonti) |
p->fonti--; |
p->fonti--; |
assert(p->fonti >= 0); |
assert(p->fonti >= 0); |
} |
} |
|
|
|
/* Pop one font off the stack. */ |
void |
void |
term_fontpop(struct termp *p) |
term_fontpop(struct termp *p) |
{ |
{ |
Line 554 encode1(struct termp *p, int c) |
|
Line 558 encode1(struct termp *p, int c) |
|
if (p->col + 6 >= p->maxcols) |
if (p->col + 6 >= p->maxcols) |
adjbuf(p, p->col + 6); |
adjbuf(p, p->col + 6); |
|
|
f = term_fonttop(p); |
f = *term_fontq(p); |
|
|
if (TERMFONT_UNDER == f || TERMFONT_BI == f) { |
if (TERMFONT_UNDER == f || TERMFONT_BI == f) { |
p->buf[p->col++] = '_'; |
p->buf[p->col++] = '_'; |
Line 586 encode(struct termp *p, const char *word, size_t sz) |
|
Line 590 encode(struct termp *p, const char *word, size_t sz) |
|
* character by character. |
* character by character. |
*/ |
*/ |
|
|
if (TERMFONT_NONE == term_fonttop(p)) { |
if (*term_fontq(p) == TERMFONT_NONE) { |
if (p->col + sz >= p->maxcols) |
if (p->col + sz >= p->maxcols) |
adjbuf(p, p->col + sz); |
adjbuf(p, p->col + sz); |
for (i = 0; i < sz; i++) |
for (i = 0; i < sz; i++) |
Line 772 term_vspan(const struct termp *p, const struct roffsu |
|
Line 776 term_vspan(const struct termp *p, const struct roffsu |
|
double r; |
double r; |
|
|
switch (su->unit) { |
switch (su->unit) { |
|
case SCALE_BU: |
|
r = su->scale / 40.0; |
|
break; |
case SCALE_CM: |
case SCALE_CM: |
r = su->scale * 2.0; |
r = su->scale * 6.0 / 2.54; |
break; |
break; |
|
case SCALE_FS: |
|
r = su->scale * 65536.0 / 40.0; |
|
break; |
case SCALE_IN: |
case SCALE_IN: |
r = su->scale * 6.0; |
r = su->scale * 6.0; |
break; |
break; |
|
case SCALE_MM: |
|
r = su->scale * 0.006; |
|
break; |
case SCALE_PC: |
case SCALE_PC: |
r = su->scale; |
r = su->scale; |
break; |
break; |
case SCALE_PT: |
case SCALE_PT: |
r = su->scale / 8.0; |
r = su->scale / 12.0; |
break; |
break; |
case SCALE_MM: |
case SCALE_EN: |
r = su->scale / 1000.0; |
/* FALLTHROUGH */ |
|
case SCALE_EM: |
|
r = su->scale * 0.6; |
break; |
break; |
case SCALE_VS: |
case SCALE_VS: |
r = su->scale; |
r = su->scale; |
break; |
break; |
default: |
default: |
r = su->scale - 1.0; |
abort(); |
break; |
/* NOTREACHED */ |
} |
} |
|
|
if (r < 0.0) |
if (r < 0.0) |
r = 0.0; |
r = 0.0; |
return((size_t)(r + 0.0005)); |
return((size_t)(r + 0.4995)); |
} |
} |
|
|
size_t |
size_t |