$NetBSD: patch-ai,v 1.1 2004/02/14 22:27:30 kristerw Exp $ --- libfstt/raster_hints.cc.orig Sat Feb 14 22:10:14 2004 +++ libfstt/raster_hints.cc Sat Feb 14 22:39:52 2004 @@ -123,7 +123,7 @@ int val = cvtTab->nextVal(); // (ld 2048 = 11) - (SHIFT = 6) = 5 cvt[i] = ((val * scale + 32) >> 6) << xxexp; - debug("cvt[%3d] = %5d -> %5d\n", i, val, cvt[i]); + debug3("cvt[%3d] = %5d -> %5d\n", i, val, cvt[i]); } if (ttFont->prepTable == 0) @@ -198,13 +198,13 @@ y -= gs.round_phase - gs.round_thold; y &= -gs.round_period; y += gs.round_phase; - debug("\tsround(%d) = %d\t", x, (x<0)?-y:+y); + debug2("\tsround(%d) = %d\t", x, (x<0)?-y:+y); break; case ROUND_SUPER45: y -= gs.round_phase - gs.round_thold; y -= y % gs.round_period; y += gs.round_phase; - debug("\tsround45(%d) = %d\t", x, (x<0)?-y:+y); + debug2("\tsround45(%d) = %d\t", x, (x<0)?-y:+y); break; } if (y < 0) return 0; @@ -214,8 +214,8 @@ inline int GraphicsState::absNewMeasure(int dx11D6, int dy11D6) { - debug("\ndx = %d, dy = %d", dx11D6, dy11D6); - debug(",\tpx = %d, py = %d", p_vec_x, p_vec_y); + debug2("\ndx = %d, dy = %d", dx11D6, dy11D6); + debug2(",\tpx = %d, py = %d", p_vec_x, p_vec_y); int dist = dx11D6 * p_vec_x + dy11D6 * p_vec_y + 0x2000; dist >>= 14; @@ -225,8 +225,8 @@ inline int GraphicsState::absOldMeasure(int dx11D6, int dy11D6) { - debug("\ndx = %d, dy = %d", dx11D6, dy11D6); - debug(",\tdpx = %d, dpy = %d", dp_vec_x, dp_vec_y); + debug2("\ndx = %d, dy = %d", dx11D6, dy11D6); + debug2(",\tdpx = %d, dpy = %d", dp_vec_x, dp_vec_y); int dist = dx11D6 * dp_vec_x + dy11D6 * dp_vec_y + 0x2000; dist >>= 14; @@ -237,7 +237,7 @@ Rasterizer::newMeasure(const point& p2, const point& p1) { int dist = gs.absNewMeasure(p2.xnow - p1.xnow, p2.ynow - p1.ynow); - debug("\nnewMeasure p[%d]-p[%d] = %f", + debug3("\nnewMeasure p[%d]-p[%d] = %f", &p2 - p[1], &p1 - p[1], dist / FSHIFT); return dist; @@ -247,7 +247,7 @@ Rasterizer::oldMeasure(const point& p2, const point& p1) { int dist = gs.absOldMeasure(p2.xold - p1.xold, p2.yold - p1.yold); - debug("\noldMeasure p[%d]-p[%d] = %f", + debug3("\noldMeasure p[%d]-p[%d] = %f", &p2 - p[1], &p1 - p[1], dist / FSHIFT); return dist; } @@ -271,9 +271,9 @@ vx = 0; vy = 0; } - debug("\t(%d %d) - ", p2.xnow, p2.ynow); - debug("(%d %d)", p1.xnow, p1.ynow); - debug("\nvx vy = %f %f", vx / FSHIFT, vy / FSHIFT); + debug2("\t(%d %d) - ", p2.xnow, p2.ynow); + debug2("(%d %d)", p1.xnow, p1.ynow); + debug2("\nvx vy = %f %f", vx / FSHIFT, vy / FSHIFT); } void @@ -295,22 +295,22 @@ vx = 0; vy = 0; } - debug("\t(%d %d) - ", p2.xold, p2.yold); - debug("(%d %d)", p1.xold, p1.yold); - debug("\nvx vy = %f %f", vx / FSHIFT, vy / FSHIFT); + debug2("\t(%d %d) - ", p2.xold, p2.yold); + debug2("(%d %d)", p1.xold, p1.yold); + debug2("\nvx vy = %f %f", vx / FSHIFT, vy / FSHIFT); } inline void GraphicsState::movePoint(point& pp, int len11D6) { - debug("\nmovePoint by %f", len11D6 / FSHIFT); - debug("\t(%d %d)", pp.xnow, pp.ynow); + debug1("\nmovePoint by %f", len11D6 / FSHIFT); + debug2("\t(%d %d)", pp.xnow, pp.ynow); pp.xnow += (len11D6 * move_x) >> 14; pp.ynow += (len11D6 * move_y) >> 14; pp.flags |= flags; - debug("\t-> (%d %d)\n", pp.xnow, pp.ynow); + debug2("\t-> (%d %d)\n", pp.xnow, pp.ynow); } void @@ -350,7 +350,7 @@ assert(stack >= stackbase); int opc = f->readUByte(); - debug("\n::%05X %02X\t", f->fileOffset() - 1, opc); + debug2("\n::%05X %02X\t", f->fileOffset() - 1, opc); switch (opc) { // pushing onto the stack @@ -363,11 +363,11 @@ case PUSHB04: case PUSHB05: case PUSHB06: case PUSHB07: m = opc - (PUSHB00 - 1); - debug("PUSHB * %d\n>\t\t", m); + debug1("PUSHB * %d\n>\t\t", m); while (--m >= 0) { ++stack; *stack = f->readUByte(); - debug("%d,\t", *stack); + debug1("%d,\t", *stack); if ((m & 7) == 0) debug("\n>\t\t"); } @@ -381,10 +381,10 @@ case PUSHW04: case PUSHW05: case PUSHW06: case PUSHW07: m = opc - (PUSHW00 - 1); - debug("PUSHW * %d\n>\t\t", m); + debug1("PUSHW * %d\n>\t\t", m); while (--m >= 0) { *(++stack) = f->readSShort(); - debug("%d,\t", *stack); + debug1("%d,\t", *stack); if ((m & 7) == 0) debug("\n>\t\t"); } @@ -396,12 +396,12 @@ m = *stack; assert(m >= 0 && m < sizeStor); *stack = stor[m]; - debug("RS store[%d] = %d", m, *stack); + debug2("RS store[%d] = %d", m, *stack); break; case WS: m = *(stack--); n = *(stack--); - debug("WS %d -> store[%d]", m, n); + debug2("WS %d -> store[%d]", m, n); assert(n >= 0 && n < sizeStor); stor[n] = m; break; @@ -413,7 +413,7 @@ n = *(stack--); assert(n >= 0 && n < sizeCvt); cvt[n] = m; - debug("WCVTP %d -> cvt[%d] = %d", m, n, cvt[n]); + debug3("WCVTP %d -> cvt[%d] = %d", m, n, cvt[n]); break; case WCVTF: m = *(stack--); @@ -421,13 +421,13 @@ assert(n >= 0 && n < sizeCvt); //XXX: how does one scale a scalar with the ((xx,xy),(yx,yy)) matrix??? cvt[n] = ((m * (xx + yy) + 32) >> 6) << xxexp; - debug("#WCVTF %d -> cvt[%d] = %d\n", m, n, cvt[n]); + debug3("#WCVTF %d -> cvt[%d] = %d\n", m, n, cvt[n]); break; case RCVT: m = *stack; assert(m >= 0 && m < sizeCvt); *stack = cvt[m]; - debug("RCVT cvt[%d] = %d", m, *stack); + debug2("RCVT cvt[%d] = %d", m, *stack); break; // accessing the graphics state @@ -493,7 +493,7 @@ case SDPVTL0: m = *(stack--); n = *(stack--); - debug("SDPVTL0 p[%d] p[%d]", m, n); + debug2("SDPVTL0 p[%d] p[%d]", m, n); oldLine2vector(gs.zp1[n], gs.zp2[m], gs.dp_vec_x, gs.dp_vec_y); newLine2vector(gs.zp1[n], gs.zp2[m], gs.p_vec_x, gs.p_vec_y); gs.recalc(); @@ -501,7 +501,7 @@ case SDPVTL1: m = *(stack--); n = *(stack--); - debug("SDPVTL1 p[%d] p[%d]", m, n); + debug2("SDPVTL1 p[%d] p[%d]", m, n); oldLine2vector(gs.zp1[n], gs.zp2[m], gs.dp_vec_y, gs.dp_vec_x); gs.dp_vec_x = -gs.dp_vec_x; newLine2vector(gs.zp1[n], gs.zp2[m], gs.p_vec_y, gs.p_vec_x); @@ -511,7 +511,7 @@ case SPVTL0: m = *(stack--); n = *(stack--); - debug("SPVTL0 p[%d] p[%d]", m, n); + debug2("SPVTL0 p[%d] p[%d]", m, n); newLine2vector(gs.zp1[n], gs.zp2[m], gs.p_vec_x, gs.p_vec_y); gs.dp_vec_x = gs.p_vec_x; gs.dp_vec_y = gs.p_vec_y; @@ -520,7 +520,7 @@ case SPVTL1: m = *(stack--); n = *(stack--); - debug("SPVTL1 p[%d] p[%d]\t", m, n); + debug2("SPVTL1 p[%d] p[%d]\t", m, n); newLine2vector(gs.zp1[n], gs.zp2[m], gs.p_vec_y, gs.p_vec_x); gs.dp_vec_y = gs.p_vec_y = -gs.p_vec_y; gs.dp_vec_x = gs.p_vec_x; @@ -529,14 +529,14 @@ case SFVTL0: m = *(stack--); n = *(stack--); - debug("SFVTL0 p[%d] p[%d]\t", m, n); + debug2("SFVTL0 p[%d] p[%d]\t", m, n); newLine2vector(gs.zp1[n], gs.zp2[m], gs.f_vec_x, gs.f_vec_y); gs.recalc(); break; case SFVTL1: m = *(stack--); n = *(stack--); - debug("SFVTL1 p[%d] p[%d]", m, n); + debug2("SFVTL1 p[%d] p[%d]", m, n); newLine2vector(gs.zp1[n], gs.zp2[m], gs.f_vec_y, gs.f_vec_x); gs.f_vec_y = -gs.f_vec_y; gs.recalc(); @@ -550,58 +550,58 @@ case SPVFS: gs.dp_vec_y = gs.p_vec_y = *(stack--); gs.dp_vec_x = gs.p_vec_x = *(stack--); - debug("#SPVFS = %d %d", gs.p_vec_x, gs.p_vec_y); + debug2("#SPVFS = %d %d", gs.p_vec_x, gs.p_vec_y); gs.recalc(); break; case SFVFS: gs.f_vec_y = *(stack--); gs.f_vec_x = *(stack--); - debug("#SFVFS = %d %d", gs.f_vec_x, gs.f_vec_y); + debug2("#SFVFS = %d %d", gs.f_vec_x, gs.f_vec_y); gs.recalc(); break; case GPV: *(++stack) = gs.p_vec_x; *(++stack) = gs.p_vec_y; - debug("GPV = %d %d", gs.p_vec_x, gs.p_vec_y); + debug2("GPV = %d %d", gs.p_vec_x, gs.p_vec_y); break; case GFV: *(++stack) = gs.f_vec_x; *(++stack) = gs.f_vec_y; - debug("GFV = %d %d", gs.f_vec_x, gs.f_vec_y); + debug2("GFV = %d %d", gs.f_vec_x, gs.f_vec_y); break; case SRP0: gs.rp0 = *(stack--); - debug("SRP0 p[%d]", gs.rp0); + debug1("SRP0 p[%d]", gs.rp0); break; case SRP1: gs.rp1 = *(stack--); - debug("SRP1 p[%d]", gs.rp1); + debug1("SRP1 p[%d]", gs.rp1); break; case SRP2: gs.rp2 = *(stack--); - debug("SRP2 p[%d]", gs.rp2); + debug1("SRP2 p[%d]", gs.rp2); break; case SZP0: m = *(stack--); assert(m >= 0 && m <= 1); gs.zp0 = p[m]; - debug("SZP0 %d", m); + debug1("SZP0 %d", m); break; case SZP1: m = *(stack--); assert(m >= 0 && m <= 1); gs.zp1 = p[m]; - debug("SZP1 %d", m); + debug1("SZP1 %d", m); break; case SZP2: m = *(stack--); assert(m >= 0 && m <= 1); gs.zp2 = p[m]; - debug("SZP2 %d", m); + debug1("SZP2 %d", m); break; case SZPS: m = *(stack--); - debug("SZPS %d", m); + debug1("SZPS %d", m); assert(m >= 0 && m <= 1); gs.zp2 = gs.zp1 = gs.zp0 = p[m]; break; @@ -631,7 +631,7 @@ break; case SROUND: m = *(stack--); - debug("SROUND %d %d %d", (m >> 6) & 3, (m >> 4) & 3, m); + debug3("SROUND %d %d %d", (m >> 6) & 3, (m >> 4) & 3, m); gs.round_state = ROUND_SUPER; n = (m >> 6) & 3; gs.round_period = 0x20 << n; @@ -643,12 +643,12 @@ gs.round_thold = (gs.round_period >> 3) * (m - 4); else gs.round_thold = gs.round_period - 1; - debug("-> period 0x%02X, thold 0x%02X, phase 0x%02X", + debug3("-> period 0x%02X, thold 0x%02X, phase 0x%02X", gs.round_period, gs.round_thold, gs.round_phase); break; case S45ROUND: m = *(stack--); - debug("SROUND45 %d %d %d", (m >> 6) & 3, (m >> 4) & 3, m); + debug3("SROUND45 %d %d %d", (m >> 6) & 3, (m >> 4) & 3, m); gs.round_state = ROUND_SUPER45; gs.round_period = 1444 >> (7 - ((m >> 6) & 3)); gs.round_phase = (gs.round_period * (m & 0x30)) >> 6; @@ -657,21 +657,21 @@ gs.round_thold = (gs.round_period * (m - 4)) >> 3; else gs.round_thold = gs.round_period - 1; - debug("-> period 0x%02X, thold 0x%02X, phase 0x%02X", + debug3("-> period 0x%02X, thold 0x%02X, phase 0x%02X", gs.round_period, gs.round_thold, gs.round_phase); break; case SLOOP: gs.loop = *(stack--); - debug("SLOOP %d", gs.loop); + debug1("SLOOP %d", gs.loop); break; case SMD: gs.min_distance = *(stack--); - debug("SMD %d", gs.min_distance); + debug1("SMD %d", gs.min_distance); break; case INSTCTRL: gs.instr_control = *(stack--); m = *(stack--); - debug("###INSTCTRL %d %d", gs.instr_control, m); + debug2("###INSTCTRL %d %d", gs.instr_control, m); if (gs.instr_control == 1) if (m && grid_fitting >= 0) grid_fitting = -grid_fitting; @@ -685,24 +685,24 @@ if (m & 0x0800 && mppem > (m & 0xff)) gs.dropout_control = 0; if (m & 0x1000 && (xy || yx)) gs.dropout_control = 0; if (m & 0x2000 && xx == yy) gs.dropout_control = 0; - debug("SCANCTRL %04X -> %d", m, gs.dropout_control); + debug2("SCANCTRL %04X -> %d", m, gs.dropout_control); break; case SCANTYPE: m = *(stack--); - debug("###SCANTYPE %d", m); + debug1("###SCANTYPE %d", m); // TODO break; case SCVTCI: gs.cvt_cut_in = *(stack--); - debug("SCVTCI %d", gs.cvt_cut_in); + debug1("SCVTCI %d", gs.cvt_cut_in); break; case SSWCI: gs.swidth_cut_in = *(stack--); - debug("SSWCI %d", gs.swidth_cut_in); + debug1("SSWCI %d", gs.swidth_cut_in); break; case SSW: gs.swidth_value = *(stack--); - debug("SSW %d", gs.swidth_value); + debug1("SSW %d", gs.swidth_value); break; case FLIPON: gs.auto_flip = 1; @@ -715,37 +715,37 @@ case SANGW: // angle_weight is obsolete! m = *(stack--); - debug("SANGW %d is obsolete", m); + debug1("SANGW %d is obsolete", m); break; case SDB: gs.delta_base = *(stack--); - debug("SDB %d", gs.delta_base); + debug1("SDB %d", gs.delta_base); break; case SDS: gs.delta_shift = *(stack--); - debug("SDS %d", gs.delta_shift); + debug1("SDS %d", gs.delta_shift); break; // do some measurements case GC0: pp = &gs.zp2[*stack]; - debug("GC0 p[%d][%d]\t", gs.zp2 == p[1], pp - gs.zp2); + debug2("GC0 p[%d][%d]\t", gs.zp2 == p[1], pp - gs.zp2); *stack = gs.absNewMeasure(pp->xnow, pp->ynow); - debug("\t=> %d", *stack); + debug1("\t=> %d", *stack); break; case GC1: pp = &gs.zp2[*stack]; - debug("GC1 p[%d][%d]\t", gs.zp2 == p[1], pp - gs.zp2); + debug2("GC1 p[%d][%d]\t", gs.zp2 == p[1], pp - gs.zp2); *stack = gs.absOldMeasure(pp->xold, pp->yold); - debug("\t=> %d", *stack); + debug1("\t=> %d", *stack); break; case SCFS: // move point along freedom vector, so that // projection gets desired length m = *(stack--); n = *(stack--); - debug("SCFS p[%d][%d] to %f", gs.zp2 == p[1], n, m / FSHIFT); + debug3("SCFS p[%d][%d] to %f", gs.zp2 == p[1], n, m / FSHIFT); pp = &gs.zp2[n]; if (gs.zp2 == p[1]) { int i = gs.absNewMeasure(pp->xnow, pp->ynow); @@ -758,15 +758,15 @@ case MD0: m = *(stack--); n = *stack; - debug("MD0 p[%d][%d] ", gs.zp1 == p[1], m); - debug("- p[%d][%d]", gs.zp0 == p[1], n); + debug2("MD0 p[%d][%d] ", gs.zp1 == p[1], m); + debug2("- p[%d][%d]", gs.zp0 == p[1], n); *stack = newMeasure(gs.zp0[n], gs.zp1[m]); break; case MD1: m = *(stack--); n = *stack; - debug("MD1 p[%d][%d] ", gs.zp1 == p[1], m); - debug("- p[%d][%d]", gs.zp0 == p[1], n); + debug2("MD1 p[%d][%d] ", gs.zp1 == p[1], m); + debug2("- p[%d][%d]", gs.zp0 == p[1], n); *stack = oldMeasure(gs.zp0[n], gs.zp1[m]); // Thanks David break; case MPPEM: @@ -775,11 +775,11 @@ if (m < 0) m = -m; *(++stack) = m; - debug("\t => mppem = %d", m); + debug1("\t => mppem = %d", m); break; case MPS: *(++stack) = pointSize; - debug("MPS %d", *stack); + debug1("MPS %d", *stack); break; // outline manipulation @@ -787,7 +787,7 @@ case FLIPPT: for (m = gs.loop; --m >= 0;) { n = *(stack--); - debug("FLIPPT * %d p[%d][%d]", m, gs.zp0 == p[1], n); + debug3("FLIPPT * %d p[%d][%d]", m, gs.zp0 == p[1], n); gs.zp1[n].flags ^= ON_CURVE; } gs.loop = 1; @@ -795,7 +795,7 @@ case FLIPRGON: m = *(stack--); n = *(stack--); - debug("FLIPRGON p[%d][%d .. %d]", gs.zp0 == p[1], n, m); + debug3("FLIPRGON p[%d][%d .. %d]", gs.zp0 == p[1], n, m); pp = &gs.zp1[n]; for (m -= n-1; --m >= 0; ++pp) pp->flags |= ON_CURVE; @@ -803,7 +803,7 @@ case FLIPRGOFF: m = *(stack--); n = *(stack--); - debug("FLIPRGOFF p[%d][%d .. %d]", gs.zp0 == p[1], n, m); + debug3("FLIPRGOFF p[%d][%d .. %d]", gs.zp0 == p[1], n, m); pp = &gs.zp1[n]; for (m -= n-1; --m >= 0; ++pp) pp->flags &= ~ON_CURVE; @@ -814,8 +814,8 @@ n = gs.absNewMeasure(pp->xnow - pp->xold, pp->ynow - pp->yold); for (m = gs.loop; --m >= 0;) { int i = *(stack--); - debug("SHP * %d p[%d], rp = p[%d]", m, i, pp-p[1]); - debug(" moved by %f", n / FSHIFT); + debug3("SHP * %d p[%d], rp = p[%d]", m, i, pp-p[1]); + debug1(" moved by %f", n / FSHIFT); gs.movePoint(gs.zp2[i], n); } gs.loop = 1; @@ -826,14 +826,14 @@ m = *(stack--); assert(m >= 0 && m < sizeContours); pp = (opc & 1) ? &gs.zp0[gs.rp1] : &gs.zp1[gs.rp2]; - debug("SHC%d rp[%d]", opc & 1, pp - p[1]); + debug2("SHC%d rp[%d]", opc & 1, pp - p[1]); n = gs.absNewMeasure(pp->xnow - pp->xold, pp->ynow - pp->yold); int i = (m <= 0) ? 0 : endPoints[m-1] + 1; m = (gs.zp2 == p[0]) ? nPoints[0] : endPoints[m]; for (; i <= m; ++i) { if (pp == &gs.zp2[i]) continue; - debug("SHC%d p[%d] by %f\n", opc & 1, i, n / FSHIFT); + debug3("SHC%d p[%d] by %f\n", opc & 1, i, n / FSHIFT); gs.movePoint(gs.zp2[i], n); } } @@ -841,32 +841,32 @@ case SHZ0: case SHZ1: m = *(stack--); - debug("SHZ%d rp = p[%d]\n ", opc & 1, + debug2("SHZ%d rp = p[%d]\n ", opc & 1, (opc & 1) ? gs.rp1 : gs.rp2); pp = (opc & 1) ? &gs.zp0[gs.rp1] : &gs.zp1[gs.rp2]; n = gs.absNewMeasure(pp->xnow - pp->xold, pp->ynow - pp->yold); assert(m >= 0 && m <= 1); for (point *pp1 = p[m], *pp2 = pp1 + nPoints[m]; pp1 < pp2; ++pp1) { if (pp1 == pp) continue; - debug("\nSHZ p[%d] by %f", pp1 - p[m], n / FSHIFT); - debug("\t(%d %d) -> ", pp1->xnow, pp1->ynow); + debug2("\nSHZ p[%d] by %f", pp1 - p[m], n / FSHIFT); + debug2("\t(%d %d) -> ", pp1->xnow, pp1->ynow); pp1->xnow += (n * gs.move_x) >> 14; pp1->ynow += (n * gs.move_y) >> 14; - debug("(%d %d)\n", pp1->xnow, pp1->ynow); + debug2("(%d %d)\n", pp1->xnow, pp1->ynow); } break; case SHPIX: m = *(stack--); for (n = gs.loop; --n >= 0;) { int i = *(stack--); - debug("SHPIX * %d p[%d][%d] ", n, gs.zp2 == p[1], i); - debug("by %f", m / FSHIFT); + debug3("SHPIX * %d p[%d][%d] ", n, gs.zp2 == p[1], i); + debug1("by %f", m / FSHIFT); pp = &gs.zp2[i]; - debug("\n%d %d ->", pp->xnow, pp->ynow); + debug2("\n%d %d ->", pp->xnow, pp->ynow); pp->xnow += (m * gs.f_vec_x) >> 14; pp->ynow += (m * gs.f_vec_y) >> 14; pp->flags |= gs.flags; - debug("\t%d %d", pp->xnow, pp->ynow); + debug2("\t%d %d", pp->xnow, pp->ynow); } gs.loop = 1; break; @@ -876,8 +876,8 @@ n = *(stack--); gs.rp2 = n; gs.rp1 = gs.rp0; - debug("MSIRP%d p[%d][%d] ", opc & 1, gs.zp1 == p[1], n); - debug("to %f, rp = p[%d][%d]", m / FSHIFT, + debug3("MSIRP%d p[%d][%d] ", opc & 1, gs.zp1 == p[1], n); + debug3("to %f, rp = p[%d][%d]", m / FSHIFT, gs.zp0 == p[1], gs.rp0); if (gs.zp1 == p[1]) { int i = newMeasure(p[1][n], gs.zp0[gs.rp0]); @@ -895,9 +895,9 @@ case MDAP0: case MDAP1: gs.rp0 = gs.rp1 = *(stack--); - debug("MDAP%d p[%d]", opc & 1, gs.rp0); + debug2("MDAP%d p[%d]", opc & 1, gs.rp0); pp = &gs.zp0[gs.rp0]; - debug("\nxy %d %d", pp->xnow, pp->ynow); + debug2("\nxy %d %d", pp->xnow, pp->ynow); pp->flags |= gs.flags; if (opc & 1) { #if 0 // XXX @@ -905,11 +905,11 @@ pp->xnow = round(pp->xnow); if (gs.f_vec_y) pp->ynow = round(pp->ynow); - debug("\t-> %d %d", pp->xnow, pp->ynow); + debug2("\t-> %d %d", pp->xnow, pp->ynow); #else m = gs.absNewMeasure(pp->xnow, pp->ynow); gs.movePoint(*pp, round(m) - m); - debug("\t-> %d %d", pp->xnow, pp->ynow); + debug2("\t-> %d %d", pp->xnow, pp->ynow); #endif } break; @@ -917,10 +917,10 @@ case MIAP1: m = *(stack--); gs.rp0 = gs.rp1 = *(stack--); - debug("MIAP%d p[%d][%d] ", opc & 1, gs.zp0 == p[1], gs.rp0); - debug("to cvt[%d] = ", m); + debug3("MIAP%d p[%d][%d] ", opc & 1, gs.zp0 == p[1], gs.rp0); + debug1("to cvt[%d] = ", m); m = cvt[m]; - debug("%f", m / FSHIFT); + debug1("%f", m / FSHIFT); if (gs.zp0 != p[0]) { pp = &p[1][gs.rp0]; int i = gs.absNewMeasure(pp->xnow, pp->ynow); @@ -929,7 +929,7 @@ m = i; m = round(m); } - debug("\nabsdist = %f", i / FSHIFT); + debug1("\nabsdist = %f", i / FSHIFT); gs.movePoint(gs.zp0[gs.rp0], m - i); } else { // magic in the twilight zone pp = &p[0][gs.rp0]; @@ -959,18 +959,18 @@ case MDRP1E: case MDRP1F: gs.rp2 = *(stack--); gs.rp1 = gs.rp0; - debug("#MDRP%02X p[%d], rp = p[%d]", opc & 15, gs.rp2, gs.rp0); + debug3("#MDRP%02X p[%d], rp = p[%d]", opc & 15, gs.rp2, gs.rp0); n = oldMeasure(gs.zp1[gs.rp2], gs.zp0[gs.rp0]); m = newMeasure(gs.zp1[gs.rp2], gs.zp0[gs.rp0]); - debug("\nwgoaldist = %f, nowdist = %f", n / FSHIFT, m / FSHIFT); - debug("\n(%d %d)-", gs.zp1[gs.rp2].xnow, gs.zp1[gs.rp2].ynow); - debug("rp0(%d %d)", gs.zp0[gs.rp0].xnow, gs.zp0[gs.rp0].ynow); + debug2("\nwgoaldist = %f, nowdist = %f", n / FSHIFT, m / FSHIFT); + debug2("\n(%d %d)-", gs.zp1[gs.rp2].xnow, gs.zp1[gs.rp2].ynow); + debug2("rp0(%d %d)", gs.zp0[gs.rp0].xnow, gs.zp0[gs.rp0].ynow); if (((n >= 0) ? +n : -n) < gs.swidth_cut_in) n = (n >= 0) ? +gs.swidth_value : -gs.swidth_value; if (opc & 0x10) gs.rp0 = gs.rp2; - debug("\nmdrp1.wanted = %d", n); + debug1("\nmdrp1.wanted = %d", n); if (opc & 0x08) if (n >= 0) { if (n < +gs.min_distance) @@ -981,7 +981,7 @@ } if (opc & 0x04) n = round(n); - debug("\nmdrp2.wanted = %d", n); + debug1("\nmdrp2.wanted = %d", n); // XXX: ignore black/gray/white for now gs.movePoint(gs.zp1[gs.rp2], n - m); break; @@ -1005,10 +1005,10 @@ m = *(stack--); gs.rp2 = *(stack--); pp = &gs.zp1[gs.rp2]; - debug("#MIRP%02X p[%d] with cvt[%d]", opc & 15, gs.rp2, m); + debug3("#MIRP%02X p[%d] with cvt[%d]", opc & 15, gs.rp2, m); m = cvt[m]; - debug(" = %f, rp = p[%d]", m / FSHIFT, gs.rp0); + debug2(" = %f, rp = p[%d]", m / FSHIFT, gs.rp0); if (((m >= 0)? +m : -m) < +gs.swidth_cut_in) m = (m >= 0) ? +gs.swidth_value : -gs.swidth_value; @@ -1016,7 +1016,7 @@ if ((n^m) < 0 && gs.auto_flip) { m = -m; - debug("\nautoflip m = %f", m / FSHIFT); + debug1("\nautoflip m = %f", m / FSHIFT); } if (opc & 0x04) { if (((m>n) ? m - n : n - m) >= +gs.cvt_cut_in) @@ -1041,7 +1041,7 @@ case ALIGNRP: for (m = gs.loop; --m >= 0;) { int n = *(stack--); - debug("ALIGNRP * %d p[%d], rp0 = p[%d]", m, n, gs.rp0); + debug3("ALIGNRP * %d p[%d], rp0 = p[%d]", m, n, gs.rp0); int i = newMeasure(gs.zp0[gs.rp0], gs.zp1[n]); gs.movePoint(gs.zp1[n], i); } @@ -1051,7 +1051,7 @@ { m = *(stack--); n = *(stack--); - debug("ALIGNPTS %d %d", m, n); + debug2("ALIGNPTS %d %d", m, n); int i = newMeasure(gs.zp0[m], gs.zp1[n]) >> 1; gs.movePoint(gs.zp0[m], -i); gs.movePoint(gs.zp1[n], +i); @@ -1065,9 +1065,9 @@ point* pp4 = &gs.zp0[*(stack--)]; m = *(stack--); - debug("ISECT p[%d] ", m); - debug("between p[%d]-p[%d] ", pp1-gs.zp1, pp2-gs.zp1); - debug("and p[%d]-p[%d] ", pp3-gs.zp0, pp4-gs.zp0); + debug1("ISECT p[%d] ", m); + debug2("between p[%d]-p[%d] ", pp1-gs.zp1, pp2-gs.zp1); + debug2("and p[%d]-p[%d] ", pp3-gs.zp0, pp4-gs.zp0); int f1 = (pp1->xnow - pp3->xnow) * (pp4->ynow - pp3->ynow) - (pp1->ynow - pp3->ynow) * (pp4->xnow - pp3->xnow); @@ -1087,7 +1087,7 @@ MULDIV(f1, pp2->ynow - pp1->ynow, f2); } - debug("\n-> %d %d", pp3->xnow, pp3->ynow); + debug2("\n-> %d %d", pp3->xnow, pp3->ynow); } break; case AA: @@ -1097,9 +1097,9 @@ case IP: for (m = gs.loop; --m >= 0;) { int n = *(stack--); - debug("IP * %d p[%d] ", m, n); - debug("between p[%d][%d] ", gs.zp1 == p[1], gs.rp2); - debug("and p[%d][%d]", gs.zp0 == p[1], gs.rp1); + debug2("IP * %d p[%d] ", m, n); + debug2("between p[%d][%d] ", gs.zp1 == p[1], gs.rp2); + debug2("and p[%d][%d]", gs.zp0 == p[1], gs.rp1); interpolate(gs.zp2[n], gs.zp1[gs.rp2], gs.zp0[gs.rp1]); debug("\n"); } @@ -1108,13 +1108,13 @@ case UTP: m = *(stack--); gs.zp0[m].flags &= ~(X_TOUCHED | Y_TOUCHED); - debug("UTP p[%d]", m); + debug1("UTP p[%d]", m); break; case IUP0: pp = p[1]; for (m = 0; m < nEndPoints; ++m) { point* last = p[1] + endPoints[m]; - debug("IUP0 p[%d .. %d]", pp - p[1], last - p[1]); + debug2("IUP0 p[%d .. %d]", pp - p[1], last - p[1]); doIUP0(pp, last); pp = last + 1; } @@ -1123,7 +1123,7 @@ pp = p[1]; for (m = 0; m < nEndPoints; ++m) { point* last = p[1] + endPoints[m]; - debug("IUP1 p[%d .. %d]", pp - p[1], last - p[1]); + debug2("IUP1 p[%d .. %d]", pp - p[1], last - p[1]); doIUP1(pp, last); pp = last + 1; } @@ -1138,11 +1138,11 @@ n = 0; deltap_label: m = *(stack--); - debug("DELTAP%d * %d", (-n >> 4) + 1, m); - debug("\tmppem=%d, deltabase=%d", mppem, gs.delta_base); + debug2("DELTAP%d * %d", (-n >> 4) + 1, m); + debug2("\tmppem=%d, deltabase=%d", mppem, gs.delta_base); n += mppem - gs.delta_base; if (n < 0 || n > 15) { - debug("\n=> skipping %d exceptions", m); + debug1("\n=> skipping %d exceptions", m); stack -= m << 1; break; } @@ -1150,8 +1150,8 @@ while (--m >= 0) { int pno = *(stack--); int arg = *(stack--); - debug("\np[%d] arg %04X", pno, arg); - debug("\targ.n=%d, n=%d", arg >> 4, n >> 4); + debug2("\np[%d] arg %04X", pno, arg); + debug2("\targ.n=%d, n=%d", arg >> 4, n >> 4); if (n > (arg & 0xf0)) break; if (n == (arg & 0xf0)) { @@ -1159,7 +1159,7 @@ if (arg >= 0) ++arg; arg <<= (SHIFT - gs.delta_shift); - debug("\tmoving by %f from (%d %d) ", + debug3("\tmoving by %f from (%d %d) ", arg / FSHIFT, gs.zp0[pno].xnow, gs.zp0[pno].ynow); #if 0 @@ -1169,7 +1169,7 @@ gs.zp0[pno].ynow += (arg * gs.f_vec_y) >> 14; gs.zp0[pno].flags |= gs.flags; #endif - debug("to (%d %d)\n", + debug2("to (%d %d)\n", gs.zp0[pno].xnow, gs.zp0[pno].ynow); } } @@ -1198,8 +1198,8 @@ n = 0; deltac_label: m = *(stack--); - debug("DELTAC%d * %d", (-n >> 4) + 1, m); - debug("\tmppem=%d, deltabase=%d", mppem, gs.delta_base); + debug2("DELTAC%d * %d", (-n >> 4) + 1, m); + debug2("\tmppem=%d, deltabase=%d", mppem, gs.delta_base); n += mppem - gs.delta_base; if (n < 0 || n > 15) { stack -= m << 1; @@ -1209,7 +1209,7 @@ while (--m >= 0) { int cno = *(stack--); int arg = *(stack--); - debug("\ncvt[%d] arg = %04X, n = %d", + debug3("\ncvt[%d] arg = %04X, n = %d", cno, arg, n >> 4); if (n > (arg & 0xf0)) break; @@ -1217,10 +1217,10 @@ arg = (arg & 15) - 8; if (arg >= 0) ++arg; arg <<= SHIFT - gs.delta_shift; - debug("\tmoved by %f,\t%d ", + debug2("\tmoved by %f,\t%d ", arg / FSHIFT, cvt[cno]); cvt[cno] += arg; - debug("-> %d", cvt[cno]); + debug1("-> %d", cvt[cno]); } } #ifndef DEBUG @@ -1230,8 +1230,8 @@ while (--m >= 0) { int cno = *(stack--); int arg = *(stack--); - debug("\n(cvt[%d] arg %04X", cno, arg); - debug("\targ.n=%d, n=%d)", arg >> 4, n >> 4); + debug2("\n(cvt[%d] arg %04X", cno, arg); + debug2("\targ.n=%d, n=%d)", arg >> 4, n >> 4); }; #endif break; @@ -1241,7 +1241,7 @@ case DUP: m = *stack; *(++stack) = m; - debug("DUP = %d", m); + debug1("DUP = %d", m); break; case POP: debug("POP"); @@ -1260,20 +1260,20 @@ case DEPTH: m = stack - stackbase; *(++stack) = m; - debug("DEPTH = %d", m); + debug1("DEPTH = %d", m); break; case CINDEX: m = *stack; assert(stack - m >= stackbase); *stack = *(stack - m); - debug("CINDEX %d = %d", m, *stack); + debug2("CINDEX %d = %d", m, *stack); break; case MINDEX: m = *stack; stack -= m; assert(stack >= stackbase); n = *stack; - debug("MINDEX %d = %d", m, n); + debug2("MINDEX %d = %d", m, n); for (; --m > 0; ++stack) stack[0] = stack[1]; *stack = n; @@ -1283,15 +1283,15 @@ *(stack - 0) = *(stack - 2); *(stack - 2) = *(stack - 1); *(stack - 1) = m; - debug("ROLL %d %d %d", m, *(stack - 2), *stack); - debug(" => %d %d %d", *stack, m, *(stack - 2)); + debug3("ROLL %d %d %d", m, *(stack - 2), *stack); + debug3(" => %d %d %d", *stack, m, *(stack - 2)); break; // control flow case IF: m = *(stack--); - debug("IF %d", m); + debug1("IF %d", m); if (!m) skipHints(f); break; @@ -1305,7 +1305,7 @@ break; case JROT: m = *(stack--); - debug("JROT %d -> ", m); + debug1("JROT %d -> ", m); if (m) goto jump_relative; debug("not taken"); @@ -1313,7 +1313,7 @@ break; case JROF: m = *(stack--); - debug("JROF %d -> ", m); + debug1("JROF %d -> ", m); if (!m) goto jump_relative; debug("not taken"); @@ -1322,81 +1322,81 @@ case JMPR: jump_relative: m = *(stack--); - debug("JMPR %d", m); + debug1("JMPR %d", m); f->seekRelative(m-1); break; case LT: m = *(stack--); n = *stack; *stack = (n < m); - debug("LT %d %d = %d", m, n, *stack); + debug3("LT %d %d = %d", m, n, *stack); break; case LTEQ: m = *(stack--); n = *stack; *stack = (n <= m); - debug("LTEQ %d %d = %d", m, n, *stack); + debug3("LTEQ %d %d = %d", m, n, *stack); break; case GT: m = *(stack--); n = *stack; *stack = (n > m); - debug("GT %d %d = %d", m, n, *stack); + debug3("GT %d %d = %d", m, n, *stack); break; case GTEQ: m = *(stack--); n = *stack; *stack = (n >= m); - debug("GTEQ %d %d = %d", m, n, *stack); + debug3("GTEQ %d %d = %d", m, n, *stack); break; case EQ: m = *(stack--); n = *stack; *stack = (m == n); - debug("EQ %d %d = %d", m, n, *stack); + debug3("EQ %d %d = %d", m, n, *stack); break; case NEQ: m = *(stack--); n = *stack; *stack = (m != n); - debug("NEQ %d %d = %d", m, n, *stack); + debug3("NEQ %d %d = %d", m, n, *stack); break; case ODD: m = *stack; *stack = (round(m) >> SHIFT) & 1; - debug("ODD %d = %d", m, *stack); + debug2("ODD %d = %d", m, *stack); break; case EVEN: m = *stack; *stack = ((~round(m)) >> SHIFT) & 1; - debug("EVEN %d = %d", m, *stack); + debug2("EVEN %d = %d", m, *stack); break; case AND: m = *(stack--); n = *stack; *stack = n && m; - debug("AND %d %d = %d", m, n, *stack); + debug3("AND %d %d = %d", m, n, *stack); break; case OR: m = *(stack--); n = *stack; *stack = n || m; - debug("OR %d %d = %d", m, n, *stack); + debug3("OR %d %d = %d", m, n, *stack); break; case NOT: m = *stack; *stack = !m; - debug("NOT %d = %d", m, *stack); + debug2("NOT %d = %d", m, *stack); break; case ADD: m = *(stack--); *stack += m; - debug("ADD %d %d = %d", m, *stack - m, *stack); + debug3("ADD %d %d = %d", m, *stack - m, *stack); break; case SUB: m = *(stack--); *stack -= m; - debug("SUB %d %d = %d", m, *stack + m, *stack); + debug3("SUB %d %d = %d", m, *stack + m, *stack); break; case DIV: m = *(stack--); @@ -1405,46 +1405,46 @@ *stack = (n << SHIFT) / m; else *stack = (n >= 0) ? 0x7ffffff : -0x7ffffff; - debug("DIV %d %d = %d", m, n, *stack); + debug3("DIV %d %d = %d", m, n, *stack); break; case MUL: m = *(stack--); n = *stack; *stack = (m * n + 32) >> SHIFT; - debug("MUL %d %d = %d", m, n, *stack); + debug3("MUL %d %d = %d", m, n, *stack); break; case ABS: m = *stack; if (m < 0) *stack = -m; - debug("ABS %d = %d", m, *stack); + debug2("ABS %d = %d", m, *stack); break; case NEG: *stack = -*stack; - debug("NEG %d = %d", -*stack, *stack); + debug2("NEG %d = %d", -*stack, *stack); break; case FLOOR: m = *stack; *stack = m & -64; - debug("FLOOR %d = %d", m, *stack); + debug2("FLOOR %d = %d", m, *stack); break; case CEILING: m = *stack; *stack = (m + 63) & -64; - debug("CEILING %d = %d", m, *stack); + debug2("CEILING %d = %d", m, *stack); break; case MAX: m = *(stack--); n = *stack; if (m > n) *stack = m; - debug("MAX %d %d = %d", m, n, *stack); + debug3("MAX %d %d = %d", m, n, *stack); break; case MIN: m = *(stack--); n = *stack; if (m < n) *stack = m; - debug("MIN %d %d = %d", m, n, *stack); + debug3("MIN %d %d = %d", m, n, *stack); break; case ROUND00: case ROUND01: case ROUND02: case ROUND03: @@ -1452,7 +1452,7 @@ m = *stack; // XXX: ignore black/gray/white for now *stack = round(m); - debug("#ROUND%02X %d = %d", opc & 3, m, *stack); + debug3("#ROUND%02X %d = %d", opc & 3, m, *stack); break; case NROUND00: case NROUND01: case NROUND02: case NROUND03: @@ -1460,11 +1460,11 @@ m = *stack; // XXX: ignore black/gray/white for now *stack = m; - debug("#NROUND%02X %d = %d", opc & 3, m, *stack); + debug3("#NROUND%02X %d = %d", opc & 3, m, *stack); break; case FDEF: m = *(stack--); - debug("FDEF %d", m); + debug1("FDEF %d", m); assert(m >= 0 && m < sizeFDefs); fdefs[m].f = f; fdefs[m].offset = f->tell(); @@ -1476,7 +1476,7 @@ return; case IDEF: m = *(stack--); - debug("IDEF %02X", m); + debug1("IDEF %02X", m); assert(m >= 0 && m < sizeIDefs); idefs[m].f = f; idefs[m].offset = f->tell(); @@ -1486,7 +1486,7 @@ case CALL: { m = *(stack--); - debug("CALL %d\n", m); + debug1("CALL %d\n", m); assert(m >= 0 && m < sizeFDefs); int ofs = f->tell(); @@ -1500,7 +1500,7 @@ { m = *(stack--); n = *(stack--); - debug("LOOPCALL %d * %d\n", m, n); + debug2("LOOPCALL %d * %d\n", m, n); int ofs = f->tell(); FDefs* fd = &fdefs[m]; @@ -1524,19 +1524,19 @@ if (m & GLYPH_STRETCHED) if (xx != yy) *stack |= IS_STRETCHED; - debug("GETINFO %d = 0x%03X", m, *stack); + debug2("GETINFO %d = 0x%03X", m, *stack); break; default: { int ofs = f->tell(); IDefs* idef = &idefs[opc]; - debug("IDEF_CALL 0x%02X, ofs = %05X, len = %d\n", + debug3("IDEF_CALL 0x%02X, ofs = %05X, len = %d\n", opc, idef->offset, idef->length); if (idef->length) // Thanks Colin McCormack execHints(idef->f, idef->offset, idef->length); else - debug("illegal instruction %02X\n", opc); + debug1("illegal instruction %02X\n", opc); f->seekAbsolute(ofs); } @@ -1578,7 +1578,7 @@ debug("\nskipping..."); for (int depth = 0;;) { int opc = f->readUByte(); - debug(" %02X ", opc); + debug1(" %02X ", opc); switch (opc) { case NPUSHB: opc = f->readUByte() + PUSHB00 - 1; @@ -1642,7 +1642,7 @@ dist = MULDIV(doldp1, dnew21, dold21) - dnewp1; } - debug("\nmove by %f", dist / FSHIFT); + debug1("\nmove by %f", dist / FSHIFT); gs.movePoint(pp, dist); } @@ -1653,11 +1653,11 @@ int dold21 = p2->yold - p1->yold; int doldp1 = pp->yold - p1->yold; - debug("\np[%d] between p[%d] and p[%d]", pp - p[1], p1 - p[1], + debug3("\np[%d] between p[%d] and p[%d]", pp - p[1], p1 - p[1], p2 - p[1]); - debug("\nd21o dp1o %f %f", dold21 / FSHIFT, doldp1 / FSHIFT); + debug2("\nd21o dp1o %f %f", dold21 / FSHIFT, doldp1 / FSHIFT); - debug("\tchanging y: %d %d", pp->xnow, pp->ynow); + debug2("\tchanging y: %d %d", pp->xnow, pp->ynow); if ((dold21 ^ doldp1) < 0 || doldp1 == 0) pp->ynow = pp->yold + p1->ynow - p1->yold; @@ -1666,11 +1666,11 @@ pp->ynow = pp->yold + p2->ynow - p2->yold; else { int dnew21 = p2->ynow - p1->ynow; - debug("\nd21n %8.3f", dnew21 / FSHIFT); + debug1("\nd21n %8.3f", dnew21 / FSHIFT); pp->ynow = MULDIV(doldp1 + 1, dnew21, dold21) + p1->ynow; } - debug(" -> %d %d\n", pp->xnow, pp->ynow); + debug2(" -> %d %d\n", pp->xnow, pp->ynow); } @@ -1680,11 +1680,11 @@ int dold21 = p2->xold - p1->xold; int doldp1 = pp->xold - p1->xold; - debug("\np[%d] between p[%d] and p[%d]", pp - p[1], p1 - p[1], + debug3("\np[%d] between p[%d] and p[%d]", pp - p[1], p1 - p[1], p2 - p[1]); - debug("\nd21o dp1o %f %f", dold21 / FSHIFT, doldp1 / FSHIFT); + debug2("\nd21o dp1o %f %f", dold21 / FSHIFT, doldp1 / FSHIFT); - debug("\nchanging x: %d %d", pp->xnow, pp->ynow); + debug2("\nchanging x: %d %d", pp->xnow, pp->ynow); if ((dold21 ^ doldp1) < 0 || doldp1 == 0) pp->xnow = pp->xold + p1->xnow - p1->xold; @@ -1693,11 +1693,11 @@ pp->xnow = pp->xold + p2->xnow - p2->xold; else { int dnew21 = p2->xnow - p1->xnow; - debug("\t(d21n %8.3f)", dnew21 / FSHIFT); + debug1("\t(d21n %8.3f)", dnew21 / FSHIFT); pp->xnow = MULDIV(doldp1 + 1, dnew21, dold21) + p1->xnow; } - debug(" -> %d %d\n", pp->xnow, pp->ynow); + debug2(" -> %d %d\n", pp->xnow, pp->ynow); }