emf-converter 4.25.3 → 4.25.5
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/README.md +1 -1
- package/dist/browser.js +94 -20
- package/dist/browser.mjs +94 -20
- package/dist/index.js +94 -20
- package/dist/index.mjs +94 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -339,7 +339,7 @@ page. The defaults are `1252` and `437`; explicit text charsets are unchanged.
|
|
|
339
339
|
| `ansiCodePage` | `number` | `1252` | Playback-device ANSI code page (`GetACP()`) for ANSI/DEFAULT text |
|
|
340
340
|
| `oemCodePage` | `number` | `437` | Playback-device OEM code page (`GetOEMCP()`) for OEM text |
|
|
341
341
|
| `maxHeight` | `number` | None | Maximum output height in pixels |
|
|
342
|
-
| `dpiScale` | `number` | `1` | Resolution multiplier; clamped to `4` |
|
|
342
|
+
| `dpiScale` | `number` | `1` | Resolution multiplier; clamped to `4`. `1` is the header bounds' pixel size, so raise it for sharp scaled-up previews |
|
|
343
343
|
| `maxCanvasDimension` | `number` | `8192` | Hard cap on output width/height in pixels |
|
|
344
344
|
| `maxRecords` | `number` | `200000`/`500000` | Records processed per stream before replay stops (EMF+ uses the higher default unless overridden) |
|
|
345
345
|
| `gdiAntialias` | `boolean` | `false` (PNG) | `true` smooths every shape edge with Canvas antialiasing instead of reproducing Windows' own GDI/GDI+ rasterisation |
|
package/dist/browser.js
CHANGED
|
@@ -26077,6 +26077,9 @@ function parseEmfPlusPenObject(view, dataOff, recDataSize, textureCache, cacheKe
|
|
|
26077
26077
|
return v;
|
|
26078
26078
|
};
|
|
26079
26079
|
const pen = { kind: "plus-pen", color: "rgba(0,0,0,1)", width: penWidth, dashStyle: 0 };
|
|
26080
|
+
if (hasVersion) {
|
|
26081
|
+
pen.unit = view.getUint32(dataOff + 12, true);
|
|
26082
|
+
}
|
|
26080
26083
|
if (penFlags & PEN_TRANSFORM) {
|
|
26081
26084
|
if (o + 24 <= end) {
|
|
26082
26085
|
pen.transform = [0, 4, 8, 12, 16, 20].map((k) => view.getFloat32(o + k, true));
|
|
@@ -30676,24 +30679,30 @@ function brushPaint(rCtx, obj) {
|
|
|
30676
30679
|
}
|
|
30677
30680
|
return obj.color;
|
|
30678
30681
|
}
|
|
30679
|
-
|
|
30680
|
-
|
|
30682
|
+
var UNIT_WORLD = 0;
|
|
30683
|
+
var UNIT_DISPLAY = 1;
|
|
30684
|
+
var UNIT_MILLIMETER = 6;
|
|
30685
|
+
var DEFAULT_PLUS_DPI = 96;
|
|
30686
|
+
function getPageUnitMultiplier(pageUnit, pageScale, dpi = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30681
30687
|
let unitToPixel;
|
|
30682
30688
|
switch (pageUnit) {
|
|
30689
|
+
case UNIT_DISPLAY:
|
|
30690
|
+
unitToPixel = videoDisplay ? 1 : dpi / 100;
|
|
30691
|
+
break;
|
|
30683
30692
|
case 3:
|
|
30684
|
-
unitToPixel =
|
|
30693
|
+
unitToPixel = dpi / 72;
|
|
30685
30694
|
break;
|
|
30686
30695
|
// Point
|
|
30687
30696
|
case 4:
|
|
30688
|
-
unitToPixel =
|
|
30697
|
+
unitToPixel = dpi;
|
|
30689
30698
|
break;
|
|
30690
30699
|
// Inch
|
|
30691
30700
|
case 5:
|
|
30692
|
-
unitToPixel =
|
|
30701
|
+
unitToPixel = dpi / 300;
|
|
30693
30702
|
break;
|
|
30694
30703
|
// Document
|
|
30695
30704
|
case 6:
|
|
30696
|
-
unitToPixel =
|
|
30705
|
+
unitToPixel = dpi / 25.4;
|
|
30697
30706
|
break;
|
|
30698
30707
|
// Millimeter
|
|
30699
30708
|
default:
|
|
@@ -30702,6 +30711,13 @@ function getPageUnitMultiplier(pageUnit, pageScale) {
|
|
|
30702
30711
|
}
|
|
30703
30712
|
return unitToPixel * pageScale;
|
|
30704
30713
|
}
|
|
30714
|
+
function pageMultipliers(rCtx) {
|
|
30715
|
+
const video = rCtx.videoDisplay ?? true;
|
|
30716
|
+
return [
|
|
30717
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiX ?? DEFAULT_PLUS_DPI, video),
|
|
30718
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiY ?? DEFAULT_PLUS_DPI, video)
|
|
30719
|
+
];
|
|
30720
|
+
}
|
|
30705
30721
|
function plusWorldMatrix(rCtx) {
|
|
30706
30722
|
const pre = plusPageToDeviceMatrix(rCtx);
|
|
30707
30723
|
const s = rCtx.dpiScale;
|
|
@@ -30731,8 +30747,8 @@ function plusPageToDeviceMatrix(rCtx) {
|
|
|
30731
30747
|
return ext.tsDevice;
|
|
30732
30748
|
}
|
|
30733
30749
|
const wt = rCtx.worldTransform;
|
|
30734
|
-
const
|
|
30735
|
-
const m = [wt[0] *
|
|
30750
|
+
const [kx, ky] = pageMultipliers(rCtx);
|
|
30751
|
+
const m = [wt[0] * kx, wt[1] * ky, wt[2] * kx, wt[3] * ky, wt[4] * kx, wt[5] * ky];
|
|
30736
30752
|
return ext?.containerTransform ? multiplyMatrix2(m, ext.containerTransform) : m;
|
|
30737
30753
|
}
|
|
30738
30754
|
function deviceToCanvasMatrix(rCtx) {
|
|
@@ -30815,7 +30831,7 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30815
30831
|
ext.textContrast = void 0;
|
|
30816
30832
|
rCtx.clipRegion = null;
|
|
30817
30833
|
rCtx.worldTransform = [1, 0, 0, 1, 0, 0];
|
|
30818
|
-
rCtx.pageUnit =
|
|
30834
|
+
rCtx.pageUnit = UNIT_DISPLAY;
|
|
30819
30835
|
rCtx.pageScale = 1;
|
|
30820
30836
|
rCtx.antiAlias = false;
|
|
30821
30837
|
rCtx.interpolationMode = void 0;
|
|
@@ -30823,16 +30839,17 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30823
30839
|
rCtx.textRenderingHint = void 0;
|
|
30824
30840
|
reapplyPlusClip(rCtx);
|
|
30825
30841
|
}
|
|
30826
|
-
function containerRectTransform(dst, src, unit) {
|
|
30827
|
-
const
|
|
30828
|
-
const
|
|
30829
|
-
const
|
|
30842
|
+
function containerRectTransform(dst, src, unit, dpiX = DEFAULT_PLUS_DPI, dpiY = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30843
|
+
const ux = unit === UNIT_WORLD ? dpiX / 100 : getPageUnitMultiplier(unit, 1, dpiX, videoDisplay);
|
|
30844
|
+
const uy = unit === UNIT_WORLD ? dpiY / 100 : getPageUnitMultiplier(unit, 1, dpiY, videoDisplay);
|
|
30845
|
+
const sw = src.w * ux;
|
|
30846
|
+
const sh = src.h * uy;
|
|
30830
30847
|
if (!(Math.abs(sw) > 0 && Math.abs(sh) > 0) || ![dst.x, dst.y, dst.w, dst.h, sw, sh].every(Number.isFinite)) {
|
|
30831
30848
|
return null;
|
|
30832
30849
|
}
|
|
30833
30850
|
const a = dst.w / sw;
|
|
30834
30851
|
const d = dst.h / sh;
|
|
30835
|
-
return [a, 0, 0, d, dst.x - src.x *
|
|
30852
|
+
return [a, 0, 0, d, dst.x - src.x * ux * a, dst.y - src.y * uy * d];
|
|
30836
30853
|
}
|
|
30837
30854
|
function concatClip(a, b) {
|
|
30838
30855
|
const parts = [...a ?? [], ...b ?? []];
|
|
@@ -31211,7 +31228,10 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31211
31228
|
const t = containerRectTransform(
|
|
31212
31229
|
{ x: f2(0), y: f2(4), w: f2(8), h: f2(12) },
|
|
31213
31230
|
{ x: f2(16), y: f2(20), w: f2(24), h: f2(28) },
|
|
31214
|
-
recFlags & 255
|
|
31231
|
+
recFlags & 255,
|
|
31232
|
+
rCtx.dpiX,
|
|
31233
|
+
rCtx.dpiY,
|
|
31234
|
+
rCtx.videoDisplay
|
|
31215
31235
|
);
|
|
31216
31236
|
beginContainer(rCtx, view.getUint32(dataOff + 32, true), t ?? [1, 0, 0, 1, 0, 0]);
|
|
31217
31237
|
}
|
|
@@ -31228,6 +31248,9 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31228
31248
|
dropTsDevice(rCtx);
|
|
31229
31249
|
const pageUnit = recFlags & 255;
|
|
31230
31250
|
const pageScale = recDataSize >= 4 ? view.getFloat32(dataOff, true) : 1;
|
|
31251
|
+
if (pageUnit === UNIT_WORLD || pageUnit > UNIT_MILLIMETER || !(pageScale > 0) || !Number.isFinite(pageScale)) {
|
|
31252
|
+
return true;
|
|
31253
|
+
}
|
|
31231
31254
|
rCtx.pageUnit = pageUnit;
|
|
31232
31255
|
rCtx.pageScale = pageScale;
|
|
31233
31256
|
return true;
|
|
@@ -54269,6 +54292,13 @@ function applyPlusPenStyle(ctx, pen, widthScale = 1) {
|
|
|
54269
54292
|
ctx.lineDashOffset = dashes.length > 0 ? (pen.dashOffset ?? 0) * (pen.width || 1) : 0;
|
|
54270
54293
|
}
|
|
54271
54294
|
function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false, evenOddClip = false) {
|
|
54295
|
+
if (pen) {
|
|
54296
|
+
const unitPen = penForUnit(rCtx, pen);
|
|
54297
|
+
if (!unitPen) {
|
|
54298
|
+
return;
|
|
54299
|
+
}
|
|
54300
|
+
pen = unitPen;
|
|
54301
|
+
}
|
|
54272
54302
|
const { ctx } = rCtx;
|
|
54273
54303
|
const resolved = resolvePenTransform(pen);
|
|
54274
54304
|
pen = resolved.pen;
|
|
@@ -54349,6 +54379,22 @@ function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false,
|
|
|
54349
54379
|
applyPlusWorldTransform(rCtx);
|
|
54350
54380
|
stroke(ctx);
|
|
54351
54381
|
}
|
|
54382
|
+
var PEN_UNIT_PIXEL = 2;
|
|
54383
|
+
function penForUnit(rCtx, pen) {
|
|
54384
|
+
const unit = pen.unit ?? 0;
|
|
54385
|
+
if (unit >= 3 && unit <= 6) {
|
|
54386
|
+
return null;
|
|
54387
|
+
}
|
|
54388
|
+
if (unit !== PEN_UNIT_PIXEL) {
|
|
54389
|
+
return pen;
|
|
54390
|
+
}
|
|
54391
|
+
const m = plusPageToDeviceMatrix(rCtx);
|
|
54392
|
+
const inv3 = invertAffine([m[0], m[1], m[2], m[3], 0, 0]);
|
|
54393
|
+
if (!inv3) {
|
|
54394
|
+
return pen;
|
|
54395
|
+
}
|
|
54396
|
+
return { ...pen, transform: mulMatrix(inv3, pen.transform ?? [1, 0, 0, 1, 0, 0]) };
|
|
54397
|
+
}
|
|
54352
54398
|
function resolvePenTransform(pen) {
|
|
54353
54399
|
if (!pen?.transform) {
|
|
54354
54400
|
return { pen, nib: null };
|
|
@@ -54810,6 +54856,19 @@ function rgbaToHex(c) {
|
|
|
54810
54856
|
}
|
|
54811
54857
|
return /^#[0-9a-f]{6}$/i.test(c) ? c : null;
|
|
54812
54858
|
}
|
|
54859
|
+
function worldUnitFont(rCtx, obj) {
|
|
54860
|
+
if (!obj || obj.kind !== "plus-font") {
|
|
54861
|
+
return obj;
|
|
54862
|
+
}
|
|
54863
|
+
const unit = obj.unit ?? 0;
|
|
54864
|
+
if (unit < 3 || unit > 6) {
|
|
54865
|
+
return unit === 0 ? obj : { ...obj, unit: 0 };
|
|
54866
|
+
}
|
|
54867
|
+
const dpi = rCtx.dpiY ?? DEFAULT_PLUS_DPI;
|
|
54868
|
+
const page = getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, dpi, rCtx.videoDisplay ?? true);
|
|
54869
|
+
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54870
|
+
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54871
|
+
}
|
|
54813
54872
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54814
54873
|
const fonts = rCtx.fonts;
|
|
54815
54874
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
@@ -55020,7 +55079,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55020
55079
|
const layoutW = view.getFloat32(dataOff + 20, true);
|
|
55021
55080
|
const layoutH = view.getFloat32(dataOff + 24, true);
|
|
55022
55081
|
const fontId = recFlags & 255;
|
|
55023
|
-
const font = objectTable.get(fontId);
|
|
55082
|
+
const font = worldUnitFont(rCtx, objectTable.get(fontId));
|
|
55024
55083
|
if (strLen > 0 && dataOff + 28 + strLen * 2 <= dataOff + recDataSize) {
|
|
55025
55084
|
const text = readUtf16LE(view, dataOff + 28, strLen);
|
|
55026
55085
|
if (text.length > 0 && font && font.kind === "plus-font") {
|
|
@@ -55074,7 +55133,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55074
55133
|
const options2 = view.getUint32(dataOff + 4, true);
|
|
55075
55134
|
const matrixPresent = view.getUint32(dataOff + 8, true) !== 0;
|
|
55076
55135
|
const glyphCount = view.getUint32(dataOff + 12, true);
|
|
55077
|
-
const font = objectTable.get(recFlags & 255);
|
|
55136
|
+
const font = worldUnitFont(rCtx, objectTable.get(recFlags & 255));
|
|
55078
55137
|
const glyphsOff = dataOff + 16;
|
|
55079
55138
|
const posOff = glyphsOff + glyphCount * 2;
|
|
55080
55139
|
const matrixOff = posOff + glyphCount * 8;
|
|
@@ -55958,6 +56017,9 @@ function handleMultiFormatStart(rCtx, dataOff, dataSize) {
|
|
|
55958
56017
|
}
|
|
55959
56018
|
(rCtx.ext ?? (rCtx.ext = {})).multiFormatSkip = true;
|
|
55960
56019
|
}
|
|
56020
|
+
function validDpi(dpi) {
|
|
56021
|
+
return dpi > 0 && dpi <= 1e5 ? dpi : void 0;
|
|
56022
|
+
}
|
|
55961
56023
|
function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH, state, dpiScale = 1, maxRecords = MAX_RECORDS_EMFPLUS_DEFAULT, fontFamilyMap, textureCache, fonts) {
|
|
55962
56024
|
const s = state ?? createEmfPlusState();
|
|
55963
56025
|
const rCtx = {
|
|
@@ -55972,8 +56034,12 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
55972
56034
|
totalDrawImageCalls: 0,
|
|
55973
56035
|
clipSaveDepth: s.clipSaveDepth,
|
|
55974
56036
|
clipRegion: s.clipRegion,
|
|
55975
|
-
|
|
56037
|
+
// GDI+ starts playback, as every Graphics, in the Display unit.
|
|
56038
|
+
pageUnit: s.pageUnit ?? UNIT_DISPLAY,
|
|
55976
56039
|
pageScale: s.pageScale ?? 1,
|
|
56040
|
+
dpiX: s.dpiX,
|
|
56041
|
+
dpiY: s.dpiY,
|
|
56042
|
+
videoDisplay: s.videoDisplay,
|
|
55977
56043
|
...s.continuation ?? createContinuationAccumulator(),
|
|
55978
56044
|
dpiScale,
|
|
55979
56045
|
canvasW,
|
|
@@ -56020,8 +56086,13 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56020
56086
|
case EMFPLUS_HEADER: {
|
|
56021
56087
|
s.dualMode = (recFlags & 1) !== 0;
|
|
56022
56088
|
if (recDataSize >= 16) {
|
|
56023
|
-
view.
|
|
56024
|
-
view.
|
|
56089
|
+
const plusFlags = view.getUint32(dataOff + 4, true);
|
|
56090
|
+
const dpiX = view.getUint32(dataOff + 8, true);
|
|
56091
|
+
const dpiY = view.getUint32(dataOff + 12, true);
|
|
56092
|
+
rCtx.dpiX = s.dpiX = validDpi(dpiX);
|
|
56093
|
+
rCtx.dpiY = s.dpiY = validDpi(dpiY);
|
|
56094
|
+
rCtx.videoDisplay = s.videoDisplay = (plusFlags & 1) !== 0;
|
|
56095
|
+
emfLog(`replayEmfPlusRecords: HEADER dpiX=${dpiX}, dpiY=${dpiY}, flags=0x${plusFlags.toString(16)}`);
|
|
56025
56096
|
}
|
|
56026
56097
|
break;
|
|
56027
56098
|
}
|
|
@@ -56117,6 +56188,9 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56117
56188
|
state.textRenderingHint = rCtx.textRenderingHint;
|
|
56118
56189
|
state.pageUnit = rCtx.pageUnit;
|
|
56119
56190
|
state.pageScale = rCtx.pageScale;
|
|
56191
|
+
state.dpiX = rCtx.dpiX;
|
|
56192
|
+
state.dpiY = rCtx.dpiY;
|
|
56193
|
+
state.videoDisplay = rCtx.videoDisplay;
|
|
56120
56194
|
state.antiAlias = rCtx.antiAlias;
|
|
56121
56195
|
}
|
|
56122
56196
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
package/dist/browser.mjs
CHANGED
|
@@ -26075,6 +26075,9 @@ function parseEmfPlusPenObject(view, dataOff, recDataSize, textureCache, cacheKe
|
|
|
26075
26075
|
return v;
|
|
26076
26076
|
};
|
|
26077
26077
|
const pen = { kind: "plus-pen", color: "rgba(0,0,0,1)", width: penWidth, dashStyle: 0 };
|
|
26078
|
+
if (hasVersion) {
|
|
26079
|
+
pen.unit = view.getUint32(dataOff + 12, true);
|
|
26080
|
+
}
|
|
26078
26081
|
if (penFlags & PEN_TRANSFORM) {
|
|
26079
26082
|
if (o + 24 <= end) {
|
|
26080
26083
|
pen.transform = [0, 4, 8, 12, 16, 20].map((k) => view.getFloat32(o + k, true));
|
|
@@ -30674,24 +30677,30 @@ function brushPaint(rCtx, obj) {
|
|
|
30674
30677
|
}
|
|
30675
30678
|
return obj.color;
|
|
30676
30679
|
}
|
|
30677
|
-
|
|
30678
|
-
|
|
30680
|
+
var UNIT_WORLD = 0;
|
|
30681
|
+
var UNIT_DISPLAY = 1;
|
|
30682
|
+
var UNIT_MILLIMETER = 6;
|
|
30683
|
+
var DEFAULT_PLUS_DPI = 96;
|
|
30684
|
+
function getPageUnitMultiplier(pageUnit, pageScale, dpi = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30679
30685
|
let unitToPixel;
|
|
30680
30686
|
switch (pageUnit) {
|
|
30687
|
+
case UNIT_DISPLAY:
|
|
30688
|
+
unitToPixel = videoDisplay ? 1 : dpi / 100;
|
|
30689
|
+
break;
|
|
30681
30690
|
case 3:
|
|
30682
|
-
unitToPixel =
|
|
30691
|
+
unitToPixel = dpi / 72;
|
|
30683
30692
|
break;
|
|
30684
30693
|
// Point
|
|
30685
30694
|
case 4:
|
|
30686
|
-
unitToPixel =
|
|
30695
|
+
unitToPixel = dpi;
|
|
30687
30696
|
break;
|
|
30688
30697
|
// Inch
|
|
30689
30698
|
case 5:
|
|
30690
|
-
unitToPixel =
|
|
30699
|
+
unitToPixel = dpi / 300;
|
|
30691
30700
|
break;
|
|
30692
30701
|
// Document
|
|
30693
30702
|
case 6:
|
|
30694
|
-
unitToPixel =
|
|
30703
|
+
unitToPixel = dpi / 25.4;
|
|
30695
30704
|
break;
|
|
30696
30705
|
// Millimeter
|
|
30697
30706
|
default:
|
|
@@ -30700,6 +30709,13 @@ function getPageUnitMultiplier(pageUnit, pageScale) {
|
|
|
30700
30709
|
}
|
|
30701
30710
|
return unitToPixel * pageScale;
|
|
30702
30711
|
}
|
|
30712
|
+
function pageMultipliers(rCtx) {
|
|
30713
|
+
const video = rCtx.videoDisplay ?? true;
|
|
30714
|
+
return [
|
|
30715
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiX ?? DEFAULT_PLUS_DPI, video),
|
|
30716
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiY ?? DEFAULT_PLUS_DPI, video)
|
|
30717
|
+
];
|
|
30718
|
+
}
|
|
30703
30719
|
function plusWorldMatrix(rCtx) {
|
|
30704
30720
|
const pre = plusPageToDeviceMatrix(rCtx);
|
|
30705
30721
|
const s = rCtx.dpiScale;
|
|
@@ -30729,8 +30745,8 @@ function plusPageToDeviceMatrix(rCtx) {
|
|
|
30729
30745
|
return ext.tsDevice;
|
|
30730
30746
|
}
|
|
30731
30747
|
const wt = rCtx.worldTransform;
|
|
30732
|
-
const
|
|
30733
|
-
const m = [wt[0] *
|
|
30748
|
+
const [kx, ky] = pageMultipliers(rCtx);
|
|
30749
|
+
const m = [wt[0] * kx, wt[1] * ky, wt[2] * kx, wt[3] * ky, wt[4] * kx, wt[5] * ky];
|
|
30734
30750
|
return ext?.containerTransform ? multiplyMatrix2(m, ext.containerTransform) : m;
|
|
30735
30751
|
}
|
|
30736
30752
|
function deviceToCanvasMatrix(rCtx) {
|
|
@@ -30813,7 +30829,7 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30813
30829
|
ext.textContrast = void 0;
|
|
30814
30830
|
rCtx.clipRegion = null;
|
|
30815
30831
|
rCtx.worldTransform = [1, 0, 0, 1, 0, 0];
|
|
30816
|
-
rCtx.pageUnit =
|
|
30832
|
+
rCtx.pageUnit = UNIT_DISPLAY;
|
|
30817
30833
|
rCtx.pageScale = 1;
|
|
30818
30834
|
rCtx.antiAlias = false;
|
|
30819
30835
|
rCtx.interpolationMode = void 0;
|
|
@@ -30821,16 +30837,17 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30821
30837
|
rCtx.textRenderingHint = void 0;
|
|
30822
30838
|
reapplyPlusClip(rCtx);
|
|
30823
30839
|
}
|
|
30824
|
-
function containerRectTransform(dst, src, unit) {
|
|
30825
|
-
const
|
|
30826
|
-
const
|
|
30827
|
-
const
|
|
30840
|
+
function containerRectTransform(dst, src, unit, dpiX = DEFAULT_PLUS_DPI, dpiY = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30841
|
+
const ux = unit === UNIT_WORLD ? dpiX / 100 : getPageUnitMultiplier(unit, 1, dpiX, videoDisplay);
|
|
30842
|
+
const uy = unit === UNIT_WORLD ? dpiY / 100 : getPageUnitMultiplier(unit, 1, dpiY, videoDisplay);
|
|
30843
|
+
const sw = src.w * ux;
|
|
30844
|
+
const sh = src.h * uy;
|
|
30828
30845
|
if (!(Math.abs(sw) > 0 && Math.abs(sh) > 0) || ![dst.x, dst.y, dst.w, dst.h, sw, sh].every(Number.isFinite)) {
|
|
30829
30846
|
return null;
|
|
30830
30847
|
}
|
|
30831
30848
|
const a = dst.w / sw;
|
|
30832
30849
|
const d = dst.h / sh;
|
|
30833
|
-
return [a, 0, 0, d, dst.x - src.x *
|
|
30850
|
+
return [a, 0, 0, d, dst.x - src.x * ux * a, dst.y - src.y * uy * d];
|
|
30834
30851
|
}
|
|
30835
30852
|
function concatClip(a, b) {
|
|
30836
30853
|
const parts = [...a ?? [], ...b ?? []];
|
|
@@ -31209,7 +31226,10 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31209
31226
|
const t = containerRectTransform(
|
|
31210
31227
|
{ x: f2(0), y: f2(4), w: f2(8), h: f2(12) },
|
|
31211
31228
|
{ x: f2(16), y: f2(20), w: f2(24), h: f2(28) },
|
|
31212
|
-
recFlags & 255
|
|
31229
|
+
recFlags & 255,
|
|
31230
|
+
rCtx.dpiX,
|
|
31231
|
+
rCtx.dpiY,
|
|
31232
|
+
rCtx.videoDisplay
|
|
31213
31233
|
);
|
|
31214
31234
|
beginContainer(rCtx, view.getUint32(dataOff + 32, true), t ?? [1, 0, 0, 1, 0, 0]);
|
|
31215
31235
|
}
|
|
@@ -31226,6 +31246,9 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31226
31246
|
dropTsDevice(rCtx);
|
|
31227
31247
|
const pageUnit = recFlags & 255;
|
|
31228
31248
|
const pageScale = recDataSize >= 4 ? view.getFloat32(dataOff, true) : 1;
|
|
31249
|
+
if (pageUnit === UNIT_WORLD || pageUnit > UNIT_MILLIMETER || !(pageScale > 0) || !Number.isFinite(pageScale)) {
|
|
31250
|
+
return true;
|
|
31251
|
+
}
|
|
31229
31252
|
rCtx.pageUnit = pageUnit;
|
|
31230
31253
|
rCtx.pageScale = pageScale;
|
|
31231
31254
|
return true;
|
|
@@ -54267,6 +54290,13 @@ function applyPlusPenStyle(ctx, pen, widthScale = 1) {
|
|
|
54267
54290
|
ctx.lineDashOffset = dashes.length > 0 ? (pen.dashOffset ?? 0) * (pen.width || 1) : 0;
|
|
54268
54291
|
}
|
|
54269
54292
|
function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false, evenOddClip = false) {
|
|
54293
|
+
if (pen) {
|
|
54294
|
+
const unitPen = penForUnit(rCtx, pen);
|
|
54295
|
+
if (!unitPen) {
|
|
54296
|
+
return;
|
|
54297
|
+
}
|
|
54298
|
+
pen = unitPen;
|
|
54299
|
+
}
|
|
54270
54300
|
const { ctx } = rCtx;
|
|
54271
54301
|
const resolved = resolvePenTransform(pen);
|
|
54272
54302
|
pen = resolved.pen;
|
|
@@ -54347,6 +54377,22 @@ function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false,
|
|
|
54347
54377
|
applyPlusWorldTransform(rCtx);
|
|
54348
54378
|
stroke(ctx);
|
|
54349
54379
|
}
|
|
54380
|
+
var PEN_UNIT_PIXEL = 2;
|
|
54381
|
+
function penForUnit(rCtx, pen) {
|
|
54382
|
+
const unit = pen.unit ?? 0;
|
|
54383
|
+
if (unit >= 3 && unit <= 6) {
|
|
54384
|
+
return null;
|
|
54385
|
+
}
|
|
54386
|
+
if (unit !== PEN_UNIT_PIXEL) {
|
|
54387
|
+
return pen;
|
|
54388
|
+
}
|
|
54389
|
+
const m = plusPageToDeviceMatrix(rCtx);
|
|
54390
|
+
const inv3 = invertAffine([m[0], m[1], m[2], m[3], 0, 0]);
|
|
54391
|
+
if (!inv3) {
|
|
54392
|
+
return pen;
|
|
54393
|
+
}
|
|
54394
|
+
return { ...pen, transform: mulMatrix(inv3, pen.transform ?? [1, 0, 0, 1, 0, 0]) };
|
|
54395
|
+
}
|
|
54350
54396
|
function resolvePenTransform(pen) {
|
|
54351
54397
|
if (!pen?.transform) {
|
|
54352
54398
|
return { pen, nib: null };
|
|
@@ -54808,6 +54854,19 @@ function rgbaToHex(c) {
|
|
|
54808
54854
|
}
|
|
54809
54855
|
return /^#[0-9a-f]{6}$/i.test(c) ? c : null;
|
|
54810
54856
|
}
|
|
54857
|
+
function worldUnitFont(rCtx, obj) {
|
|
54858
|
+
if (!obj || obj.kind !== "plus-font") {
|
|
54859
|
+
return obj;
|
|
54860
|
+
}
|
|
54861
|
+
const unit = obj.unit ?? 0;
|
|
54862
|
+
if (unit < 3 || unit > 6) {
|
|
54863
|
+
return unit === 0 ? obj : { ...obj, unit: 0 };
|
|
54864
|
+
}
|
|
54865
|
+
const dpi = rCtx.dpiY ?? DEFAULT_PLUS_DPI;
|
|
54866
|
+
const page = getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, dpi, rCtx.videoDisplay ?? true);
|
|
54867
|
+
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54868
|
+
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54869
|
+
}
|
|
54811
54870
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54812
54871
|
const fonts = rCtx.fonts;
|
|
54813
54872
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
@@ -55018,7 +55077,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55018
55077
|
const layoutW = view.getFloat32(dataOff + 20, true);
|
|
55019
55078
|
const layoutH = view.getFloat32(dataOff + 24, true);
|
|
55020
55079
|
const fontId = recFlags & 255;
|
|
55021
|
-
const font = objectTable.get(fontId);
|
|
55080
|
+
const font = worldUnitFont(rCtx, objectTable.get(fontId));
|
|
55022
55081
|
if (strLen > 0 && dataOff + 28 + strLen * 2 <= dataOff + recDataSize) {
|
|
55023
55082
|
const text = readUtf16LE(view, dataOff + 28, strLen);
|
|
55024
55083
|
if (text.length > 0 && font && font.kind === "plus-font") {
|
|
@@ -55072,7 +55131,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55072
55131
|
const options2 = view.getUint32(dataOff + 4, true);
|
|
55073
55132
|
const matrixPresent = view.getUint32(dataOff + 8, true) !== 0;
|
|
55074
55133
|
const glyphCount = view.getUint32(dataOff + 12, true);
|
|
55075
|
-
const font = objectTable.get(recFlags & 255);
|
|
55134
|
+
const font = worldUnitFont(rCtx, objectTable.get(recFlags & 255));
|
|
55076
55135
|
const glyphsOff = dataOff + 16;
|
|
55077
55136
|
const posOff = glyphsOff + glyphCount * 2;
|
|
55078
55137
|
const matrixOff = posOff + glyphCount * 8;
|
|
@@ -55956,6 +56015,9 @@ function handleMultiFormatStart(rCtx, dataOff, dataSize) {
|
|
|
55956
56015
|
}
|
|
55957
56016
|
(rCtx.ext ?? (rCtx.ext = {})).multiFormatSkip = true;
|
|
55958
56017
|
}
|
|
56018
|
+
function validDpi(dpi) {
|
|
56019
|
+
return dpi > 0 && dpi <= 1e5 ? dpi : void 0;
|
|
56020
|
+
}
|
|
55959
56021
|
function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH, state, dpiScale = 1, maxRecords = MAX_RECORDS_EMFPLUS_DEFAULT, fontFamilyMap, textureCache, fonts) {
|
|
55960
56022
|
const s = state ?? createEmfPlusState();
|
|
55961
56023
|
const rCtx = {
|
|
@@ -55970,8 +56032,12 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
55970
56032
|
totalDrawImageCalls: 0,
|
|
55971
56033
|
clipSaveDepth: s.clipSaveDepth,
|
|
55972
56034
|
clipRegion: s.clipRegion,
|
|
55973
|
-
|
|
56035
|
+
// GDI+ starts playback, as every Graphics, in the Display unit.
|
|
56036
|
+
pageUnit: s.pageUnit ?? UNIT_DISPLAY,
|
|
55974
56037
|
pageScale: s.pageScale ?? 1,
|
|
56038
|
+
dpiX: s.dpiX,
|
|
56039
|
+
dpiY: s.dpiY,
|
|
56040
|
+
videoDisplay: s.videoDisplay,
|
|
55975
56041
|
...s.continuation ?? createContinuationAccumulator(),
|
|
55976
56042
|
dpiScale,
|
|
55977
56043
|
canvasW,
|
|
@@ -56018,8 +56084,13 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56018
56084
|
case EMFPLUS_HEADER: {
|
|
56019
56085
|
s.dualMode = (recFlags & 1) !== 0;
|
|
56020
56086
|
if (recDataSize >= 16) {
|
|
56021
|
-
view.
|
|
56022
|
-
view.
|
|
56087
|
+
const plusFlags = view.getUint32(dataOff + 4, true);
|
|
56088
|
+
const dpiX = view.getUint32(dataOff + 8, true);
|
|
56089
|
+
const dpiY = view.getUint32(dataOff + 12, true);
|
|
56090
|
+
rCtx.dpiX = s.dpiX = validDpi(dpiX);
|
|
56091
|
+
rCtx.dpiY = s.dpiY = validDpi(dpiY);
|
|
56092
|
+
rCtx.videoDisplay = s.videoDisplay = (plusFlags & 1) !== 0;
|
|
56093
|
+
emfLog(`replayEmfPlusRecords: HEADER dpiX=${dpiX}, dpiY=${dpiY}, flags=0x${plusFlags.toString(16)}`);
|
|
56023
56094
|
}
|
|
56024
56095
|
break;
|
|
56025
56096
|
}
|
|
@@ -56115,6 +56186,9 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56115
56186
|
state.textRenderingHint = rCtx.textRenderingHint;
|
|
56116
56187
|
state.pageUnit = rCtx.pageUnit;
|
|
56117
56188
|
state.pageScale = rCtx.pageScale;
|
|
56189
|
+
state.dpiX = rCtx.dpiX;
|
|
56190
|
+
state.dpiY = rCtx.dpiY;
|
|
56191
|
+
state.videoDisplay = rCtx.videoDisplay;
|
|
56118
56192
|
state.antiAlias = rCtx.antiAlias;
|
|
56119
56193
|
}
|
|
56120
56194
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
package/dist/index.js
CHANGED
|
@@ -26078,6 +26078,9 @@ function parseEmfPlusPenObject(view, dataOff, recDataSize, textureCache, cacheKe
|
|
|
26078
26078
|
return v;
|
|
26079
26079
|
};
|
|
26080
26080
|
const pen = { kind: "plus-pen", color: "rgba(0,0,0,1)", width: penWidth, dashStyle: 0 };
|
|
26081
|
+
if (hasVersion) {
|
|
26082
|
+
pen.unit = view.getUint32(dataOff + 12, true);
|
|
26083
|
+
}
|
|
26081
26084
|
if (penFlags & PEN_TRANSFORM) {
|
|
26082
26085
|
if (o + 24 <= end) {
|
|
26083
26086
|
pen.transform = [0, 4, 8, 12, 16, 20].map((k) => view.getFloat32(o + k, true));
|
|
@@ -30677,24 +30680,30 @@ function brushPaint(rCtx, obj) {
|
|
|
30677
30680
|
}
|
|
30678
30681
|
return obj.color;
|
|
30679
30682
|
}
|
|
30680
|
-
|
|
30681
|
-
|
|
30683
|
+
var UNIT_WORLD = 0;
|
|
30684
|
+
var UNIT_DISPLAY = 1;
|
|
30685
|
+
var UNIT_MILLIMETER = 6;
|
|
30686
|
+
var DEFAULT_PLUS_DPI = 96;
|
|
30687
|
+
function getPageUnitMultiplier(pageUnit, pageScale, dpi = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30682
30688
|
let unitToPixel;
|
|
30683
30689
|
switch (pageUnit) {
|
|
30690
|
+
case UNIT_DISPLAY:
|
|
30691
|
+
unitToPixel = videoDisplay ? 1 : dpi / 100;
|
|
30692
|
+
break;
|
|
30684
30693
|
case 3:
|
|
30685
|
-
unitToPixel =
|
|
30694
|
+
unitToPixel = dpi / 72;
|
|
30686
30695
|
break;
|
|
30687
30696
|
// Point
|
|
30688
30697
|
case 4:
|
|
30689
|
-
unitToPixel =
|
|
30698
|
+
unitToPixel = dpi;
|
|
30690
30699
|
break;
|
|
30691
30700
|
// Inch
|
|
30692
30701
|
case 5:
|
|
30693
|
-
unitToPixel =
|
|
30702
|
+
unitToPixel = dpi / 300;
|
|
30694
30703
|
break;
|
|
30695
30704
|
// Document
|
|
30696
30705
|
case 6:
|
|
30697
|
-
unitToPixel =
|
|
30706
|
+
unitToPixel = dpi / 25.4;
|
|
30698
30707
|
break;
|
|
30699
30708
|
// Millimeter
|
|
30700
30709
|
default:
|
|
@@ -30703,6 +30712,13 @@ function getPageUnitMultiplier(pageUnit, pageScale) {
|
|
|
30703
30712
|
}
|
|
30704
30713
|
return unitToPixel * pageScale;
|
|
30705
30714
|
}
|
|
30715
|
+
function pageMultipliers(rCtx) {
|
|
30716
|
+
const video = rCtx.videoDisplay ?? true;
|
|
30717
|
+
return [
|
|
30718
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiX ?? DEFAULT_PLUS_DPI, video),
|
|
30719
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiY ?? DEFAULT_PLUS_DPI, video)
|
|
30720
|
+
];
|
|
30721
|
+
}
|
|
30706
30722
|
function plusWorldMatrix(rCtx) {
|
|
30707
30723
|
const pre = plusPageToDeviceMatrix(rCtx);
|
|
30708
30724
|
const s = rCtx.dpiScale;
|
|
@@ -30732,8 +30748,8 @@ function plusPageToDeviceMatrix(rCtx) {
|
|
|
30732
30748
|
return ext.tsDevice;
|
|
30733
30749
|
}
|
|
30734
30750
|
const wt = rCtx.worldTransform;
|
|
30735
|
-
const
|
|
30736
|
-
const m = [wt[0] *
|
|
30751
|
+
const [kx, ky] = pageMultipliers(rCtx);
|
|
30752
|
+
const m = [wt[0] * kx, wt[1] * ky, wt[2] * kx, wt[3] * ky, wt[4] * kx, wt[5] * ky];
|
|
30737
30753
|
return ext?.containerTransform ? multiplyMatrix2(m, ext.containerTransform) : m;
|
|
30738
30754
|
}
|
|
30739
30755
|
function deviceToCanvasMatrix(rCtx) {
|
|
@@ -30816,7 +30832,7 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30816
30832
|
ext.textContrast = void 0;
|
|
30817
30833
|
rCtx.clipRegion = null;
|
|
30818
30834
|
rCtx.worldTransform = [1, 0, 0, 1, 0, 0];
|
|
30819
|
-
rCtx.pageUnit =
|
|
30835
|
+
rCtx.pageUnit = UNIT_DISPLAY;
|
|
30820
30836
|
rCtx.pageScale = 1;
|
|
30821
30837
|
rCtx.antiAlias = false;
|
|
30822
30838
|
rCtx.interpolationMode = void 0;
|
|
@@ -30824,16 +30840,17 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30824
30840
|
rCtx.textRenderingHint = void 0;
|
|
30825
30841
|
reapplyPlusClip(rCtx);
|
|
30826
30842
|
}
|
|
30827
|
-
function containerRectTransform(dst, src, unit) {
|
|
30828
|
-
const
|
|
30829
|
-
const
|
|
30830
|
-
const
|
|
30843
|
+
function containerRectTransform(dst, src, unit, dpiX = DEFAULT_PLUS_DPI, dpiY = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30844
|
+
const ux = unit === UNIT_WORLD ? dpiX / 100 : getPageUnitMultiplier(unit, 1, dpiX, videoDisplay);
|
|
30845
|
+
const uy = unit === UNIT_WORLD ? dpiY / 100 : getPageUnitMultiplier(unit, 1, dpiY, videoDisplay);
|
|
30846
|
+
const sw = src.w * ux;
|
|
30847
|
+
const sh = src.h * uy;
|
|
30831
30848
|
if (!(Math.abs(sw) > 0 && Math.abs(sh) > 0) || ![dst.x, dst.y, dst.w, dst.h, sw, sh].every(Number.isFinite)) {
|
|
30832
30849
|
return null;
|
|
30833
30850
|
}
|
|
30834
30851
|
const a = dst.w / sw;
|
|
30835
30852
|
const d = dst.h / sh;
|
|
30836
|
-
return [a, 0, 0, d, dst.x - src.x *
|
|
30853
|
+
return [a, 0, 0, d, dst.x - src.x * ux * a, dst.y - src.y * uy * d];
|
|
30837
30854
|
}
|
|
30838
30855
|
function concatClip(a, b) {
|
|
30839
30856
|
const parts = [...a ?? [], ...b ?? []];
|
|
@@ -31212,7 +31229,10 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31212
31229
|
const t = containerRectTransform(
|
|
31213
31230
|
{ x: f2(0), y: f2(4), w: f2(8), h: f2(12) },
|
|
31214
31231
|
{ x: f2(16), y: f2(20), w: f2(24), h: f2(28) },
|
|
31215
|
-
recFlags & 255
|
|
31232
|
+
recFlags & 255,
|
|
31233
|
+
rCtx.dpiX,
|
|
31234
|
+
rCtx.dpiY,
|
|
31235
|
+
rCtx.videoDisplay
|
|
31216
31236
|
);
|
|
31217
31237
|
beginContainer(rCtx, view.getUint32(dataOff + 32, true), t ?? [1, 0, 0, 1, 0, 0]);
|
|
31218
31238
|
}
|
|
@@ -31229,6 +31249,9 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31229
31249
|
dropTsDevice(rCtx);
|
|
31230
31250
|
const pageUnit = recFlags & 255;
|
|
31231
31251
|
const pageScale = recDataSize >= 4 ? view.getFloat32(dataOff, true) : 1;
|
|
31252
|
+
if (pageUnit === UNIT_WORLD || pageUnit > UNIT_MILLIMETER || !(pageScale > 0) || !Number.isFinite(pageScale)) {
|
|
31253
|
+
return true;
|
|
31254
|
+
}
|
|
31232
31255
|
rCtx.pageUnit = pageUnit;
|
|
31233
31256
|
rCtx.pageScale = pageScale;
|
|
31234
31257
|
return true;
|
|
@@ -54270,6 +54293,13 @@ function applyPlusPenStyle(ctx, pen, widthScale = 1) {
|
|
|
54270
54293
|
ctx.lineDashOffset = dashes.length > 0 ? (pen.dashOffset ?? 0) * (pen.width || 1) : 0;
|
|
54271
54294
|
}
|
|
54272
54295
|
function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false, evenOddClip = false) {
|
|
54296
|
+
if (pen) {
|
|
54297
|
+
const unitPen = penForUnit(rCtx, pen);
|
|
54298
|
+
if (!unitPen) {
|
|
54299
|
+
return;
|
|
54300
|
+
}
|
|
54301
|
+
pen = unitPen;
|
|
54302
|
+
}
|
|
54273
54303
|
const { ctx } = rCtx;
|
|
54274
54304
|
const resolved = resolvePenTransform(pen);
|
|
54275
54305
|
pen = resolved.pen;
|
|
@@ -54350,6 +54380,22 @@ function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false,
|
|
|
54350
54380
|
applyPlusWorldTransform(rCtx);
|
|
54351
54381
|
stroke(ctx);
|
|
54352
54382
|
}
|
|
54383
|
+
var PEN_UNIT_PIXEL = 2;
|
|
54384
|
+
function penForUnit(rCtx, pen) {
|
|
54385
|
+
const unit = pen.unit ?? 0;
|
|
54386
|
+
if (unit >= 3 && unit <= 6) {
|
|
54387
|
+
return null;
|
|
54388
|
+
}
|
|
54389
|
+
if (unit !== PEN_UNIT_PIXEL) {
|
|
54390
|
+
return pen;
|
|
54391
|
+
}
|
|
54392
|
+
const m = plusPageToDeviceMatrix(rCtx);
|
|
54393
|
+
const inv3 = invertAffine([m[0], m[1], m[2], m[3], 0, 0]);
|
|
54394
|
+
if (!inv3) {
|
|
54395
|
+
return pen;
|
|
54396
|
+
}
|
|
54397
|
+
return { ...pen, transform: mulMatrix(inv3, pen.transform ?? [1, 0, 0, 1, 0, 0]) };
|
|
54398
|
+
}
|
|
54353
54399
|
function resolvePenTransform(pen) {
|
|
54354
54400
|
if (!pen?.transform) {
|
|
54355
54401
|
return { pen, nib: null };
|
|
@@ -54811,6 +54857,19 @@ function rgbaToHex(c) {
|
|
|
54811
54857
|
}
|
|
54812
54858
|
return /^#[0-9a-f]{6}$/i.test(c) ? c : null;
|
|
54813
54859
|
}
|
|
54860
|
+
function worldUnitFont(rCtx, obj) {
|
|
54861
|
+
if (!obj || obj.kind !== "plus-font") {
|
|
54862
|
+
return obj;
|
|
54863
|
+
}
|
|
54864
|
+
const unit = obj.unit ?? 0;
|
|
54865
|
+
if (unit < 3 || unit > 6) {
|
|
54866
|
+
return unit === 0 ? obj : { ...obj, unit: 0 };
|
|
54867
|
+
}
|
|
54868
|
+
const dpi = rCtx.dpiY ?? DEFAULT_PLUS_DPI;
|
|
54869
|
+
const page = getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, dpi, rCtx.videoDisplay ?? true);
|
|
54870
|
+
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54871
|
+
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54872
|
+
}
|
|
54814
54873
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54815
54874
|
const fonts = rCtx.fonts;
|
|
54816
54875
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
@@ -55021,7 +55080,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55021
55080
|
const layoutW = view.getFloat32(dataOff + 20, true);
|
|
55022
55081
|
const layoutH = view.getFloat32(dataOff + 24, true);
|
|
55023
55082
|
const fontId = recFlags & 255;
|
|
55024
|
-
const font = objectTable.get(fontId);
|
|
55083
|
+
const font = worldUnitFont(rCtx, objectTable.get(fontId));
|
|
55025
55084
|
if (strLen > 0 && dataOff + 28 + strLen * 2 <= dataOff + recDataSize) {
|
|
55026
55085
|
const text = readUtf16LE(view, dataOff + 28, strLen);
|
|
55027
55086
|
if (text.length > 0 && font && font.kind === "plus-font") {
|
|
@@ -55075,7 +55134,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55075
55134
|
const options2 = view.getUint32(dataOff + 4, true);
|
|
55076
55135
|
const matrixPresent = view.getUint32(dataOff + 8, true) !== 0;
|
|
55077
55136
|
const glyphCount = view.getUint32(dataOff + 12, true);
|
|
55078
|
-
const font = objectTable.get(recFlags & 255);
|
|
55137
|
+
const font = worldUnitFont(rCtx, objectTable.get(recFlags & 255));
|
|
55079
55138
|
const glyphsOff = dataOff + 16;
|
|
55080
55139
|
const posOff = glyphsOff + glyphCount * 2;
|
|
55081
55140
|
const matrixOff = posOff + glyphCount * 8;
|
|
@@ -55959,6 +56018,9 @@ function handleMultiFormatStart(rCtx, dataOff, dataSize) {
|
|
|
55959
56018
|
}
|
|
55960
56019
|
(rCtx.ext ?? (rCtx.ext = {})).multiFormatSkip = true;
|
|
55961
56020
|
}
|
|
56021
|
+
function validDpi(dpi) {
|
|
56022
|
+
return dpi > 0 && dpi <= 1e5 ? dpi : void 0;
|
|
56023
|
+
}
|
|
55962
56024
|
function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH, state, dpiScale = 1, maxRecords = MAX_RECORDS_EMFPLUS_DEFAULT, fontFamilyMap, textureCache, fonts) {
|
|
55963
56025
|
const s = state ?? createEmfPlusState();
|
|
55964
56026
|
const rCtx = {
|
|
@@ -55973,8 +56035,12 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
55973
56035
|
totalDrawImageCalls: 0,
|
|
55974
56036
|
clipSaveDepth: s.clipSaveDepth,
|
|
55975
56037
|
clipRegion: s.clipRegion,
|
|
55976
|
-
|
|
56038
|
+
// GDI+ starts playback, as every Graphics, in the Display unit.
|
|
56039
|
+
pageUnit: s.pageUnit ?? UNIT_DISPLAY,
|
|
55977
56040
|
pageScale: s.pageScale ?? 1,
|
|
56041
|
+
dpiX: s.dpiX,
|
|
56042
|
+
dpiY: s.dpiY,
|
|
56043
|
+
videoDisplay: s.videoDisplay,
|
|
55978
56044
|
...s.continuation ?? createContinuationAccumulator(),
|
|
55979
56045
|
dpiScale,
|
|
55980
56046
|
canvasW,
|
|
@@ -56021,8 +56087,13 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56021
56087
|
case EMFPLUS_HEADER: {
|
|
56022
56088
|
s.dualMode = (recFlags & 1) !== 0;
|
|
56023
56089
|
if (recDataSize >= 16) {
|
|
56024
|
-
view.
|
|
56025
|
-
view.
|
|
56090
|
+
const plusFlags = view.getUint32(dataOff + 4, true);
|
|
56091
|
+
const dpiX = view.getUint32(dataOff + 8, true);
|
|
56092
|
+
const dpiY = view.getUint32(dataOff + 12, true);
|
|
56093
|
+
rCtx.dpiX = s.dpiX = validDpi(dpiX);
|
|
56094
|
+
rCtx.dpiY = s.dpiY = validDpi(dpiY);
|
|
56095
|
+
rCtx.videoDisplay = s.videoDisplay = (plusFlags & 1) !== 0;
|
|
56096
|
+
emfLog(`replayEmfPlusRecords: HEADER dpiX=${dpiX}, dpiY=${dpiY}, flags=0x${plusFlags.toString(16)}`);
|
|
56026
56097
|
}
|
|
56027
56098
|
break;
|
|
56028
56099
|
}
|
|
@@ -56118,6 +56189,9 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56118
56189
|
state.textRenderingHint = rCtx.textRenderingHint;
|
|
56119
56190
|
state.pageUnit = rCtx.pageUnit;
|
|
56120
56191
|
state.pageScale = rCtx.pageScale;
|
|
56192
|
+
state.dpiX = rCtx.dpiX;
|
|
56193
|
+
state.dpiY = rCtx.dpiY;
|
|
56194
|
+
state.videoDisplay = rCtx.videoDisplay;
|
|
56121
56195
|
state.antiAlias = rCtx.antiAlias;
|
|
56122
56196
|
}
|
|
56123
56197
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
package/dist/index.mjs
CHANGED
|
@@ -26076,6 +26076,9 @@ function parseEmfPlusPenObject(view, dataOff, recDataSize, textureCache, cacheKe
|
|
|
26076
26076
|
return v;
|
|
26077
26077
|
};
|
|
26078
26078
|
const pen = { kind: "plus-pen", color: "rgba(0,0,0,1)", width: penWidth, dashStyle: 0 };
|
|
26079
|
+
if (hasVersion) {
|
|
26080
|
+
pen.unit = view.getUint32(dataOff + 12, true);
|
|
26081
|
+
}
|
|
26079
26082
|
if (penFlags & PEN_TRANSFORM) {
|
|
26080
26083
|
if (o + 24 <= end) {
|
|
26081
26084
|
pen.transform = [0, 4, 8, 12, 16, 20].map((k) => view.getFloat32(o + k, true));
|
|
@@ -30675,24 +30678,30 @@ function brushPaint(rCtx, obj) {
|
|
|
30675
30678
|
}
|
|
30676
30679
|
return obj.color;
|
|
30677
30680
|
}
|
|
30678
|
-
|
|
30679
|
-
|
|
30681
|
+
var UNIT_WORLD = 0;
|
|
30682
|
+
var UNIT_DISPLAY = 1;
|
|
30683
|
+
var UNIT_MILLIMETER = 6;
|
|
30684
|
+
var DEFAULT_PLUS_DPI = 96;
|
|
30685
|
+
function getPageUnitMultiplier(pageUnit, pageScale, dpi = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30680
30686
|
let unitToPixel;
|
|
30681
30687
|
switch (pageUnit) {
|
|
30688
|
+
case UNIT_DISPLAY:
|
|
30689
|
+
unitToPixel = videoDisplay ? 1 : dpi / 100;
|
|
30690
|
+
break;
|
|
30682
30691
|
case 3:
|
|
30683
|
-
unitToPixel =
|
|
30692
|
+
unitToPixel = dpi / 72;
|
|
30684
30693
|
break;
|
|
30685
30694
|
// Point
|
|
30686
30695
|
case 4:
|
|
30687
|
-
unitToPixel =
|
|
30696
|
+
unitToPixel = dpi;
|
|
30688
30697
|
break;
|
|
30689
30698
|
// Inch
|
|
30690
30699
|
case 5:
|
|
30691
|
-
unitToPixel =
|
|
30700
|
+
unitToPixel = dpi / 300;
|
|
30692
30701
|
break;
|
|
30693
30702
|
// Document
|
|
30694
30703
|
case 6:
|
|
30695
|
-
unitToPixel =
|
|
30704
|
+
unitToPixel = dpi / 25.4;
|
|
30696
30705
|
break;
|
|
30697
30706
|
// Millimeter
|
|
30698
30707
|
default:
|
|
@@ -30701,6 +30710,13 @@ function getPageUnitMultiplier(pageUnit, pageScale) {
|
|
|
30701
30710
|
}
|
|
30702
30711
|
return unitToPixel * pageScale;
|
|
30703
30712
|
}
|
|
30713
|
+
function pageMultipliers(rCtx) {
|
|
30714
|
+
const video = rCtx.videoDisplay ?? true;
|
|
30715
|
+
return [
|
|
30716
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiX ?? DEFAULT_PLUS_DPI, video),
|
|
30717
|
+
getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, rCtx.dpiY ?? DEFAULT_PLUS_DPI, video)
|
|
30718
|
+
];
|
|
30719
|
+
}
|
|
30704
30720
|
function plusWorldMatrix(rCtx) {
|
|
30705
30721
|
const pre = plusPageToDeviceMatrix(rCtx);
|
|
30706
30722
|
const s = rCtx.dpiScale;
|
|
@@ -30730,8 +30746,8 @@ function plusPageToDeviceMatrix(rCtx) {
|
|
|
30730
30746
|
return ext.tsDevice;
|
|
30731
30747
|
}
|
|
30732
30748
|
const wt = rCtx.worldTransform;
|
|
30733
|
-
const
|
|
30734
|
-
const m = [wt[0] *
|
|
30749
|
+
const [kx, ky] = pageMultipliers(rCtx);
|
|
30750
|
+
const m = [wt[0] * kx, wt[1] * ky, wt[2] * kx, wt[3] * ky, wt[4] * kx, wt[5] * ky];
|
|
30735
30751
|
return ext?.containerTransform ? multiplyMatrix2(m, ext.containerTransform) : m;
|
|
30736
30752
|
}
|
|
30737
30753
|
function deviceToCanvasMatrix(rCtx) {
|
|
@@ -30814,7 +30830,7 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30814
30830
|
ext.textContrast = void 0;
|
|
30815
30831
|
rCtx.clipRegion = null;
|
|
30816
30832
|
rCtx.worldTransform = [1, 0, 0, 1, 0, 0];
|
|
30817
|
-
rCtx.pageUnit =
|
|
30833
|
+
rCtx.pageUnit = UNIT_DISPLAY;
|
|
30818
30834
|
rCtx.pageScale = 1;
|
|
30819
30835
|
rCtx.antiAlias = false;
|
|
30820
30836
|
rCtx.interpolationMode = void 0;
|
|
@@ -30822,16 +30838,17 @@ function beginContainer(rCtx, stackId, rectTransform) {
|
|
|
30822
30838
|
rCtx.textRenderingHint = void 0;
|
|
30823
30839
|
reapplyPlusClip(rCtx);
|
|
30824
30840
|
}
|
|
30825
|
-
function containerRectTransform(dst, src, unit) {
|
|
30826
|
-
const
|
|
30827
|
-
const
|
|
30828
|
-
const
|
|
30841
|
+
function containerRectTransform(dst, src, unit, dpiX = DEFAULT_PLUS_DPI, dpiY = DEFAULT_PLUS_DPI, videoDisplay = true) {
|
|
30842
|
+
const ux = unit === UNIT_WORLD ? dpiX / 100 : getPageUnitMultiplier(unit, 1, dpiX, videoDisplay);
|
|
30843
|
+
const uy = unit === UNIT_WORLD ? dpiY / 100 : getPageUnitMultiplier(unit, 1, dpiY, videoDisplay);
|
|
30844
|
+
const sw = src.w * ux;
|
|
30845
|
+
const sh = src.h * uy;
|
|
30829
30846
|
if (!(Math.abs(sw) > 0 && Math.abs(sh) > 0) || ![dst.x, dst.y, dst.w, dst.h, sw, sh].every(Number.isFinite)) {
|
|
30830
30847
|
return null;
|
|
30831
30848
|
}
|
|
30832
30849
|
const a = dst.w / sw;
|
|
30833
30850
|
const d = dst.h / sh;
|
|
30834
|
-
return [a, 0, 0, d, dst.x - src.x *
|
|
30851
|
+
return [a, 0, 0, d, dst.x - src.x * ux * a, dst.y - src.y * uy * d];
|
|
30835
30852
|
}
|
|
30836
30853
|
function concatClip(a, b) {
|
|
30837
30854
|
const parts = [...a ?? [], ...b ?? []];
|
|
@@ -31210,7 +31227,10 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31210
31227
|
const t = containerRectTransform(
|
|
31211
31228
|
{ x: f2(0), y: f2(4), w: f2(8), h: f2(12) },
|
|
31212
31229
|
{ x: f2(16), y: f2(20), w: f2(24), h: f2(28) },
|
|
31213
|
-
recFlags & 255
|
|
31230
|
+
recFlags & 255,
|
|
31231
|
+
rCtx.dpiX,
|
|
31232
|
+
rCtx.dpiY,
|
|
31233
|
+
rCtx.videoDisplay
|
|
31214
31234
|
);
|
|
31215
31235
|
beginContainer(rCtx, view.getUint32(dataOff + 32, true), t ?? [1, 0, 0, 1, 0, 0]);
|
|
31216
31236
|
}
|
|
@@ -31227,6 +31247,9 @@ function handleEmfPlusStateRecord(rCtx, recType, recFlags, dataOff, recDataSize)
|
|
|
31227
31247
|
dropTsDevice(rCtx);
|
|
31228
31248
|
const pageUnit = recFlags & 255;
|
|
31229
31249
|
const pageScale = recDataSize >= 4 ? view.getFloat32(dataOff, true) : 1;
|
|
31250
|
+
if (pageUnit === UNIT_WORLD || pageUnit > UNIT_MILLIMETER || !(pageScale > 0) || !Number.isFinite(pageScale)) {
|
|
31251
|
+
return true;
|
|
31252
|
+
}
|
|
31230
31253
|
rCtx.pageUnit = pageUnit;
|
|
31231
31254
|
rCtx.pageScale = pageScale;
|
|
31232
31255
|
return true;
|
|
@@ -54268,6 +54291,13 @@ function applyPlusPenStyle(ctx, pen, widthScale = 1) {
|
|
|
54268
54291
|
ctx.lineDashOffset = dashes.length > 0 ? (pen.dashOffset ?? 0) * (pen.width || 1) : 0;
|
|
54269
54292
|
}
|
|
54270
54293
|
function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false, evenOddClip = false) {
|
|
54294
|
+
if (pen) {
|
|
54295
|
+
const unitPen = penForUnit(rCtx, pen);
|
|
54296
|
+
if (!unitPen) {
|
|
54297
|
+
return;
|
|
54298
|
+
}
|
|
54299
|
+
pen = unitPen;
|
|
54300
|
+
}
|
|
54271
54301
|
const { ctx } = rCtx;
|
|
54272
54302
|
const resolved = resolvePenTransform(pen);
|
|
54273
54303
|
pen = resolved.pen;
|
|
@@ -54348,6 +54378,22 @@ function strokePlusGeometry(rCtx, pen, buildPath, points, closedFigure = false,
|
|
|
54348
54378
|
applyPlusWorldTransform(rCtx);
|
|
54349
54379
|
stroke(ctx);
|
|
54350
54380
|
}
|
|
54381
|
+
var PEN_UNIT_PIXEL = 2;
|
|
54382
|
+
function penForUnit(rCtx, pen) {
|
|
54383
|
+
const unit = pen.unit ?? 0;
|
|
54384
|
+
if (unit >= 3 && unit <= 6) {
|
|
54385
|
+
return null;
|
|
54386
|
+
}
|
|
54387
|
+
if (unit !== PEN_UNIT_PIXEL) {
|
|
54388
|
+
return pen;
|
|
54389
|
+
}
|
|
54390
|
+
const m = plusPageToDeviceMatrix(rCtx);
|
|
54391
|
+
const inv3 = invertAffine([m[0], m[1], m[2], m[3], 0, 0]);
|
|
54392
|
+
if (!inv3) {
|
|
54393
|
+
return pen;
|
|
54394
|
+
}
|
|
54395
|
+
return { ...pen, transform: mulMatrix(inv3, pen.transform ?? [1, 0, 0, 1, 0, 0]) };
|
|
54396
|
+
}
|
|
54351
54397
|
function resolvePenTransform(pen) {
|
|
54352
54398
|
if (!pen?.transform) {
|
|
54353
54399
|
return { pen, nib: null };
|
|
@@ -54809,6 +54855,19 @@ function rgbaToHex(c) {
|
|
|
54809
54855
|
}
|
|
54810
54856
|
return /^#[0-9a-f]{6}$/i.test(c) ? c : null;
|
|
54811
54857
|
}
|
|
54858
|
+
function worldUnitFont(rCtx, obj) {
|
|
54859
|
+
if (!obj || obj.kind !== "plus-font") {
|
|
54860
|
+
return obj;
|
|
54861
|
+
}
|
|
54862
|
+
const unit = obj.unit ?? 0;
|
|
54863
|
+
if (unit < 3 || unit > 6) {
|
|
54864
|
+
return unit === 0 ? obj : { ...obj, unit: 0 };
|
|
54865
|
+
}
|
|
54866
|
+
const dpi = rCtx.dpiY ?? DEFAULT_PLUS_DPI;
|
|
54867
|
+
const page = getPageUnitMultiplier(rCtx.pageUnit, rCtx.pageScale, dpi, rCtx.videoDisplay ?? true);
|
|
54868
|
+
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54869
|
+
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54870
|
+
}
|
|
54812
54871
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54813
54872
|
const fonts = rCtx.fonts;
|
|
54814
54873
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
@@ -55019,7 +55078,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55019
55078
|
const layoutW = view.getFloat32(dataOff + 20, true);
|
|
55020
55079
|
const layoutH = view.getFloat32(dataOff + 24, true);
|
|
55021
55080
|
const fontId = recFlags & 255;
|
|
55022
|
-
const font = objectTable.get(fontId);
|
|
55081
|
+
const font = worldUnitFont(rCtx, objectTable.get(fontId));
|
|
55023
55082
|
if (strLen > 0 && dataOff + 28 + strLen * 2 <= dataOff + recDataSize) {
|
|
55024
55083
|
const text = readUtf16LE(view, dataOff + 28, strLen);
|
|
55025
55084
|
if (text.length > 0 && font && font.kind === "plus-font") {
|
|
@@ -55073,7 +55132,7 @@ function handleEmfPlusTextImageRecord(rCtx, recType, recFlags, dataOff, recDataS
|
|
|
55073
55132
|
const options2 = view.getUint32(dataOff + 4, true);
|
|
55074
55133
|
const matrixPresent = view.getUint32(dataOff + 8, true) !== 0;
|
|
55075
55134
|
const glyphCount = view.getUint32(dataOff + 12, true);
|
|
55076
|
-
const font = objectTable.get(recFlags & 255);
|
|
55135
|
+
const font = worldUnitFont(rCtx, objectTable.get(recFlags & 255));
|
|
55077
55136
|
const glyphsOff = dataOff + 16;
|
|
55078
55137
|
const posOff = glyphsOff + glyphCount * 2;
|
|
55079
55138
|
const matrixOff = posOff + glyphCount * 8;
|
|
@@ -55957,6 +56016,9 @@ function handleMultiFormatStart(rCtx, dataOff, dataSize) {
|
|
|
55957
56016
|
}
|
|
55958
56017
|
(rCtx.ext ?? (rCtx.ext = {})).multiFormatSkip = true;
|
|
55959
56018
|
}
|
|
56019
|
+
function validDpi(dpi) {
|
|
56020
|
+
return dpi > 0 && dpi <= 1e5 ? dpi : void 0;
|
|
56021
|
+
}
|
|
55960
56022
|
function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH, state, dpiScale = 1, maxRecords = MAX_RECORDS_EMFPLUS_DEFAULT, fontFamilyMap, textureCache, fonts) {
|
|
55961
56023
|
const s = state ?? createEmfPlusState();
|
|
55962
56024
|
const rCtx = {
|
|
@@ -55971,8 +56033,12 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
55971
56033
|
totalDrawImageCalls: 0,
|
|
55972
56034
|
clipSaveDepth: s.clipSaveDepth,
|
|
55973
56035
|
clipRegion: s.clipRegion,
|
|
55974
|
-
|
|
56036
|
+
// GDI+ starts playback, as every Graphics, in the Display unit.
|
|
56037
|
+
pageUnit: s.pageUnit ?? UNIT_DISPLAY,
|
|
55975
56038
|
pageScale: s.pageScale ?? 1,
|
|
56039
|
+
dpiX: s.dpiX,
|
|
56040
|
+
dpiY: s.dpiY,
|
|
56041
|
+
videoDisplay: s.videoDisplay,
|
|
55976
56042
|
...s.continuation ?? createContinuationAccumulator(),
|
|
55977
56043
|
dpiScale,
|
|
55978
56044
|
canvasW,
|
|
@@ -56019,8 +56085,13 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56019
56085
|
case EMFPLUS_HEADER: {
|
|
56020
56086
|
s.dualMode = (recFlags & 1) !== 0;
|
|
56021
56087
|
if (recDataSize >= 16) {
|
|
56022
|
-
view.
|
|
56023
|
-
view.
|
|
56088
|
+
const plusFlags = view.getUint32(dataOff + 4, true);
|
|
56089
|
+
const dpiX = view.getUint32(dataOff + 8, true);
|
|
56090
|
+
const dpiY = view.getUint32(dataOff + 12, true);
|
|
56091
|
+
rCtx.dpiX = s.dpiX = validDpi(dpiX);
|
|
56092
|
+
rCtx.dpiY = s.dpiY = validDpi(dpiY);
|
|
56093
|
+
rCtx.videoDisplay = s.videoDisplay = (plusFlags & 1) !== 0;
|
|
56094
|
+
emfLog(`replayEmfPlusRecords: HEADER dpiX=${dpiX}, dpiY=${dpiY}, flags=0x${plusFlags.toString(16)}`);
|
|
56024
56095
|
}
|
|
56025
56096
|
break;
|
|
56026
56097
|
}
|
|
@@ -56116,6 +56187,9 @@ function* replayEmfPlusRecordsSteps(view, offset, length, ctx, canvasW, canvasH,
|
|
|
56116
56187
|
state.textRenderingHint = rCtx.textRenderingHint;
|
|
56117
56188
|
state.pageUnit = rCtx.pageUnit;
|
|
56118
56189
|
state.pageScale = rCtx.pageScale;
|
|
56190
|
+
state.dpiX = rCtx.dpiX;
|
|
56191
|
+
state.dpiY = rCtx.dpiY;
|
|
56192
|
+
state.videoDisplay = rCtx.videoDisplay;
|
|
56119
56193
|
state.antiAlias = rCtx.antiAlias;
|
|
56120
56194
|
}
|
|
56121
56195
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|