shithub: neatmkfn

Download patch

ref: 3b33b2993253e10204743273e06545708fe3e149
parent: 5e95c9c795e3ebeaa4df7a60f706328613cb63d5
author: Ali Gholami Rudi <ali@rudi.ir>
date: Tue Jun 23 19:45:38 EDT 2015

mkfn: suppress glyph positions with -n option

The fifth column of "char" lines specifies internal glyph position.
If missing, neatpost would output glyphs by their device dependent
names.  The -n option forces this by suppressing glyph positions
altogether.  Tested by Dirk-Wilhelm Peters <peters@schwertfisch.de>.

--- a/mkfn.c
+++ b/mkfn.c
@@ -104,6 +104,7 @@
 	"  -k kmin \tspecify the minimum amount of kerning (0)\n"
 	"  -b      \tinclude glyph bounding boxes\n"
 	"  -l      \tsuppress the ligatures line\n"
+	"  -n      \tsuppress glyph positions\n"
 	"  -S scrs \tcomma-separated list of scripts to include (help to list)\n"
 	"  -L langs\tcomma-separated list of languages to include (help to list)\n"
 	"  -w      \twarn about unsupported font features\n";
@@ -117,6 +118,7 @@
 	int bbox = 0;
 	int warn = 0;
 	int ligs = 1;
+	int pos = 1;
 	int i;
 	for (i = 1; i < argc && argv[i][0] == '-'; i++) {
 		switch (argv[i][1]) {
@@ -135,6 +137,9 @@
 		case 'L':
 			trfn_langs = argv[i][2] ? argv[i] + 2 : argv[++i];
 			break;
+		case 'n':
+			pos = 0;
+			break;
 		case 'o':
 			afm = 0;
 			break;
@@ -161,7 +166,7 @@
 			return 0;
 		}
 	}
-	trfn_init(res, spc, kmin, bbox, ligs);
+	trfn_init(res, spc, kmin, bbox, ligs, pos);
 	if (afm)
 		afm_read();
 	else
--- a/trfn.c
+++ b/trfn.c
@@ -23,6 +23,7 @@
 static int trfn_kmin;		/* minimum kerning value */
 static int trfn_bbox;		/* include bounding box */
 static int trfn_noligs;		/* suppress ligatures */
+static int trfn_pos;		/* include glyph positions */
 static char trfn_ligs[8192];	/* font ligatures */
 static char trfn_trname[256];	/* font troff name */
 static char trfn_psname[256];	/* font ps name */
@@ -266,9 +267,9 @@
 	/* initializing character attributes */
 	if (trfn_name(uc, psname, u))
 		strcpy(uc, "---");
-	if (n >= 0 && n < 256)
+	if (trfn_pos && n >= 0 && n < 256)
 		sprintf(pos, "%d", n);
-	if (n < 0 && !uc[1] && uc[0] >= 32 && uc[0] <= 125)
+	if (trfn_pos && n < 0 && !uc[1] && uc[0] >= 32 && uc[0] <= 125)
 		if (!strchr(psname, '.'))
 			sprintf(pos, "%d", uc[0]);
 	typ = trfn_type(!strchr(psname, '.') ? uc : "", lly, ury);
@@ -323,7 +324,7 @@
 	printf("%s", sbuf_buf(&sbuf_kern));
 }
 
-void trfn_init(int res, int spc, int kmin, int bbox, int ligs)
+void trfn_init(int res, int spc, int kmin, int bbox, int ligs, int pos)
 {
 	int i;
 	trfn_div = 7200 / res;
@@ -331,6 +332,7 @@
 	trfn_kmin = kmin;
 	trfn_bbox = bbox;
 	trfn_noligs = !ligs;
+	trfn_pos = pos;
 	sbuf_init(&sbuf_char);
 	sbuf_init(&sbuf_kern);
 	tab_agl = tab_alloc(LEN(agl));
--- a/trfn.h
+++ b/trfn.h
@@ -1,4 +1,4 @@
-void trfn_init(int res, int special, int kmin, int bbox, int ligs);
+void trfn_init(int res, int special, int kmin, int bbox, int ligs, int pos);
 void trfn_done(void);
 void trfn_trfont(char *name);
 void trfn_psfont(char *fontname);