shithub: neatroff

Download patch

ref: 65a15243b12b41bf4bb4c1795aea9587dacb660b
parent: bbde779f213eaabbde86aba59de478b6e38c751e
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Mar 5 20:53:48 EST 2014

roff.h: replace charwid_base() with DEVWID()

--- a/out.c
+++ b/out.c
@@ -126,7 +126,7 @@
 {
 	struct glyph *g = dev_glyph(c, o_f);
 	int cwid = charwid(o_f, o_s, g ? g->wid : SC_DW);
-	int bwid = charwid_base(o_f, o_s, g ? g->wid : SC_DW);
+	int bwid = DEVWID(o_s, g ? g->wid : SC_DW);
 	if (g && font_mapped(g->font, c))
 		c = g->name;
 	if (dev_getcs(o_f))
--- a/ren.c
+++ b/ren.c
@@ -86,18 +86,11 @@
 	}
 }
 
-int charwid_base(int fn, int sz, int wid)
-{
-	/* the original troff rounds the widths up */
-	return (wid * sz + dev_uwid / 2) / dev_uwid;
-}
-
 int charwid(int fn, int sz, int wid)
 {
 	if (dev_getcs(fn))
 		return dev_getcs(n_f) * SC_EM / 36;
-	return charwid_base(fn, sz, wid) +
-		(dev_getbd(fn) ? dev_getbd(fn) - 1 : 0);
+	return DEVWID(sz, wid) + (dev_getbd(fn) ? dev_getbd(fn) - 1 : 0);
 }
 
 int spacewid(int fn, int sz)
--- a/roff.h
+++ b/roff.h
@@ -181,7 +181,9 @@
 struct glyph *dev_glyph_byid(char *id, int fn);
 int charwid(int fn, int sz, int wid);
 int spacewid(int fn, int sz);
-int charwid_base(int fn, int sz, int wid);
+
+/* convert wid in device unitwidth size to size sz */
+#define DEVWID(sz, wid)		(((wid) * (sz) + (dev_uwid / 2)) / dev_uwid)
 
 /* different layers of neatroff */
 int in_next(void);		/* input layer */
--- a/wb.c
+++ b/wb.c
@@ -162,7 +162,7 @@
 		g = dev_glyph(c, R_F(wb));
 	}
 	if (g && !zerowidth && g->icleft && wb->icleft_ll == sbuf_len(&wb->sbuf))
-		wb_hmov(wb, charwid_base(R_F(wb), R_S(wb), g->icleft));
+		wb_hmov(wb, DEVWID(R_S(wb), g->icleft));
 	wb->icleft_ll = -1;
 	wb_font(wb);
 	wb_prevcheck(wb);		/* make sure wb->prev_c[] is valid */
@@ -509,7 +509,7 @@
 {
 	struct glyph *g = wb_prevglyph(wb);
 	if (g && g->ic)
-		wb_hmov(wb, charwid_base(wb->f, wb->s, g->ic));
+		wb_hmov(wb, DEVWID(wb->s, g->ic));
 }
 
 void wb_italiccorrectionleft(struct wb *wb)