shithub: neatroff

Download patch

ref: 19c01743a735453e0529767156a42df75c817523
parent: 297fc906899f4c1f9b37edca27a7e610ac8bf004
author: Ali Gholami Rudi <[email protected]>
date: Mon Aug 4 06:14:06 EDT 2014

font: support alternative glyphs in gpos rules

--- a/font.c
+++ b/font.c
@@ -211,6 +211,7 @@
 {
 	int src[WORDLEN], dst[WORDLEN];
 	int ndst = 0;
+	int didx = 0;
 	int i, j;
 	for (i = 0; i < nsrc; i++)
 		src[i] = font_idx(fn, gsrc[i]);
@@ -242,10 +243,15 @@
 		if (!rule)
 			continue;
 		for (j = 0; j < rule->len; j++) {
-			x[i + j] = rule->pats[j].x;
-			y[i + j] = rule->pats[j].y;
-			xadv[i + j] = rule->pats[j].xadv;
-			yadv[i + j] = rule->pats[j].yadv;
+			if (rule->pats[j].g == dst[didx]) {
+				x[i + didx] = rule->pats[j].x;
+				y[i + didx] = rule->pats[j].y;
+				xadv[i + didx] = rule->pats[j].xadv;
+				yadv[i + didx] = rule->pats[j].yadv;
+				didx++;
+				while (rule->pats[j].flg & GF_ALT)
+					j++;
+			}
 		}
 	}
 	return ndst;
@@ -386,9 +392,12 @@
 		col = strchr(tok, ':');
 		if (col)
 			*col = '\0';
-		if (!(g = font_glyph(fn, tok)))
+		if (!(g = font_glyph(fn, tok + 1)))
 			return 0;
 		rule->pats[i].g = font_idx(fn, g);
+		rule->pats[i].flg = GF_PAT;
+		if (tok[0] == '|' && i > 0)
+			rule->pats[i - 1].flg |= GF_ALT;
 		if (col)
 			sscanf(col + 1, "%hd%hd%hd%hd",
 				&rule->pats[i].x, &rule->pats[i].y,