emf-converter 4.4.5 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +79 -24
- package/dist/browser.mjs +79 -24
- package/dist/index.js +79 -24
- package/dist/index.mjs +79 -24
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -10316,6 +10316,49 @@ async function decodePng(bytes) {
|
|
|
10316
10316
|
var import_jpeg_js = __toESM(require_jpeg_js());
|
|
10317
10317
|
var import_gifuct_js = __toESM(require_lib2());
|
|
10318
10318
|
var UTIF = __toESM(require_UTIF());
|
|
10319
|
+
|
|
10320
|
+
// src/tiff-group3.ts
|
|
10321
|
+
function normalizeGroup3(buffer, page) {
|
|
10322
|
+
const options = Array.isArray(page.t292) ? Number(page.t292[0]) : 0;
|
|
10323
|
+
if (!Array.isArray(page.t259) || page.t259[0] !== 3 || (options & 3) !== 0) return buffer;
|
|
10324
|
+
const offsets = page.t273, lengths = page.t279;
|
|
10325
|
+
if (!Array.isArray(offsets) || !Array.isArray(lengths) || offsets.length !== lengths.length) return buffer;
|
|
10326
|
+
const source = new Uint8Array(buffer);
|
|
10327
|
+
const leastFirst = Array.isArray(page.t266) && page.t266[0] === 2;
|
|
10328
|
+
const strips = offsets.map((offset, i) => {
|
|
10329
|
+
const start = Number(offset), length = Number(lengths[i]);
|
|
10330
|
+
if (!Number.isInteger(start) || !Number.isInteger(length) || start < 0 || length < 0 || start + length > source.length) throw new Error("Invalid TIFF strip");
|
|
10331
|
+
const output = new Uint8Array(Math.ceil(length * 8 * 13 / 12 / 8) + 1);
|
|
10332
|
+
let position2 = 0, zeros = 0;
|
|
10333
|
+
const write = (bit) => {
|
|
10334
|
+
if (bit) output[position2 >>> 3] |= 1 << (leastFirst ? position2 & 7 : 7 - (position2 & 7));
|
|
10335
|
+
position2++;
|
|
10336
|
+
};
|
|
10337
|
+
for (let bitPosition = 0; bitPosition < length * 8; bitPosition++) {
|
|
10338
|
+
const bit = source[start + (bitPosition >>> 3)] >>> (leastFirst ? bitPosition & 7 : 7 - (bitPosition & 7)) & 1;
|
|
10339
|
+
write(bit);
|
|
10340
|
+
if (bit) {
|
|
10341
|
+
if (zeros >= 11) write(1);
|
|
10342
|
+
zeros = 0;
|
|
10343
|
+
} else zeros++;
|
|
10344
|
+
}
|
|
10345
|
+
return output.subarray(0, Math.ceil(position2 / 8));
|
|
10346
|
+
});
|
|
10347
|
+
const normalized = new Uint8Array(strips.reduce((size, strip) => size + strip.length, source.length));
|
|
10348
|
+
normalized.set(source);
|
|
10349
|
+
let position = source.length;
|
|
10350
|
+
page.t273 = strips.map((strip) => {
|
|
10351
|
+
const offset = position;
|
|
10352
|
+
normalized.set(strip, position);
|
|
10353
|
+
position += strip.length;
|
|
10354
|
+
return offset;
|
|
10355
|
+
});
|
|
10356
|
+
page.t279 = strips.map((strip) => strip.length);
|
|
10357
|
+
page.t292 = [options | 1];
|
|
10358
|
+
return normalized.buffer;
|
|
10359
|
+
}
|
|
10360
|
+
|
|
10361
|
+
// src/image-codec-fallback.ts
|
|
10319
10362
|
var validSize = (w, h) => Number.isInteger(w) && Number.isInteger(h) && w > 0 && h > 0 && w <= 8192 && h <= 8192;
|
|
10320
10363
|
function decodeImageCodecFallback(bytes) {
|
|
10321
10364
|
try {
|
|
@@ -10354,7 +10397,7 @@ function decodeImageCodecFallback(bytes) {
|
|
|
10354
10397
|
const pages = UTIF.decode(buffer);
|
|
10355
10398
|
const page = pages.find((p) => p.t256 && p.t257);
|
|
10356
10399
|
if (!page || !Array.isArray(page.t256) || !Array.isArray(page.t257) || !validSize(Number(page.t256[0]), Number(page.t257[0]))) return null;
|
|
10357
|
-
UTIF.decodeImage(buffer, page);
|
|
10400
|
+
UTIF.decodeImage(normalizeGroup3(buffer, page), page);
|
|
10358
10401
|
const width = page.width, height = page.height;
|
|
10359
10402
|
if (!validSize(width, height)) return null;
|
|
10360
10403
|
const data = UTIF.toRGBA8(page);
|
|
@@ -11290,7 +11333,7 @@ var GdiRasterPath = class {
|
|
|
11290
11333
|
/** Appends every figure of `other`. */
|
|
11291
11334
|
append(other) {
|
|
11292
11335
|
for (const f of other.figures) {
|
|
11293
|
-
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
|
|
11336
|
+
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
|
|
11294
11337
|
}
|
|
11295
11338
|
for (let i = 0; i < other.getPath.types.length; i++) {
|
|
11296
11339
|
this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
|
|
@@ -28030,7 +28073,8 @@ var Outliner = class {
|
|
|
28030
28073
|
this.pen = penPolygon(opts.width);
|
|
28031
28074
|
this.n = this.pen.length;
|
|
28032
28075
|
this.rr = opts.cap === "round" && opts.join === "round";
|
|
28033
|
-
this.
|
|
28076
|
+
this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
|
|
28077
|
+
this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
|
|
28034
28078
|
this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
|
|
28035
28079
|
}
|
|
28036
28080
|
/**
|
|
@@ -28043,7 +28087,8 @@ var Outliner = class {
|
|
|
28043
28087
|
const dy = dir ? dir[1] : b[1] - a[1];
|
|
28044
28088
|
const d = drawDir ?? [dx, dy];
|
|
28045
28089
|
const [L, R] = drawVertices(this.pen, d[0], d[1]);
|
|
28046
|
-
|
|
28090
|
+
const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
|
|
28091
|
+
return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
|
|
28047
28092
|
}
|
|
28048
28093
|
push(p, v) {
|
|
28049
28094
|
this.pts.push([p[0] + v[0], p[1] + v[1]]);
|
|
@@ -28162,12 +28207,17 @@ var Outliner = class {
|
|
|
28162
28207
|
* segment).
|
|
28163
28208
|
*/
|
|
28164
28209
|
join(p, a, b, side, outer) {
|
|
28165
|
-
const {
|
|
28166
|
-
const
|
|
28167
|
-
|
|
28210
|
+
const { cap, width, miterLimit } = this.opts;
|
|
28211
|
+
const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
|
|
28212
|
+
let sa = this.joinSide(a, side);
|
|
28213
|
+
let sb = this.joinSide(b, side);
|
|
28214
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
|
|
28215
|
+
sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
|
|
28216
|
+
sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
|
|
28217
|
+
}
|
|
28168
28218
|
const Da = side === "R" ? a.R : a.L;
|
|
28169
28219
|
const Db = side === "R" ? b.R : b.L;
|
|
28170
|
-
if (this.roundJoinSides && Da === Db) {
|
|
28220
|
+
if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
|
|
28171
28221
|
this.push(p, sa);
|
|
28172
28222
|
return;
|
|
28173
28223
|
}
|
|
@@ -28191,7 +28241,12 @@ var Outliner = class {
|
|
|
28191
28241
|
}
|
|
28192
28242
|
} else {
|
|
28193
28243
|
this.pts.push([p[0], p[1]]);
|
|
28194
|
-
if (
|
|
28244
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
|
|
28245
|
+
this.push(p, sb);
|
|
28246
|
+
this.push(p, sa);
|
|
28247
|
+
this.pts.push([p[0], p[1]]);
|
|
28248
|
+
}
|
|
28249
|
+
if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
|
|
28195
28250
|
this.push(p, sb);
|
|
28196
28251
|
this.wedge(p, sb, sa, false, false);
|
|
28197
28252
|
this.push(p, sa);
|
|
@@ -28361,9 +28416,9 @@ function dashPieces(P, tangents, pattern, shorten) {
|
|
|
28361
28416
|
}
|
|
28362
28417
|
function widenPath(path, opts) {
|
|
28363
28418
|
const out = [];
|
|
28364
|
-
const outliner = new Outliner(opts, out);
|
|
28365
28419
|
const dashed = !!opts.dashes && opts.dashes.length > 0;
|
|
28366
28420
|
for (const fig of path.figures) {
|
|
28421
|
+
const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
|
|
28367
28422
|
let P = [];
|
|
28368
28423
|
const dirs = [];
|
|
28369
28424
|
for (let i = 0; i + 1 < fig.pts.length; i += 2) {
|
|
@@ -28475,6 +28530,7 @@ function ellipseRasterPath(box, clockwise = false) {
|
|
|
28475
28530
|
const path = new GdiRasterPath();
|
|
28476
28531
|
path.addBeziers(ellipseBeziersBox(box, clockwise), true);
|
|
28477
28532
|
path.closeFigure();
|
|
28533
|
+
path.figures[0].roundWiden = true;
|
|
28478
28534
|
return path;
|
|
28479
28535
|
}
|
|
28480
28536
|
function frameMapper(box, l, t, w, h) {
|
|
@@ -28594,7 +28650,7 @@ function penWidenOptions(rCtx, opts = {}) {
|
|
|
28594
28650
|
const { state } = rCtx;
|
|
28595
28651
|
const flags = state.penFlags ?? state.penStyle;
|
|
28596
28652
|
const matrix = gdiDeviceMatrix(rCtx);
|
|
28597
|
-
const widthPx =
|
|
28653
|
+
const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
|
|
28598
28654
|
const capBits = flags & 3840;
|
|
28599
28655
|
const joinBits = flags & 61440;
|
|
28600
28656
|
const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
|
|
@@ -33464,6 +33520,7 @@ function flattenBracketPath(rCtx) {
|
|
|
33464
33520
|
}
|
|
33465
33521
|
for (const f of rCtx.rasterPath.figures) {
|
|
33466
33522
|
delete f.tangents;
|
|
33523
|
+
delete f.roundWiden;
|
|
33467
33524
|
}
|
|
33468
33525
|
syncPathCmds(rCtx);
|
|
33469
33526
|
}
|
|
@@ -37491,19 +37548,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
|
|
|
37491
37548
|
if (w > 1) {
|
|
37492
37549
|
const matrix = gdiDeviceMatrix(p.rCtx);
|
|
37493
37550
|
const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
|
|
37494
|
-
|
|
37495
|
-
|
|
37496
|
-
|
|
37497
|
-
|
|
37498
|
-
|
|
37499
|
-
|
|
37500
|
-
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37501
|
-
return box;
|
|
37502
|
-
}
|
|
37503
|
-
box.x0 += Math.round(Math.floor(w / 2) * ux);
|
|
37504
|
-
box.y0 += Math.round(Math.floor(w / 2) * uy);
|
|
37505
|
-
box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
|
|
37506
|
-
box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
|
|
37551
|
+
box.x1 += Math.round(ux);
|
|
37552
|
+
box.y1 += Math.round(uy);
|
|
37553
|
+
box.x0 += Math.round(rawWidth * ux / 2);
|
|
37554
|
+
box.y0 += Math.round(rawWidth * uy / 2);
|
|
37555
|
+
box.x1 -= Math.round(rawWidth * ux / 2);
|
|
37556
|
+
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37507
37557
|
}
|
|
37508
37558
|
}
|
|
37509
37559
|
return box;
|
|
@@ -37567,6 +37617,11 @@ function compatCorner(p, w, h, box) {
|
|
|
37567
37617
|
const ch = Math.round(Math.abs(h * m[3]) * 16);
|
|
37568
37618
|
const ux = 16 * p.kx;
|
|
37569
37619
|
const uy = 16 * p.ky;
|
|
37620
|
+
if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
|
|
37621
|
+
const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
|
|
37622
|
+
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37623
|
+
return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
|
|
37624
|
+
}
|
|
37570
37625
|
if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
|
|
37571
37626
|
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37572
37627
|
return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
|
package/dist/browser.mjs
CHANGED
|
@@ -10314,6 +10314,49 @@ async function decodePng(bytes) {
|
|
|
10314
10314
|
var import_jpeg_js = __toESM(require_jpeg_js());
|
|
10315
10315
|
var import_gifuct_js = __toESM(require_lib2());
|
|
10316
10316
|
var UTIF = __toESM(require_UTIF());
|
|
10317
|
+
|
|
10318
|
+
// src/tiff-group3.ts
|
|
10319
|
+
function normalizeGroup3(buffer, page) {
|
|
10320
|
+
const options = Array.isArray(page.t292) ? Number(page.t292[0]) : 0;
|
|
10321
|
+
if (!Array.isArray(page.t259) || page.t259[0] !== 3 || (options & 3) !== 0) return buffer;
|
|
10322
|
+
const offsets = page.t273, lengths = page.t279;
|
|
10323
|
+
if (!Array.isArray(offsets) || !Array.isArray(lengths) || offsets.length !== lengths.length) return buffer;
|
|
10324
|
+
const source = new Uint8Array(buffer);
|
|
10325
|
+
const leastFirst = Array.isArray(page.t266) && page.t266[0] === 2;
|
|
10326
|
+
const strips = offsets.map((offset, i) => {
|
|
10327
|
+
const start = Number(offset), length = Number(lengths[i]);
|
|
10328
|
+
if (!Number.isInteger(start) || !Number.isInteger(length) || start < 0 || length < 0 || start + length > source.length) throw new Error("Invalid TIFF strip");
|
|
10329
|
+
const output = new Uint8Array(Math.ceil(length * 8 * 13 / 12 / 8) + 1);
|
|
10330
|
+
let position2 = 0, zeros = 0;
|
|
10331
|
+
const write = (bit) => {
|
|
10332
|
+
if (bit) output[position2 >>> 3] |= 1 << (leastFirst ? position2 & 7 : 7 - (position2 & 7));
|
|
10333
|
+
position2++;
|
|
10334
|
+
};
|
|
10335
|
+
for (let bitPosition = 0; bitPosition < length * 8; bitPosition++) {
|
|
10336
|
+
const bit = source[start + (bitPosition >>> 3)] >>> (leastFirst ? bitPosition & 7 : 7 - (bitPosition & 7)) & 1;
|
|
10337
|
+
write(bit);
|
|
10338
|
+
if (bit) {
|
|
10339
|
+
if (zeros >= 11) write(1);
|
|
10340
|
+
zeros = 0;
|
|
10341
|
+
} else zeros++;
|
|
10342
|
+
}
|
|
10343
|
+
return output.subarray(0, Math.ceil(position2 / 8));
|
|
10344
|
+
});
|
|
10345
|
+
const normalized = new Uint8Array(strips.reduce((size, strip) => size + strip.length, source.length));
|
|
10346
|
+
normalized.set(source);
|
|
10347
|
+
let position = source.length;
|
|
10348
|
+
page.t273 = strips.map((strip) => {
|
|
10349
|
+
const offset = position;
|
|
10350
|
+
normalized.set(strip, position);
|
|
10351
|
+
position += strip.length;
|
|
10352
|
+
return offset;
|
|
10353
|
+
});
|
|
10354
|
+
page.t279 = strips.map((strip) => strip.length);
|
|
10355
|
+
page.t292 = [options | 1];
|
|
10356
|
+
return normalized.buffer;
|
|
10357
|
+
}
|
|
10358
|
+
|
|
10359
|
+
// src/image-codec-fallback.ts
|
|
10317
10360
|
var validSize = (w, h) => Number.isInteger(w) && Number.isInteger(h) && w > 0 && h > 0 && w <= 8192 && h <= 8192;
|
|
10318
10361
|
function decodeImageCodecFallback(bytes) {
|
|
10319
10362
|
try {
|
|
@@ -10352,7 +10395,7 @@ function decodeImageCodecFallback(bytes) {
|
|
|
10352
10395
|
const pages = UTIF.decode(buffer);
|
|
10353
10396
|
const page = pages.find((p) => p.t256 && p.t257);
|
|
10354
10397
|
if (!page || !Array.isArray(page.t256) || !Array.isArray(page.t257) || !validSize(Number(page.t256[0]), Number(page.t257[0]))) return null;
|
|
10355
|
-
UTIF.decodeImage(buffer, page);
|
|
10398
|
+
UTIF.decodeImage(normalizeGroup3(buffer, page), page);
|
|
10356
10399
|
const width = page.width, height = page.height;
|
|
10357
10400
|
if (!validSize(width, height)) return null;
|
|
10358
10401
|
const data = UTIF.toRGBA8(page);
|
|
@@ -11288,7 +11331,7 @@ var GdiRasterPath = class {
|
|
|
11288
11331
|
/** Appends every figure of `other`. */
|
|
11289
11332
|
append(other) {
|
|
11290
11333
|
for (const f of other.figures) {
|
|
11291
|
-
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
|
|
11334
|
+
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
|
|
11292
11335
|
}
|
|
11293
11336
|
for (let i = 0; i < other.getPath.types.length; i++) {
|
|
11294
11337
|
this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
|
|
@@ -28028,7 +28071,8 @@ var Outliner = class {
|
|
|
28028
28071
|
this.pen = penPolygon(opts.width);
|
|
28029
28072
|
this.n = this.pen.length;
|
|
28030
28073
|
this.rr = opts.cap === "round" && opts.join === "round";
|
|
28031
|
-
this.
|
|
28074
|
+
this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
|
|
28075
|
+
this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
|
|
28032
28076
|
this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
|
|
28033
28077
|
}
|
|
28034
28078
|
/**
|
|
@@ -28041,7 +28085,8 @@ var Outliner = class {
|
|
|
28041
28085
|
const dy = dir ? dir[1] : b[1] - a[1];
|
|
28042
28086
|
const d = drawDir ?? [dx, dy];
|
|
28043
28087
|
const [L, R] = drawVertices(this.pen, d[0], d[1]);
|
|
28044
|
-
|
|
28088
|
+
const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
|
|
28089
|
+
return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
|
|
28045
28090
|
}
|
|
28046
28091
|
push(p, v) {
|
|
28047
28092
|
this.pts.push([p[0] + v[0], p[1] + v[1]]);
|
|
@@ -28160,12 +28205,17 @@ var Outliner = class {
|
|
|
28160
28205
|
* segment).
|
|
28161
28206
|
*/
|
|
28162
28207
|
join(p, a, b, side, outer) {
|
|
28163
|
-
const {
|
|
28164
|
-
const
|
|
28165
|
-
|
|
28208
|
+
const { cap, width, miterLimit } = this.opts;
|
|
28209
|
+
const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
|
|
28210
|
+
let sa = this.joinSide(a, side);
|
|
28211
|
+
let sb = this.joinSide(b, side);
|
|
28212
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
|
|
28213
|
+
sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
|
|
28214
|
+
sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
|
|
28215
|
+
}
|
|
28166
28216
|
const Da = side === "R" ? a.R : a.L;
|
|
28167
28217
|
const Db = side === "R" ? b.R : b.L;
|
|
28168
|
-
if (this.roundJoinSides && Da === Db) {
|
|
28218
|
+
if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
|
|
28169
28219
|
this.push(p, sa);
|
|
28170
28220
|
return;
|
|
28171
28221
|
}
|
|
@@ -28189,7 +28239,12 @@ var Outliner = class {
|
|
|
28189
28239
|
}
|
|
28190
28240
|
} else {
|
|
28191
28241
|
this.pts.push([p[0], p[1]]);
|
|
28192
|
-
if (
|
|
28242
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
|
|
28243
|
+
this.push(p, sb);
|
|
28244
|
+
this.push(p, sa);
|
|
28245
|
+
this.pts.push([p[0], p[1]]);
|
|
28246
|
+
}
|
|
28247
|
+
if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
|
|
28193
28248
|
this.push(p, sb);
|
|
28194
28249
|
this.wedge(p, sb, sa, false, false);
|
|
28195
28250
|
this.push(p, sa);
|
|
@@ -28359,9 +28414,9 @@ function dashPieces(P, tangents, pattern, shorten) {
|
|
|
28359
28414
|
}
|
|
28360
28415
|
function widenPath(path, opts) {
|
|
28361
28416
|
const out = [];
|
|
28362
|
-
const outliner = new Outliner(opts, out);
|
|
28363
28417
|
const dashed = !!opts.dashes && opts.dashes.length > 0;
|
|
28364
28418
|
for (const fig of path.figures) {
|
|
28419
|
+
const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
|
|
28365
28420
|
let P = [];
|
|
28366
28421
|
const dirs = [];
|
|
28367
28422
|
for (let i = 0; i + 1 < fig.pts.length; i += 2) {
|
|
@@ -28473,6 +28528,7 @@ function ellipseRasterPath(box, clockwise = false) {
|
|
|
28473
28528
|
const path = new GdiRasterPath();
|
|
28474
28529
|
path.addBeziers(ellipseBeziersBox(box, clockwise), true);
|
|
28475
28530
|
path.closeFigure();
|
|
28531
|
+
path.figures[0].roundWiden = true;
|
|
28476
28532
|
return path;
|
|
28477
28533
|
}
|
|
28478
28534
|
function frameMapper(box, l, t, w, h) {
|
|
@@ -28592,7 +28648,7 @@ function penWidenOptions(rCtx, opts = {}) {
|
|
|
28592
28648
|
const { state } = rCtx;
|
|
28593
28649
|
const flags = state.penFlags ?? state.penStyle;
|
|
28594
28650
|
const matrix = gdiDeviceMatrix(rCtx);
|
|
28595
|
-
const widthPx =
|
|
28651
|
+
const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
|
|
28596
28652
|
const capBits = flags & 3840;
|
|
28597
28653
|
const joinBits = flags & 61440;
|
|
28598
28654
|
const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
|
|
@@ -33462,6 +33518,7 @@ function flattenBracketPath(rCtx) {
|
|
|
33462
33518
|
}
|
|
33463
33519
|
for (const f of rCtx.rasterPath.figures) {
|
|
33464
33520
|
delete f.tangents;
|
|
33521
|
+
delete f.roundWiden;
|
|
33465
33522
|
}
|
|
33466
33523
|
syncPathCmds(rCtx);
|
|
33467
33524
|
}
|
|
@@ -37489,19 +37546,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
|
|
|
37489
37546
|
if (w > 1) {
|
|
37490
37547
|
const matrix = gdiDeviceMatrix(p.rCtx);
|
|
37491
37548
|
const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
|
|
37492
|
-
|
|
37493
|
-
|
|
37494
|
-
|
|
37495
|
-
|
|
37496
|
-
|
|
37497
|
-
|
|
37498
|
-
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37499
|
-
return box;
|
|
37500
|
-
}
|
|
37501
|
-
box.x0 += Math.round(Math.floor(w / 2) * ux);
|
|
37502
|
-
box.y0 += Math.round(Math.floor(w / 2) * uy);
|
|
37503
|
-
box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
|
|
37504
|
-
box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
|
|
37549
|
+
box.x1 += Math.round(ux);
|
|
37550
|
+
box.y1 += Math.round(uy);
|
|
37551
|
+
box.x0 += Math.round(rawWidth * ux / 2);
|
|
37552
|
+
box.y0 += Math.round(rawWidth * uy / 2);
|
|
37553
|
+
box.x1 -= Math.round(rawWidth * ux / 2);
|
|
37554
|
+
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37505
37555
|
}
|
|
37506
37556
|
}
|
|
37507
37557
|
return box;
|
|
@@ -37565,6 +37615,11 @@ function compatCorner(p, w, h, box) {
|
|
|
37565
37615
|
const ch = Math.round(Math.abs(h * m[3]) * 16);
|
|
37566
37616
|
const ux = 16 * p.kx;
|
|
37567
37617
|
const uy = 16 * p.ky;
|
|
37618
|
+
if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
|
|
37619
|
+
const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
|
|
37620
|
+
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37621
|
+
return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
|
|
37622
|
+
}
|
|
37568
37623
|
if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
|
|
37569
37624
|
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37570
37625
|
return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
|
package/dist/index.js
CHANGED
|
@@ -10316,6 +10316,49 @@ async function decodePng(bytes) {
|
|
|
10316
10316
|
var import_jpeg_js = __toESM(require_jpeg_js());
|
|
10317
10317
|
var import_gifuct_js = __toESM(require_lib2());
|
|
10318
10318
|
var UTIF = __toESM(require_UTIF());
|
|
10319
|
+
|
|
10320
|
+
// src/tiff-group3.ts
|
|
10321
|
+
function normalizeGroup3(buffer, page) {
|
|
10322
|
+
const options = Array.isArray(page.t292) ? Number(page.t292[0]) : 0;
|
|
10323
|
+
if (!Array.isArray(page.t259) || page.t259[0] !== 3 || (options & 3) !== 0) return buffer;
|
|
10324
|
+
const offsets = page.t273, lengths = page.t279;
|
|
10325
|
+
if (!Array.isArray(offsets) || !Array.isArray(lengths) || offsets.length !== lengths.length) return buffer;
|
|
10326
|
+
const source = new Uint8Array(buffer);
|
|
10327
|
+
const leastFirst = Array.isArray(page.t266) && page.t266[0] === 2;
|
|
10328
|
+
const strips = offsets.map((offset, i) => {
|
|
10329
|
+
const start = Number(offset), length = Number(lengths[i]);
|
|
10330
|
+
if (!Number.isInteger(start) || !Number.isInteger(length) || start < 0 || length < 0 || start + length > source.length) throw new Error("Invalid TIFF strip");
|
|
10331
|
+
const output = new Uint8Array(Math.ceil(length * 8 * 13 / 12 / 8) + 1);
|
|
10332
|
+
let position2 = 0, zeros = 0;
|
|
10333
|
+
const write = (bit) => {
|
|
10334
|
+
if (bit) output[position2 >>> 3] |= 1 << (leastFirst ? position2 & 7 : 7 - (position2 & 7));
|
|
10335
|
+
position2++;
|
|
10336
|
+
};
|
|
10337
|
+
for (let bitPosition = 0; bitPosition < length * 8; bitPosition++) {
|
|
10338
|
+
const bit = source[start + (bitPosition >>> 3)] >>> (leastFirst ? bitPosition & 7 : 7 - (bitPosition & 7)) & 1;
|
|
10339
|
+
write(bit);
|
|
10340
|
+
if (bit) {
|
|
10341
|
+
if (zeros >= 11) write(1);
|
|
10342
|
+
zeros = 0;
|
|
10343
|
+
} else zeros++;
|
|
10344
|
+
}
|
|
10345
|
+
return output.subarray(0, Math.ceil(position2 / 8));
|
|
10346
|
+
});
|
|
10347
|
+
const normalized = new Uint8Array(strips.reduce((size, strip) => size + strip.length, source.length));
|
|
10348
|
+
normalized.set(source);
|
|
10349
|
+
let position = source.length;
|
|
10350
|
+
page.t273 = strips.map((strip) => {
|
|
10351
|
+
const offset = position;
|
|
10352
|
+
normalized.set(strip, position);
|
|
10353
|
+
position += strip.length;
|
|
10354
|
+
return offset;
|
|
10355
|
+
});
|
|
10356
|
+
page.t279 = strips.map((strip) => strip.length);
|
|
10357
|
+
page.t292 = [options | 1];
|
|
10358
|
+
return normalized.buffer;
|
|
10359
|
+
}
|
|
10360
|
+
|
|
10361
|
+
// src/image-codec-fallback.ts
|
|
10319
10362
|
var validSize = (w, h) => Number.isInteger(w) && Number.isInteger(h) && w > 0 && h > 0 && w <= 8192 && h <= 8192;
|
|
10320
10363
|
function decodeImageCodecFallback(bytes) {
|
|
10321
10364
|
try {
|
|
@@ -10354,7 +10397,7 @@ function decodeImageCodecFallback(bytes) {
|
|
|
10354
10397
|
const pages = UTIF.decode(buffer);
|
|
10355
10398
|
const page = pages.find((p) => p.t256 && p.t257);
|
|
10356
10399
|
if (!page || !Array.isArray(page.t256) || !Array.isArray(page.t257) || !validSize(Number(page.t256[0]), Number(page.t257[0]))) return null;
|
|
10357
|
-
UTIF.decodeImage(buffer, page);
|
|
10400
|
+
UTIF.decodeImage(normalizeGroup3(buffer, page), page);
|
|
10358
10401
|
const width = page.width, height = page.height;
|
|
10359
10402
|
if (!validSize(width, height)) return null;
|
|
10360
10403
|
const data = UTIF.toRGBA8(page);
|
|
@@ -11291,7 +11334,7 @@ var GdiRasterPath = class {
|
|
|
11291
11334
|
/** Appends every figure of `other`. */
|
|
11292
11335
|
append(other) {
|
|
11293
11336
|
for (const f of other.figures) {
|
|
11294
|
-
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
|
|
11337
|
+
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
|
|
11295
11338
|
}
|
|
11296
11339
|
for (let i = 0; i < other.getPath.types.length; i++) {
|
|
11297
11340
|
this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
|
|
@@ -28031,7 +28074,8 @@ var Outliner = class {
|
|
|
28031
28074
|
this.pen = penPolygon(opts.width);
|
|
28032
28075
|
this.n = this.pen.length;
|
|
28033
28076
|
this.rr = opts.cap === "round" && opts.join === "round";
|
|
28034
|
-
this.
|
|
28077
|
+
this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
|
|
28078
|
+
this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
|
|
28035
28079
|
this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
|
|
28036
28080
|
}
|
|
28037
28081
|
/**
|
|
@@ -28044,7 +28088,8 @@ var Outliner = class {
|
|
|
28044
28088
|
const dy = dir ? dir[1] : b[1] - a[1];
|
|
28045
28089
|
const d = drawDir ?? [dx, dy];
|
|
28046
28090
|
const [L, R] = drawVertices(this.pen, d[0], d[1]);
|
|
28047
|
-
|
|
28091
|
+
const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
|
|
28092
|
+
return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
|
|
28048
28093
|
}
|
|
28049
28094
|
push(p, v) {
|
|
28050
28095
|
this.pts.push([p[0] + v[0], p[1] + v[1]]);
|
|
@@ -28163,12 +28208,17 @@ var Outliner = class {
|
|
|
28163
28208
|
* segment).
|
|
28164
28209
|
*/
|
|
28165
28210
|
join(p, a, b, side, outer) {
|
|
28166
|
-
const {
|
|
28167
|
-
const
|
|
28168
|
-
|
|
28211
|
+
const { cap, width, miterLimit } = this.opts;
|
|
28212
|
+
const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
|
|
28213
|
+
let sa = this.joinSide(a, side);
|
|
28214
|
+
let sb = this.joinSide(b, side);
|
|
28215
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
|
|
28216
|
+
sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
|
|
28217
|
+
sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
|
|
28218
|
+
}
|
|
28169
28219
|
const Da = side === "R" ? a.R : a.L;
|
|
28170
28220
|
const Db = side === "R" ? b.R : b.L;
|
|
28171
|
-
if (this.roundJoinSides && Da === Db) {
|
|
28221
|
+
if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
|
|
28172
28222
|
this.push(p, sa);
|
|
28173
28223
|
return;
|
|
28174
28224
|
}
|
|
@@ -28192,7 +28242,12 @@ var Outliner = class {
|
|
|
28192
28242
|
}
|
|
28193
28243
|
} else {
|
|
28194
28244
|
this.pts.push([p[0], p[1]]);
|
|
28195
|
-
if (
|
|
28245
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
|
|
28246
|
+
this.push(p, sb);
|
|
28247
|
+
this.push(p, sa);
|
|
28248
|
+
this.pts.push([p[0], p[1]]);
|
|
28249
|
+
}
|
|
28250
|
+
if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
|
|
28196
28251
|
this.push(p, sb);
|
|
28197
28252
|
this.wedge(p, sb, sa, false, false);
|
|
28198
28253
|
this.push(p, sa);
|
|
@@ -28362,9 +28417,9 @@ function dashPieces(P, tangents, pattern, shorten) {
|
|
|
28362
28417
|
}
|
|
28363
28418
|
function widenPath(path, opts) {
|
|
28364
28419
|
const out = [];
|
|
28365
|
-
const outliner = new Outliner(opts, out);
|
|
28366
28420
|
const dashed = !!opts.dashes && opts.dashes.length > 0;
|
|
28367
28421
|
for (const fig of path.figures) {
|
|
28422
|
+
const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
|
|
28368
28423
|
let P = [];
|
|
28369
28424
|
const dirs = [];
|
|
28370
28425
|
for (let i = 0; i + 1 < fig.pts.length; i += 2) {
|
|
@@ -28476,6 +28531,7 @@ function ellipseRasterPath(box, clockwise = false) {
|
|
|
28476
28531
|
const path = new GdiRasterPath();
|
|
28477
28532
|
path.addBeziers(ellipseBeziersBox(box, clockwise), true);
|
|
28478
28533
|
path.closeFigure();
|
|
28534
|
+
path.figures[0].roundWiden = true;
|
|
28479
28535
|
return path;
|
|
28480
28536
|
}
|
|
28481
28537
|
function frameMapper(box, l, t, w, h) {
|
|
@@ -28595,7 +28651,7 @@ function penWidenOptions(rCtx, opts = {}) {
|
|
|
28595
28651
|
const { state } = rCtx;
|
|
28596
28652
|
const flags = state.penFlags ?? state.penStyle;
|
|
28597
28653
|
const matrix = gdiDeviceMatrix(rCtx);
|
|
28598
|
-
const widthPx =
|
|
28654
|
+
const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
|
|
28599
28655
|
const capBits = flags & 3840;
|
|
28600
28656
|
const joinBits = flags & 61440;
|
|
28601
28657
|
const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
|
|
@@ -33465,6 +33521,7 @@ function flattenBracketPath(rCtx) {
|
|
|
33465
33521
|
}
|
|
33466
33522
|
for (const f of rCtx.rasterPath.figures) {
|
|
33467
33523
|
delete f.tangents;
|
|
33524
|
+
delete f.roundWiden;
|
|
33468
33525
|
}
|
|
33469
33526
|
syncPathCmds(rCtx);
|
|
33470
33527
|
}
|
|
@@ -37492,19 +37549,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
|
|
|
37492
37549
|
if (w > 1) {
|
|
37493
37550
|
const matrix = gdiDeviceMatrix(p.rCtx);
|
|
37494
37551
|
const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
|
|
37495
|
-
|
|
37496
|
-
|
|
37497
|
-
|
|
37498
|
-
|
|
37499
|
-
|
|
37500
|
-
|
|
37501
|
-
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37502
|
-
return box;
|
|
37503
|
-
}
|
|
37504
|
-
box.x0 += Math.round(Math.floor(w / 2) * ux);
|
|
37505
|
-
box.y0 += Math.round(Math.floor(w / 2) * uy);
|
|
37506
|
-
box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
|
|
37507
|
-
box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
|
|
37552
|
+
box.x1 += Math.round(ux);
|
|
37553
|
+
box.y1 += Math.round(uy);
|
|
37554
|
+
box.x0 += Math.round(rawWidth * ux / 2);
|
|
37555
|
+
box.y0 += Math.round(rawWidth * uy / 2);
|
|
37556
|
+
box.x1 -= Math.round(rawWidth * ux / 2);
|
|
37557
|
+
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37508
37558
|
}
|
|
37509
37559
|
}
|
|
37510
37560
|
return box;
|
|
@@ -37568,6 +37618,11 @@ function compatCorner(p, w, h, box) {
|
|
|
37568
37618
|
const ch = Math.round(Math.abs(h * m[3]) * 16);
|
|
37569
37619
|
const ux = 16 * p.kx;
|
|
37570
37620
|
const uy = 16 * p.ky;
|
|
37621
|
+
if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
|
|
37622
|
+
const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
|
|
37623
|
+
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37624
|
+
return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
|
|
37625
|
+
}
|
|
37571
37626
|
if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
|
|
37572
37627
|
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37573
37628
|
return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
|
package/dist/index.mjs
CHANGED
|
@@ -10314,6 +10314,49 @@ async function decodePng(bytes) {
|
|
|
10314
10314
|
var import_jpeg_js = __toESM(require_jpeg_js());
|
|
10315
10315
|
var import_gifuct_js = __toESM(require_lib2());
|
|
10316
10316
|
var UTIF = __toESM(require_UTIF());
|
|
10317
|
+
|
|
10318
|
+
// src/tiff-group3.ts
|
|
10319
|
+
function normalizeGroup3(buffer, page) {
|
|
10320
|
+
const options = Array.isArray(page.t292) ? Number(page.t292[0]) : 0;
|
|
10321
|
+
if (!Array.isArray(page.t259) || page.t259[0] !== 3 || (options & 3) !== 0) return buffer;
|
|
10322
|
+
const offsets = page.t273, lengths = page.t279;
|
|
10323
|
+
if (!Array.isArray(offsets) || !Array.isArray(lengths) || offsets.length !== lengths.length) return buffer;
|
|
10324
|
+
const source = new Uint8Array(buffer);
|
|
10325
|
+
const leastFirst = Array.isArray(page.t266) && page.t266[0] === 2;
|
|
10326
|
+
const strips = offsets.map((offset, i) => {
|
|
10327
|
+
const start = Number(offset), length = Number(lengths[i]);
|
|
10328
|
+
if (!Number.isInteger(start) || !Number.isInteger(length) || start < 0 || length < 0 || start + length > source.length) throw new Error("Invalid TIFF strip");
|
|
10329
|
+
const output = new Uint8Array(Math.ceil(length * 8 * 13 / 12 / 8) + 1);
|
|
10330
|
+
let position2 = 0, zeros = 0;
|
|
10331
|
+
const write = (bit) => {
|
|
10332
|
+
if (bit) output[position2 >>> 3] |= 1 << (leastFirst ? position2 & 7 : 7 - (position2 & 7));
|
|
10333
|
+
position2++;
|
|
10334
|
+
};
|
|
10335
|
+
for (let bitPosition = 0; bitPosition < length * 8; bitPosition++) {
|
|
10336
|
+
const bit = source[start + (bitPosition >>> 3)] >>> (leastFirst ? bitPosition & 7 : 7 - (bitPosition & 7)) & 1;
|
|
10337
|
+
write(bit);
|
|
10338
|
+
if (bit) {
|
|
10339
|
+
if (zeros >= 11) write(1);
|
|
10340
|
+
zeros = 0;
|
|
10341
|
+
} else zeros++;
|
|
10342
|
+
}
|
|
10343
|
+
return output.subarray(0, Math.ceil(position2 / 8));
|
|
10344
|
+
});
|
|
10345
|
+
const normalized = new Uint8Array(strips.reduce((size, strip) => size + strip.length, source.length));
|
|
10346
|
+
normalized.set(source);
|
|
10347
|
+
let position = source.length;
|
|
10348
|
+
page.t273 = strips.map((strip) => {
|
|
10349
|
+
const offset = position;
|
|
10350
|
+
normalized.set(strip, position);
|
|
10351
|
+
position += strip.length;
|
|
10352
|
+
return offset;
|
|
10353
|
+
});
|
|
10354
|
+
page.t279 = strips.map((strip) => strip.length);
|
|
10355
|
+
page.t292 = [options | 1];
|
|
10356
|
+
return normalized.buffer;
|
|
10357
|
+
}
|
|
10358
|
+
|
|
10359
|
+
// src/image-codec-fallback.ts
|
|
10317
10360
|
var validSize = (w, h) => Number.isInteger(w) && Number.isInteger(h) && w > 0 && h > 0 && w <= 8192 && h <= 8192;
|
|
10318
10361
|
function decodeImageCodecFallback(bytes) {
|
|
10319
10362
|
try {
|
|
@@ -10352,7 +10395,7 @@ function decodeImageCodecFallback(bytes) {
|
|
|
10352
10395
|
const pages = UTIF.decode(buffer);
|
|
10353
10396
|
const page = pages.find((p) => p.t256 && p.t257);
|
|
10354
10397
|
if (!page || !Array.isArray(page.t256) || !Array.isArray(page.t257) || !validSize(Number(page.t256[0]), Number(page.t257[0]))) return null;
|
|
10355
|
-
UTIF.decodeImage(buffer, page);
|
|
10398
|
+
UTIF.decodeImage(normalizeGroup3(buffer, page), page);
|
|
10356
10399
|
const width = page.width, height = page.height;
|
|
10357
10400
|
if (!validSize(width, height)) return null;
|
|
10358
10401
|
const data = UTIF.toRGBA8(page);
|
|
@@ -11289,7 +11332,7 @@ var GdiRasterPath = class {
|
|
|
11289
11332
|
/** Appends every figure of `other`. */
|
|
11290
11333
|
append(other) {
|
|
11291
11334
|
for (const f of other.figures) {
|
|
11292
|
-
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents) });
|
|
11335
|
+
this.figures.push({ pts: f.pts.slice(), closed: f.closed, tangents: f.tangents && new Map(f.tangents), roundWiden: f.roundWiden });
|
|
11293
11336
|
}
|
|
11294
11337
|
for (let i = 0; i < other.getPath.types.length; i++) {
|
|
11295
11338
|
this.log(other.getPath.pts[2 * i], other.getPath.pts[2 * i + 1], other.getPath.types[i]);
|
|
@@ -28029,7 +28072,8 @@ var Outliner = class {
|
|
|
28029
28072
|
this.pen = penPolygon(opts.width);
|
|
28030
28073
|
this.n = this.pen.length;
|
|
28031
28074
|
this.rr = opts.cap === "round" && opts.join === "round";
|
|
28032
|
-
this.
|
|
28075
|
+
this.originalRoundJoinSides = opts.join === "round" && opts.cap !== "flat";
|
|
28076
|
+
this.roundJoinSides = !!opts.roundCurveJoins || this.originalRoundJoinSides;
|
|
28033
28077
|
this.maxX = Math.max(...this.pen.map((q) => Math.abs(q[0])));
|
|
28034
28078
|
}
|
|
28035
28079
|
/**
|
|
@@ -28042,7 +28086,8 @@ var Outliner = class {
|
|
|
28042
28086
|
const dy = dir ? dir[1] : b[1] - a[1];
|
|
28043
28087
|
const d = drawDir ?? [dx, dy];
|
|
28044
28088
|
const [L, R] = drawVertices(this.pen, d[0], d[1]);
|
|
28045
|
-
|
|
28089
|
+
const perpendicular = this.opts.roundCurveJoins && drawDir ? drawDir : [dx, dy];
|
|
28090
|
+
return { dx, dy, L, R, v: flatVector(this.opts.width, perpendicular[0], perpendicular[1]), e: squareExtension(this.opts.width, dx, dy), curveEnd: !!drawDir };
|
|
28046
28091
|
}
|
|
28047
28092
|
push(p, v) {
|
|
28048
28093
|
this.pts.push([p[0] + v[0], p[1] + v[1]]);
|
|
@@ -28161,12 +28206,17 @@ var Outliner = class {
|
|
|
28161
28206
|
* segment).
|
|
28162
28207
|
*/
|
|
28163
28208
|
join(p, a, b, side, outer) {
|
|
28164
|
-
const {
|
|
28165
|
-
const
|
|
28166
|
-
|
|
28209
|
+
const { cap, width, miterLimit } = this.opts;
|
|
28210
|
+
const join = this.opts.roundCurveJoins ? "round" : this.opts.join;
|
|
28211
|
+
let sa = this.joinSide(a, side);
|
|
28212
|
+
let sb = this.joinSide(b, side);
|
|
28213
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides && a.curveEnd && b.curveEnd) {
|
|
28214
|
+
sa = side === "R" ? a.v : [-a.v[0], -a.v[1]];
|
|
28215
|
+
sb = side === "R" ? b.v : [-b.v[0], -b.v[1]];
|
|
28216
|
+
}
|
|
28167
28217
|
const Da = side === "R" ? a.R : a.L;
|
|
28168
28218
|
const Db = side === "R" ? b.R : b.L;
|
|
28169
|
-
if (this.roundJoinSides && Da === Db) {
|
|
28219
|
+
if (this.roundJoinSides && (Da === Db || this.opts.roundCurveJoins && sa[0] === sb[0] && sa[1] === sb[1])) {
|
|
28170
28220
|
this.push(p, sa);
|
|
28171
28221
|
return;
|
|
28172
28222
|
}
|
|
@@ -28190,7 +28240,12 @@ var Outliner = class {
|
|
|
28190
28240
|
}
|
|
28191
28241
|
} else {
|
|
28192
28242
|
this.pts.push([p[0], p[1]]);
|
|
28193
|
-
if (
|
|
28243
|
+
if (this.opts.roundCurveJoins && !this.originalRoundJoinSides) {
|
|
28244
|
+
this.push(p, sb);
|
|
28245
|
+
this.push(p, sa);
|
|
28246
|
+
this.pts.push([p[0], p[1]]);
|
|
28247
|
+
}
|
|
28248
|
+
if (join === "round" && cap === "flat" && !this.opts.roundCurveJoins) {
|
|
28194
28249
|
this.push(p, sb);
|
|
28195
28250
|
this.wedge(p, sb, sa, false, false);
|
|
28196
28251
|
this.push(p, sa);
|
|
@@ -28360,9 +28415,9 @@ function dashPieces(P, tangents, pattern, shorten) {
|
|
|
28360
28415
|
}
|
|
28361
28416
|
function widenPath(path, opts) {
|
|
28362
28417
|
const out = [];
|
|
28363
|
-
const outliner = new Outliner(opts, out);
|
|
28364
28418
|
const dashed = !!opts.dashes && opts.dashes.length > 0;
|
|
28365
28419
|
for (const fig of path.figures) {
|
|
28420
|
+
const outliner = new Outliner(fig.roundWiden ? { ...opts, roundCurveJoins: true } : opts, out);
|
|
28366
28421
|
let P = [];
|
|
28367
28422
|
const dirs = [];
|
|
28368
28423
|
for (let i = 0; i + 1 < fig.pts.length; i += 2) {
|
|
@@ -28474,6 +28529,7 @@ function ellipseRasterPath(box, clockwise = false) {
|
|
|
28474
28529
|
const path = new GdiRasterPath();
|
|
28475
28530
|
path.addBeziers(ellipseBeziersBox(box, clockwise), true);
|
|
28476
28531
|
path.closeFigure();
|
|
28532
|
+
path.figures[0].roundWiden = true;
|
|
28477
28533
|
return path;
|
|
28478
28534
|
}
|
|
28479
28535
|
function frameMapper(box, l, t, w, h) {
|
|
@@ -28593,7 +28649,7 @@ function penWidenOptions(rCtx, opts = {}) {
|
|
|
28593
28649
|
const { state } = rCtx;
|
|
28594
28650
|
const flags = state.penFlags ?? state.penStyle;
|
|
28595
28651
|
const matrix = gdiDeviceMatrix(rCtx);
|
|
28596
|
-
const widthPx =
|
|
28652
|
+
const widthPx = rCtx.wholeDevicePixels && (flags & 15) === 6 ? state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) : penDeviceWidth(rCtx);
|
|
28597
28653
|
const capBits = flags & 3840;
|
|
28598
28654
|
const joinBits = flags & 61440;
|
|
28599
28655
|
const dashes = state.penExtended ? geometricStyle(flags, widthPx, state.penUserStyle, widthPx / (state.penWidth || 1)) : null;
|
|
@@ -33463,6 +33519,7 @@ function flattenBracketPath(rCtx) {
|
|
|
33463
33519
|
}
|
|
33464
33520
|
for (const f of rCtx.rasterPath.figures) {
|
|
33465
33521
|
delete f.tangents;
|
|
33522
|
+
delete f.roundWiden;
|
|
33466
33523
|
}
|
|
33467
33524
|
syncPathCmds(rCtx);
|
|
33468
33525
|
}
|
|
@@ -37490,19 +37547,12 @@ function compatBox(p, l, t, r, b, opts = {}) {
|
|
|
37490
37547
|
if (w > 1) {
|
|
37491
37548
|
const matrix = gdiDeviceMatrix(p.rCtx);
|
|
37492
37549
|
const rawWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(matrix[0] * matrix[3] - matrix[1] * matrix[2])) / p.kx;
|
|
37493
|
-
|
|
37494
|
-
|
|
37495
|
-
|
|
37496
|
-
|
|
37497
|
-
|
|
37498
|
-
|
|
37499
|
-
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37500
|
-
return box;
|
|
37501
|
-
}
|
|
37502
|
-
box.x0 += Math.round(Math.floor(w / 2) * ux);
|
|
37503
|
-
box.y0 += Math.round(Math.floor(w / 2) * uy);
|
|
37504
|
-
box.x1 -= Math.round(Math.floor((w - 1) / 2) * ux);
|
|
37505
|
-
box.y1 -= Math.round(Math.floor((w - 1) / 2) * uy);
|
|
37550
|
+
box.x1 += Math.round(ux);
|
|
37551
|
+
box.y1 += Math.round(uy);
|
|
37552
|
+
box.x0 += Math.round(rawWidth * ux / 2);
|
|
37553
|
+
box.y0 += Math.round(rawWidth * uy / 2);
|
|
37554
|
+
box.x1 -= Math.round(rawWidth * ux / 2);
|
|
37555
|
+
box.y1 -= Math.round(rawWidth * uy / 2);
|
|
37506
37556
|
}
|
|
37507
37557
|
}
|
|
37508
37558
|
return box;
|
|
@@ -37566,6 +37616,11 @@ function compatCorner(p, w, h, box) {
|
|
|
37566
37616
|
const ch = Math.round(Math.abs(h * m[3]) * 16);
|
|
37567
37617
|
const ux = 16 * p.kx;
|
|
37568
37618
|
const uy = 16 * p.ky;
|
|
37619
|
+
if ((p.rCtx.state.penStyle & 15) === PS_INSIDEFRAME && !penIsCosmetic(p.rCtx)) {
|
|
37620
|
+
const penWidth = p.rCtx.state.penWidth * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) * 16;
|
|
37621
|
+
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37622
|
+
return [Math.min(cw, width + penWidth) * width / (width + penWidth), Math.min(ch, height + penWidth) * height / (height + penWidth)];
|
|
37623
|
+
}
|
|
37569
37624
|
if (!penIsNull(p) && penIsCosmetic(p.rCtx)) {
|
|
37570
37625
|
const width = box.x1 - box.x0, height = box.y1 - box.y0;
|
|
37571
37626
|
return [Math.min(cw, width + ux) * width / (width + ux), Math.min(ch, height + uy) * height / (height + uy)];
|