changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: libttf: add SHZ[] instruction

changeset 6822: e8fe70debd30
parent 6821: fae7dd79fa22
child 6823: 559068140f63
author: aiju
date: Tue, 16 Oct 2018 19:14:19 +0000
files: sys/src/libttf/hint.c
description: libttf: add SHZ[] instruction
     1.1--- a/sys/src/libttf/hint.c
     1.2+++ b/sys/src/libttf/hint.c
     1.3@@ -120,7 +120,7 @@ getpoint(Hint *h, int n, int pi)
     1.4 		if(h->g == nil)
     1.5 			herror(h, "access to glyph zone from FPGM/CVT");
     1.6 		if((uint)pi >= h->g->npt)
     1.7-			herror(h, "glyph zone point index %d out of range", n);
     1.8+			herror(h, "glyph zone point index %d out of range", pi);
     1.9 		dprint("G%s%d: %+π\n", n&ORIG?"O":"", pi, (n & ORIG) != 0 ? h->g->ptorg[pi] : h->g->pt[pi]);
    1.10 		return (n & ORIG) != 0 ? h->g->ptorg[pi] : h->g->pt[pi];
    1.11 	}else{
    1.12@@ -143,17 +143,53 @@ setpoint(Hint *h, int n, int pi, TTPoint
    1.13 		if(h->g == nil)
    1.14 			herror(h, "access to glyph zone from FPGM/CVT");
    1.15 		if((uint)pi >= h->g->npt)
    1.16-			herror(h, "glyph zone point index %d out of range", n);
    1.17+			herror(h, "glyph zone point index %d out of range", pi);
    1.18 		dprint("G%d: %+π -> %+π\n", pi, h->g->pt[pi], p);
    1.19 		h->g->pt[pi] = p;
    1.20 	}else{
    1.21 		if((uint)pi >= h->f->u->maxTwilightPoints)
    1.22-			herror(h, "twilight zone point index %d out of range", n);
    1.23+			herror(h, "twilight zone point index %d out of range", pi);
    1.24 		dprint("T%d: %+π -> %+π\n", pi, h->f->twilight[pi], p);
    1.25 		h->f->twilight[pi] = p;
    1.26 	}
    1.27 }
    1.28 
    1.29+static TTPoint
    1.30+getpointz(Hint *h, int z, int pi)
    1.31+{
    1.32+	if((z & 1) != 0){
    1.33+		if(h->g == nil)
    1.34+			herror(h, "access to glyph zone from FPGM/CVT");
    1.35+		if((uint)pi >= h->g->npt)
    1.36+			herror(h, "glyph zone point index %d out of range", pi);
    1.37+		dprint("G%s%d: %+π\n", z&ORIG?"O":"", pi, (z & ORIG) != 0 ? h->g->ptorg[pi] : h->g->pt[pi]);
    1.38+		return (z & ORIG) != 0 ? h->g->ptorg[pi] : h->g->pt[pi];
    1.39+	}else{
    1.40+		if((uint)pi >= h->f->u->maxTwilightPoints)
    1.41+			herror(h, "twilight zone point index %d out of range", pi);
    1.42+		return (z & ORIG) != 0 ? h->f->twiorg[pi] : h->f->twilight[pi];
    1.43+	}
    1.44+}
    1.45+
    1.46+static void
    1.47+setpointz(Hint *h, int z, int pi, TTPoint p)
    1.48+{
    1.49+	if((z & 1) != 0){
    1.50+		if(h->g == nil)
    1.51+			herror(h, "access to glyph zone from FPGM/CVT");
    1.52+		if((uint)pi >= h->g->npt)
    1.53+			herror(h, "glyph zone point index %d out of range", pi);
    1.54+		dprint("G%d: %+π -> %+π\n", pi, h->g->pt[pi], p);
    1.55+		h->g->pt[pi] = p;
    1.56+	}else{
    1.57+		if((uint)pi >= h->f->u->maxTwilightPoints)
    1.58+			herror(h, "twilight zone point index %d out of range", pi);
    1.59+		dprint("T%d: %+π -> %+π\n", pi, h->f->twilight[pi], p);
    1.60+		h->f->twilight[pi] = p;
    1.61+	}
    1.62+}
    1.63+
    1.64+
    1.65 static void
    1.66 debugprint(Hint *h, int skip)
    1.67 {
    1.68@@ -1445,6 +1481,34 @@ h_shc(Hint *h)
    1.69 	}
    1.70 }
    1.71 
    1.72+static void
    1.73+h_shz(Hint *h)
    1.74+{
    1.75+	int i, e, np;
    1.76+	TTPoint rp, orp;
    1.77+	TTPoint p, n;
    1.78+	int d, dp;
    1.79+
    1.80+	if((h->ip[-1] & 1) != 0){
    1.81+		rp = getpoint(h, RP1|ZP0, 0);
    1.82+		orp = getpoint(h, RP1|ZP0|ORIG, 0);
    1.83+	}else{
    1.84+		rp = getpoint(h, RP2|ZP1, 0);
    1.85+		orp = getpoint(h, RP2|ZP1|ORIG, 0);
    1.86+	}
    1.87+	e = pop(h);
    1.88+	if((uint)e > 1)
    1.89+		herror(h, "SHZ[] with invalid zone %d", e);
    1.90+	d = project(h, &rp, &orp);
    1.91+	np = e ? h->g->npt : h->f->u->maxTwilightPoints;
    1.92+	for(i = 0; i < np; i++){
    1.93+		p = getpointz(h, e, i);
    1.94+		dp = project(h, &p, nil);
    1.95+		n = forceproject(h, p, dp + d);
    1.96+		setpointz(h, e, i, n);
    1.97+	}
    1.98+}
    1.99+
   1.100 static void (*itable[256])(Hint *) = {
   1.101 	[0x00] h_svtca, h_svtca, h_svtca, h_svtca, h_svtca, h_svtca,
   1.102 	[0x06] h_sxvtl, h_sxvtl, h_sxvtl, h_sxvtl,
   1.103@@ -1478,6 +1542,7 @@ static void (*itable[256])(Hint *) = {
   1.104 	[0x30] h_iup, h_iup,
   1.105 	[0x32] h_shp, h_shp,
   1.106 	[0x34] h_shc, h_shc,
   1.107+	[0x37] h_shz,
   1.108 	[0x38] h_shpix,
   1.109 	[0x39] h_ip,
   1.110 	[0x3a] h_msirp, h_msirp,