shithub: neatroff

Download patch

ref: 4b451268a4cf9a90e01efe84cadbb5417161d568
parent: fa227033810da058e4b76ed18ccf36a9c04fa9d5
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Apr 24 19:25:13 EDT 2013

out: use em / 3 as the default char width

--- a/line.c
+++ b/line.c
@@ -9,7 +9,7 @@
 static int cwid(char *c)
 {
 	struct glyph *g = dev_glyph(c, n_f);
-	return charwid(g ? g->wid : dev_spacewid(), n_s);
+	return charwid(g ? g->wid : SC_DW, n_s);
 }
 
 static int lchar(char *c, char **cs)
--- a/out.c
+++ b/out.c
@@ -233,12 +233,10 @@
 			}
 		}
 		g = dev_glyph(c, o_f);
-		if (g) {
-			if (utf8len(c[0]) == strlen(c))
-				outnn("c%s%s", c, c[1] ? "\n" : "");
-			else
-				out("C%s\n", c[0] == '\\' && c[1] == '(' ? c + 2 : c);
-		}
-		outnn("h%d", charwid(g ? g->wid : dev_spacewid(), o_s));
+		if (utf8len(c[0]) == strlen(c))
+			outnn("c%s%s", c, c[1] ? "\n" : "");
+		else
+			out("C%s\n", c[0] == '\\' && c[1] == '(' ? c + 2 : c);
+		outnn("h%d", charwid(g ? g->wid : SC_DW, o_s));
 	}
 }
--- a/ren.c
+++ b/ren.c
@@ -514,7 +514,7 @@
 		break;
 	case '0':
 		g = dev_glyph("0", n_f);
-		w = charwid(g ? g->wid : dev_spacewid(), n_s);
+		w = charwid(g ? g->wid : SC_DW, n_s);
 		adj_put(adj, w, "\\h'%du'", w);
 		break;
 	case '|':
@@ -572,7 +572,7 @@
 		ren_f = n_f;
 	}
 	g = dev_glyph(c, n_f);
-	adj_put(adj, charwid(g ? g->wid : dev_spacewid(), n_s), c);
+	adj_put(adj, charwid(g ? g->wid : SC_DW, n_s), c);
 	return g ? g->type : 0;
 }
 
--- a/xroff.h
+++ b/xroff.h
@@ -1,6 +1,7 @@
 /* converting scales */
 #define SC_IN		(dev_res)	/* inch in units */
 #define SC_PT		(SC_IN / 72)	/* point in units */
+#define SC_DW		(n_s * SC_IN / 72 / 3)	/* default width */
 
 /* predefined array limits */
 #define PATHLEN		1024	/* path length */