ref: dc3d917a36dfc186698a36b208f0ad54d331da25
parent: d173cf1cdc72519809a0e3e01165f616044b2eee
author: Ali Gholami Rudi <[email protected]>
date: Thu Aug 7 07:40:30 EDT 2014
font: glyph cursive attachments for r2l scripts
--- a/font.c
+++ b/font.c
@@ -99,6 +99,8 @@
return dict_get(fn->ch_map, name) != -1;
}
+static int font_findfeat(struct font *fn, char *feat);
+
/* enable/disable ligatures; first bit for liga and the second bit for rlig */
static int font_featlg(struct font *fn, int val)
{
@@ -183,9 +185,13 @@
{
struct grule *gpos = fn->gpos;
struct gpat *pats;
+ int curs_feat = dir_do ? font_findfeat(fn, "curs") : -1;
+ int curs_beg = -1;
+ int curs_dif = 0;
int i, k;
for (i = 0; i < slen; i++) {
int idx = -1;
+ int curs_cur = 0;
while (1) {
int r = font_findrule(fn, 0, 0, src + i, slen - i,
src + i, i, &idx);
@@ -192,7 +198,6 @@
if (r < 0)
break;
pats = gpos[r].pats;
- /* we should accumulate the values... */
for (k = 0; k < gpos[r].len; k++) {
x[i + k] += pats[k].x;
y[i + k] += pats[k].y;
@@ -199,8 +204,22 @@
xadv[i + k] += pats[k].xadv;
yadv[i + k] += pats[k].yadv;
}
+ if (gpos[r].feat == curs_feat) {
+ curs_cur = 1;
+ if (curs_beg < 0)
+ curs_beg = i;
+ for (k = 0; k < gpos[r].len; k++)
+ curs_dif += pats[k].yadv;
+ }
}
+ if (curs_beg >= 0 && !curs_cur) {
+ yadv[curs_beg] -= curs_dif;
+ curs_beg = -1;
+ curs_dif = 0;
+ }
}
+ if (curs_beg >= 0)
+ yadv[curs_beg] -= curs_dif;
}
/* find the first gsub rule after pos that matches any glyph in src */