shithub: neatmkfn

Download patch

ref: d2dccb58de5678b20da7957debf0355fc165391d
parent: fe24ed3567bcdd2c7fe0bf22df8aec763cce2338
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Jan 29 19:04:47 EST 2015

trfn: -l option to suppress the ligatures line

Most OpenType fonts define ligatures as GSUB rules.

--- a/gen.sh
+++ b/gen.sh
@@ -33,7 +33,7 @@
 ttfconv()
 {
 	echo $1
-	cat $2 | ./mkfn -b -o -r$RES -t $1 $3 $4 $5 $6 $7 | \
+	cat $2 | ./mkfn -b -l -o -r$RES -t $1 $3 $4 $5 $6 $7 | \
 		sed "/^ligatures /s/ $LIGIGN//g" >$TP/$1
 }
 
--- a/mkfn.c
+++ b/mkfn.c
@@ -103,6 +103,7 @@
 	"  -r res  \tset device resolution (720)\n"
 	"  -k kmin \tspecify the minimum amount of kerning (0)\n"
 	"  -b      \tinclude glyph bounding boxes\n"
+	"  -l      \tsuppress the ligatures line\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";
@@ -115,6 +116,7 @@
 	int kmin = 0;
 	int bbox = 0;
 	int warn = 0;
+	int ligs = 1;
 	int i;
 	for (i = 1; i < argc && argv[i][0] == '-'; i++) {
 		switch (argv[i][1]) {
@@ -127,6 +129,9 @@
 		case 'k':
 			kmin = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]);
 			break;
+		case 'l':
+			ligs = 0;
+			break;
 		case 'L':
 			trfn_langs = argv[i][2] ? argv[i] + 2 : argv[++i];
 			break;
@@ -156,7 +161,7 @@
 			return 0;
 		}
 	}
-	trfn_init(res, spc, kmin, bbox);
+	trfn_init(res, spc, kmin, bbox, ligs);
 	if (afm)
 		afm_read();
 	else
--- a/trfn.c
+++ b/trfn.c
@@ -22,6 +22,7 @@
 static int trfn_special;	/* special flag */
 static int trfn_kmin;		/* minimum kerning value */
 static int trfn_bbox;		/* include bounding box */
+static int trfn_noligs;		/* suppress ligatures */
 static char trfn_ligs[8192];	/* font ligatures */
 static char trfn_trname[256];	/* font troff name */
 static char trfn_psname[256];	/* font ps name */
@@ -314,7 +315,8 @@
 	if (trfn_psname[0])
 		printf("fontname %s\n", trfn_psname);
 	printf("spacewidth %d\n", trfn_swid);
-	printf("ligatures %s0\n", trfn_ligs);
+	if (!trfn_noligs)
+		printf("ligatures %s0\n", trfn_ligs);
 	if (trfn_special)
 		printf("special\n");
 	printf("%s", sbuf_buf(&sbuf_char));
@@ -321,7 +323,7 @@
 	printf("%s", sbuf_buf(&sbuf_kern));
 }
 
-void trfn_init(int res, int spc, int kmin, int bbox)
+void trfn_init(int res, int spc, int kmin, int bbox, int ligs)
 {
 	int i;
 	trfn_div = 7200 / res;
@@ -328,6 +330,7 @@
 	trfn_special = spc;
 	trfn_kmin = kmin;
 	trfn_bbox = bbox;
+	trfn_noligs = !ligs;
 	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);
+void trfn_init(int res, int special, int kmin, int bbox, int ligs);
 void trfn_done(void);
 void trfn_trfont(char *name);
 void trfn_psfont(char *fontname);