* mdocml: This enables variable glyph-width output.
@ 2010-06-28 22:46 kristaps
2010-06-28 22:47 ` Kristaps Dzonsons
0 siblings, 1 reply; 2+ messages in thread
From: kristaps @ 2010-06-28 22:46 UTC (permalink / raw)
To: source
Log Message:
-----------
This enables variable glyph-width output. The checkin will be followed
by a [functionless] clean-up in term_ps.c, but this makes the
appropriate changes to "enable" initial proportional-width functionality
in term.c and fixes some areas of term_ps.c that were causing errors.
Modified Files:
--------------
mdocml:
term.c
term_ps.c
Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -Lterm.c -Lterm.c -u -p -r1.152 -r1.153
--- term.c
+++ term.c
@@ -195,9 +195,11 @@ term_flushln(struct termp *p)
if (vend > vis && vend < bp &&
ASCII_HYPH == p->buf[j])
jhy = j;
- vend++;
- } else
- vend--;
+ vend += (*p->width)(p, p->buf[j]);
+ } else {
+ assert(j);
+ vend -= (*p->width)(p, p->buf[j - 1]);
+ }
}
/*
@@ -237,13 +239,13 @@ term_flushln(struct termp *p)
break;
if (' ' == p->buf[i]) {
while (' ' == p->buf[i]) {
- vbl++;
+ vbl += (*p->width)(p, p->buf[i]);
i++;
}
break;
}
if (ASCII_NBRSP == p->buf[i]) {
- vbl++;
+ vbl += (*p->width)(p, ' ');
continue;
}
@@ -258,12 +260,13 @@ term_flushln(struct termp *p)
vbl = 0;
}
- if (ASCII_HYPH == p->buf[i])
+ if (ASCII_HYPH == p->buf[i]) {
(*p->letter)(p, '-');
- else
+ p->viscol += (*p->width)(p, '-');
+ } else {
(*p->letter)(p, p->buf[i]);
-
- p->viscol += 1;
+ p->viscol += (*p->width)(p, p->buf[i]);
+ }
}
vend += vbl;
vis = vend;
@@ -281,7 +284,7 @@ term_flushln(struct termp *p)
if (TERMP_HANG & p->flags) {
/* We need one blank after the tag. */
p->overstep = /* LINTED */
- vis - maxvis + 1;
+ vis - maxvis + (*p->width)(p, ' ');
/*
* Behave exactly the same way as groff:
@@ -305,7 +308,7 @@ term_flushln(struct termp *p)
/* Right-pad. */
if (maxvis > vis + /* LINTED */
- ((TERMP_TWOSPACE & p->flags) ? 1 : 0)) {
+ ((TERMP_TWOSPACE & p->flags) ? (*p->width)(p, ' ') : 0)) {
p->viscol += maxvis - vis;
(*p->advance)(p, maxvis - vis);
vis += (maxvis - vis);
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.13 -r1.14
--- term_ps.c
+++ term_ps.c
@@ -387,9 +387,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;
p->begin = ps_begin;
@@ -551,6 +549,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 +584,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 +704,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 +757,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);
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: mdocml: This enables variable glyph-width output.
2010-06-28 22:46 mdocml: This enables variable glyph-width output kristaps
@ 2010-06-28 22:47 ` Kristaps Dzonsons
0 siblings, 0 replies; 2+ messages in thread
From: Kristaps Dzonsons @ 2010-06-28 22:47 UTC (permalink / raw)
To: source
> This enables variable glyph-width output. The checkin will be followed
> by a [functionless] clean-up in term_ps.c, but this makes the
> appropriate changes to "enable" initial proportional-width functionality
> in term.c and fixes some areas of term_ps.c that were causing errors.
Note, by the way: this doesn't yet consider font-styles. This is a
work in progress!
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-28 22:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-28 22:46 mdocml: This enables variable glyph-width output kristaps
2010-06-28 22:47 ` Kristaps Dzonsons
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).