emf-converter 4.15.0 → 4.15.2

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 CHANGED
@@ -29999,7 +29999,7 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
29999
29999
  const ly = (-matrix[1] * dx + matrix[0] * dy) / det;
30000
30000
  let l = Math.hypot(lx, ly);
30001
30001
  if (wholePixelNorm) {
30002
- l = norm(Math.floor((lx + slack) / 16) * 16, Math.floor((ly + slack) / 16) * 16);
30002
+ l = norm(Math.sign(lx) * Math.floor((Math.abs(lx) + slack) / 16) * 16, Math.sign(ly) * Math.floor((Math.abs(ly) + slack) / 16) * 16);
30003
30003
  if (l === 0) return [0, 0];
30004
30004
  }
30005
30005
  const q = width / 2 * scale / l;
@@ -30012,7 +30012,8 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
30012
30012
  const lx = dx / ax;
30013
30013
  const ly = dy / ay;
30014
30014
  const cut = ax === 1 && ay === 1 ? 0 : slack;
30015
- const whole = norm(Math.floor((lx + cut) / 16) * 16, Math.floor((ly + cut) / 16) * 16);
30015
+ const unit = (v) => cut ? Math.sign(v) * Math.floor((Math.abs(v) + cut) / 16) * 16 : Math.floor(v / 16) * 16;
30016
+ const whole = norm(unit(lx), unit(ly));
30016
30017
  if (whole === 0) return [0, 0];
30017
30018
  return [round(lx / whole * r), round(ly * ay / ax / whole * r)];
30018
30019
  }
@@ -30230,6 +30231,11 @@ var Outliner = class {
30230
30231
  this.pts.push([p[0], p[1]]);
30231
30232
  if (curveJoin && !this.originalRoundJoinSides) {
30232
30233
  this.push(p, sb);
30234
+ if (cap === "flat" && Da !== Db && !(a.curveEnd && b.curveEnd)) {
30235
+ const before = this.pts.length;
30236
+ this.wedge(p, rayB, rayA, false, false, this.extremeTail(side === "L", Da, a));
30237
+ if (this.pts.length - before < 2) this.pts.length = before;
30238
+ }
30233
30239
  this.push(p, sa);
30234
30240
  this.pts.push([p[0], p[1]]);
30235
30241
  }
@@ -30763,9 +30769,8 @@ function penWidenOptions(rCtx, opts = {}) {
30763
30769
  const unrotated = Math.abs(matrix[1]) < 1e-6 && Math.abs(matrix[2]) < 1e-6;
30764
30770
  const scaled2 = !rCtx.wholeDevicePixels && unrotated && (Math.abs(Math.abs(matrix[0]) - 1) > 1e-6 || Math.abs(Math.abs(matrix[3]) - 1) > 1e-6);
30765
30771
  const uniform = scaled2 && !ellipse && state.penExtended && (flags & 15) !== 6;
30766
- const nibWidth = uniform ? Math.max(1, Math.floor(widthPx + 0.5)) : widthPx;
30767
30772
  return {
30768
- width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : nibWidth) * 16),
30773
+ width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : widthPx) * 16),
30769
30774
  ...ellipse ? { height: Math.round(state.penWidth * Math.abs(matrix[3]) * 16) } : {},
30770
30775
  cap: opts.roundPen || !state.penExtended || capBits === 0 ? "round" : capBits === 256 ? "square" : "flat",
30771
30776
  join: opts.roundPen ? "round" : opts.rectangle && !state.penExtended ? "miter" : !state.penExtended || joinBits === 0 ? "round" : joinBits === 4096 ? "bevel" : "miter",
@@ -30779,7 +30784,7 @@ function penWidenOptions(rCtx, opts = {}) {
30779
30784
  ...scaled2 && !dashes ? {
30780
30785
  cutToLogicalUnits: true,
30781
30786
  logicalScale: ellipse ? [Math.abs(matrix[0]), Math.abs(matrix[3])] : Math.abs(matrix[0]),
30782
- // The pen rounds to whole pixels, but a square cap extends by half the unrounded width.
30787
+ // A square cap extends by half the unrounded width in FIX.
30783
30788
  ...uniform ? { capWidth: state.penWidth * Math.abs(matrix[0]) * 16 } : {}
30784
30789
  } : {}
30785
30790
  };
@@ -32094,11 +32099,10 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32094
32099
  const cornerOnFrame = (fix, size, framedSize) => inset && size !== 0 ? Math.floor(Math.min(fix, size) * framedSize / size) : fix;
32095
32100
  let cw = cornerOnFrame(cornerFixW, Math.abs((r - l) * devM[0]) * 16, Math.abs(framed.exx));
32096
32101
  let ch = cornerOnFrame(cornerFixH, Math.abs((b - t) * devM[3]) * 16, Math.abs(framed.eyy));
32097
- if (!inset && rCtx.state.penStyle !== 6 && cornerW !== 0 && cornerH !== 0 && Math.abs(devM[1]) < 1e-9 && Math.abs(devM[2]) < 1e-9 && rCtx.state.penStyle !== 5 && !penIsCosmetic(rCtx) && rCtx.state.worldTransform.every((v, i) => v === [1, 0, 0, 1, 0, 0][i])) {
32098
- const fullW = (Math.abs(r - l) + 1) * Math.abs(devM[0]) * 16;
32099
- const fullH = (Math.abs(b - t) + 1) * Math.abs(devM[3]) * 16;
32100
- cw = Math.floor(Math.min(cornerFixW, fullW) * Math.abs(framed.exx) / fullW);
32101
- ch = Math.floor(Math.min(cornerFixH, fullH) * Math.abs(framed.eyy) / fullH);
32102
+ const drawBox = inset ? framed : curvedFixBox(rCtx, l, t, r, b, true);
32103
+ if (!inset && drawBox.exx !== unframed.exx && Math.abs(unframed.exx) > 0 && Math.abs(unframed.eyy) > 0 && cornerW !== 0 && cornerH !== 0) {
32104
+ cw = Math.floor(Math.min(cornerFixW, Math.abs(unframed.exx)) * Math.abs(drawBox.exx) / Math.abs(unframed.exx));
32105
+ ch = Math.floor(Math.min(cornerFixH, Math.abs(unframed.eyy)) * Math.abs(drawBox.eyy) / Math.abs(unframed.eyy));
32102
32106
  }
32103
32107
  const drawRoundRect = inset ? (c) => appendRoundRectPath(
32104
32108
  c,
@@ -32128,7 +32132,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32128
32132
  }
32129
32133
  const raster = (box = framed) => roundRectRasterPath(box, cw, ch, clockwise, cornerW === 0 || cornerH === 0);
32130
32134
  if (inPath) {
32131
- const box = framed;
32135
+ const box = drawBox;
32132
32136
  if (cornerW === 0 || cornerH === 0) recordRectangle(rCtx, box, clockwise);
32133
32137
  else {
32134
32138
  recordBezierShape(rCtx, roundRectDeviceBeziers(box, cw, ch, clockwise), 8);
@@ -32141,7 +32145,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32141
32145
  c.beginPath();
32142
32146
  drawRoundRect(c);
32143
32147
  },
32144
- raster: () => raster(inset ? framed : curvedFixBox(rCtx, l, t, r, b, true)),
32148
+ raster: () => raster(drawBox),
32145
32149
  roundPen: true,
32146
32150
  fill: true,
32147
32151
  stroke: true
package/dist/browser.mjs CHANGED
@@ -29997,7 +29997,7 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
29997
29997
  const ly = (-matrix[1] * dx + matrix[0] * dy) / det;
29998
29998
  let l = Math.hypot(lx, ly);
29999
29999
  if (wholePixelNorm) {
30000
- l = norm(Math.floor((lx + slack) / 16) * 16, Math.floor((ly + slack) / 16) * 16);
30000
+ l = norm(Math.sign(lx) * Math.floor((Math.abs(lx) + slack) / 16) * 16, Math.sign(ly) * Math.floor((Math.abs(ly) + slack) / 16) * 16);
30001
30001
  if (l === 0) return [0, 0];
30002
30002
  }
30003
30003
  const q = width / 2 * scale / l;
@@ -30010,7 +30010,8 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
30010
30010
  const lx = dx / ax;
30011
30011
  const ly = dy / ay;
30012
30012
  const cut = ax === 1 && ay === 1 ? 0 : slack;
30013
- const whole = norm(Math.floor((lx + cut) / 16) * 16, Math.floor((ly + cut) / 16) * 16);
30013
+ const unit = (v) => cut ? Math.sign(v) * Math.floor((Math.abs(v) + cut) / 16) * 16 : Math.floor(v / 16) * 16;
30014
+ const whole = norm(unit(lx), unit(ly));
30014
30015
  if (whole === 0) return [0, 0];
30015
30016
  return [round(lx / whole * r), round(ly * ay / ax / whole * r)];
30016
30017
  }
@@ -30228,6 +30229,11 @@ var Outliner = class {
30228
30229
  this.pts.push([p[0], p[1]]);
30229
30230
  if (curveJoin && !this.originalRoundJoinSides) {
30230
30231
  this.push(p, sb);
30232
+ if (cap === "flat" && Da !== Db && !(a.curveEnd && b.curveEnd)) {
30233
+ const before = this.pts.length;
30234
+ this.wedge(p, rayB, rayA, false, false, this.extremeTail(side === "L", Da, a));
30235
+ if (this.pts.length - before < 2) this.pts.length = before;
30236
+ }
30231
30237
  this.push(p, sa);
30232
30238
  this.pts.push([p[0], p[1]]);
30233
30239
  }
@@ -30761,9 +30767,8 @@ function penWidenOptions(rCtx, opts = {}) {
30761
30767
  const unrotated = Math.abs(matrix[1]) < 1e-6 && Math.abs(matrix[2]) < 1e-6;
30762
30768
  const scaled2 = !rCtx.wholeDevicePixels && unrotated && (Math.abs(Math.abs(matrix[0]) - 1) > 1e-6 || Math.abs(Math.abs(matrix[3]) - 1) > 1e-6);
30763
30769
  const uniform = scaled2 && !ellipse && state.penExtended && (flags & 15) !== 6;
30764
- const nibWidth = uniform ? Math.max(1, Math.floor(widthPx + 0.5)) : widthPx;
30765
30770
  return {
30766
- width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : nibWidth) * 16),
30771
+ width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : widthPx) * 16),
30767
30772
  ...ellipse ? { height: Math.round(state.penWidth * Math.abs(matrix[3]) * 16) } : {},
30768
30773
  cap: opts.roundPen || !state.penExtended || capBits === 0 ? "round" : capBits === 256 ? "square" : "flat",
30769
30774
  join: opts.roundPen ? "round" : opts.rectangle && !state.penExtended ? "miter" : !state.penExtended || joinBits === 0 ? "round" : joinBits === 4096 ? "bevel" : "miter",
@@ -30777,7 +30782,7 @@ function penWidenOptions(rCtx, opts = {}) {
30777
30782
  ...scaled2 && !dashes ? {
30778
30783
  cutToLogicalUnits: true,
30779
30784
  logicalScale: ellipse ? [Math.abs(matrix[0]), Math.abs(matrix[3])] : Math.abs(matrix[0]),
30780
- // The pen rounds to whole pixels, but a square cap extends by half the unrounded width.
30785
+ // A square cap extends by half the unrounded width in FIX.
30781
30786
  ...uniform ? { capWidth: state.penWidth * Math.abs(matrix[0]) * 16 } : {}
30782
30787
  } : {}
30783
30788
  };
@@ -32092,11 +32097,10 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32092
32097
  const cornerOnFrame = (fix, size, framedSize) => inset && size !== 0 ? Math.floor(Math.min(fix, size) * framedSize / size) : fix;
32093
32098
  let cw = cornerOnFrame(cornerFixW, Math.abs((r - l) * devM[0]) * 16, Math.abs(framed.exx));
32094
32099
  let ch = cornerOnFrame(cornerFixH, Math.abs((b - t) * devM[3]) * 16, Math.abs(framed.eyy));
32095
- if (!inset && rCtx.state.penStyle !== 6 && cornerW !== 0 && cornerH !== 0 && Math.abs(devM[1]) < 1e-9 && Math.abs(devM[2]) < 1e-9 && rCtx.state.penStyle !== 5 && !penIsCosmetic(rCtx) && rCtx.state.worldTransform.every((v, i) => v === [1, 0, 0, 1, 0, 0][i])) {
32096
- const fullW = (Math.abs(r - l) + 1) * Math.abs(devM[0]) * 16;
32097
- const fullH = (Math.abs(b - t) + 1) * Math.abs(devM[3]) * 16;
32098
- cw = Math.floor(Math.min(cornerFixW, fullW) * Math.abs(framed.exx) / fullW);
32099
- ch = Math.floor(Math.min(cornerFixH, fullH) * Math.abs(framed.eyy) / fullH);
32100
+ const drawBox = inset ? framed : curvedFixBox(rCtx, l, t, r, b, true);
32101
+ if (!inset && drawBox.exx !== unframed.exx && Math.abs(unframed.exx) > 0 && Math.abs(unframed.eyy) > 0 && cornerW !== 0 && cornerH !== 0) {
32102
+ cw = Math.floor(Math.min(cornerFixW, Math.abs(unframed.exx)) * Math.abs(drawBox.exx) / Math.abs(unframed.exx));
32103
+ ch = Math.floor(Math.min(cornerFixH, Math.abs(unframed.eyy)) * Math.abs(drawBox.eyy) / Math.abs(unframed.eyy));
32100
32104
  }
32101
32105
  const drawRoundRect = inset ? (c) => appendRoundRectPath(
32102
32106
  c,
@@ -32126,7 +32130,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32126
32130
  }
32127
32131
  const raster = (box = framed) => roundRectRasterPath(box, cw, ch, clockwise, cornerW === 0 || cornerH === 0);
32128
32132
  if (inPath) {
32129
- const box = framed;
32133
+ const box = drawBox;
32130
32134
  if (cornerW === 0 || cornerH === 0) recordRectangle(rCtx, box, clockwise);
32131
32135
  else {
32132
32136
  recordBezierShape(rCtx, roundRectDeviceBeziers(box, cw, ch, clockwise), 8);
@@ -32139,7 +32143,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32139
32143
  c.beginPath();
32140
32144
  drawRoundRect(c);
32141
32145
  },
32142
- raster: () => raster(inset ? framed : curvedFixBox(rCtx, l, t, r, b, true)),
32146
+ raster: () => raster(drawBox),
32143
32147
  roundPen: true,
32144
32148
  fill: true,
32145
32149
  stroke: true
package/dist/index.js CHANGED
@@ -30000,7 +30000,7 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
30000
30000
  const ly = (-matrix[1] * dx + matrix[0] * dy) / det;
30001
30001
  let l = Math.hypot(lx, ly);
30002
30002
  if (wholePixelNorm) {
30003
- l = norm(Math.floor((lx + slack) / 16) * 16, Math.floor((ly + slack) / 16) * 16);
30003
+ l = norm(Math.sign(lx) * Math.floor((Math.abs(lx) + slack) / 16) * 16, Math.sign(ly) * Math.floor((Math.abs(ly) + slack) / 16) * 16);
30004
30004
  if (l === 0) return [0, 0];
30005
30005
  }
30006
30006
  const q = width / 2 * scale / l;
@@ -30013,7 +30013,8 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
30013
30013
  const lx = dx / ax;
30014
30014
  const ly = dy / ay;
30015
30015
  const cut = ax === 1 && ay === 1 ? 0 : slack;
30016
- const whole = norm(Math.floor((lx + cut) / 16) * 16, Math.floor((ly + cut) / 16) * 16);
30016
+ const unit = (v) => cut ? Math.sign(v) * Math.floor((Math.abs(v) + cut) / 16) * 16 : Math.floor(v / 16) * 16;
30017
+ const whole = norm(unit(lx), unit(ly));
30017
30018
  if (whole === 0) return [0, 0];
30018
30019
  return [round(lx / whole * r), round(ly * ay / ax / whole * r)];
30019
30020
  }
@@ -30231,6 +30232,11 @@ var Outliner = class {
30231
30232
  this.pts.push([p[0], p[1]]);
30232
30233
  if (curveJoin && !this.originalRoundJoinSides) {
30233
30234
  this.push(p, sb);
30235
+ if (cap === "flat" && Da !== Db && !(a.curveEnd && b.curveEnd)) {
30236
+ const before = this.pts.length;
30237
+ this.wedge(p, rayB, rayA, false, false, this.extremeTail(side === "L", Da, a));
30238
+ if (this.pts.length - before < 2) this.pts.length = before;
30239
+ }
30234
30240
  this.push(p, sa);
30235
30241
  this.pts.push([p[0], p[1]]);
30236
30242
  }
@@ -30764,9 +30770,8 @@ function penWidenOptions(rCtx, opts = {}) {
30764
30770
  const unrotated = Math.abs(matrix[1]) < 1e-6 && Math.abs(matrix[2]) < 1e-6;
30765
30771
  const scaled2 = !rCtx.wholeDevicePixels && unrotated && (Math.abs(Math.abs(matrix[0]) - 1) > 1e-6 || Math.abs(Math.abs(matrix[3]) - 1) > 1e-6);
30766
30772
  const uniform = scaled2 && !ellipse && state.penExtended && (flags & 15) !== 6;
30767
- const nibWidth = uniform ? Math.max(1, Math.floor(widthPx + 0.5)) : widthPx;
30768
30773
  return {
30769
- width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : nibWidth) * 16),
30774
+ width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : widthPx) * 16),
30770
30775
  ...ellipse ? { height: Math.round(state.penWidth * Math.abs(matrix[3]) * 16) } : {},
30771
30776
  cap: opts.roundPen || !state.penExtended || capBits === 0 ? "round" : capBits === 256 ? "square" : "flat",
30772
30777
  join: opts.roundPen ? "round" : opts.rectangle && !state.penExtended ? "miter" : !state.penExtended || joinBits === 0 ? "round" : joinBits === 4096 ? "bevel" : "miter",
@@ -30780,7 +30785,7 @@ function penWidenOptions(rCtx, opts = {}) {
30780
30785
  ...scaled2 && !dashes ? {
30781
30786
  cutToLogicalUnits: true,
30782
30787
  logicalScale: ellipse ? [Math.abs(matrix[0]), Math.abs(matrix[3])] : Math.abs(matrix[0]),
30783
- // The pen rounds to whole pixels, but a square cap extends by half the unrounded width.
30788
+ // A square cap extends by half the unrounded width in FIX.
30784
30789
  ...uniform ? { capWidth: state.penWidth * Math.abs(matrix[0]) * 16 } : {}
30785
30790
  } : {}
30786
30791
  };
@@ -32095,11 +32100,10 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32095
32100
  const cornerOnFrame = (fix, size, framedSize) => inset && size !== 0 ? Math.floor(Math.min(fix, size) * framedSize / size) : fix;
32096
32101
  let cw = cornerOnFrame(cornerFixW, Math.abs((r - l) * devM[0]) * 16, Math.abs(framed.exx));
32097
32102
  let ch = cornerOnFrame(cornerFixH, Math.abs((b - t) * devM[3]) * 16, Math.abs(framed.eyy));
32098
- if (!inset && rCtx.state.penStyle !== 6 && cornerW !== 0 && cornerH !== 0 && Math.abs(devM[1]) < 1e-9 && Math.abs(devM[2]) < 1e-9 && rCtx.state.penStyle !== 5 && !penIsCosmetic(rCtx) && rCtx.state.worldTransform.every((v, i) => v === [1, 0, 0, 1, 0, 0][i])) {
32099
- const fullW = (Math.abs(r - l) + 1) * Math.abs(devM[0]) * 16;
32100
- const fullH = (Math.abs(b - t) + 1) * Math.abs(devM[3]) * 16;
32101
- cw = Math.floor(Math.min(cornerFixW, fullW) * Math.abs(framed.exx) / fullW);
32102
- ch = Math.floor(Math.min(cornerFixH, fullH) * Math.abs(framed.eyy) / fullH);
32103
+ const drawBox = inset ? framed : curvedFixBox(rCtx, l, t, r, b, true);
32104
+ if (!inset && drawBox.exx !== unframed.exx && Math.abs(unframed.exx) > 0 && Math.abs(unframed.eyy) > 0 && cornerW !== 0 && cornerH !== 0) {
32105
+ cw = Math.floor(Math.min(cornerFixW, Math.abs(unframed.exx)) * Math.abs(drawBox.exx) / Math.abs(unframed.exx));
32106
+ ch = Math.floor(Math.min(cornerFixH, Math.abs(unframed.eyy)) * Math.abs(drawBox.eyy) / Math.abs(unframed.eyy));
32103
32107
  }
32104
32108
  const drawRoundRect = inset ? (c) => appendRoundRectPath(
32105
32109
  c,
@@ -32129,7 +32133,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32129
32133
  }
32130
32134
  const raster = (box = framed) => roundRectRasterPath(box, cw, ch, clockwise, cornerW === 0 || cornerH === 0);
32131
32135
  if (inPath) {
32132
- const box = framed;
32136
+ const box = drawBox;
32133
32137
  if (cornerW === 0 || cornerH === 0) recordRectangle(rCtx, box, clockwise);
32134
32138
  else {
32135
32139
  recordBezierShape(rCtx, roundRectDeviceBeziers(box, cw, ch, clockwise), 8);
@@ -32142,7 +32146,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32142
32146
  c.beginPath();
32143
32147
  drawRoundRect(c);
32144
32148
  },
32145
- raster: () => raster(inset ? framed : curvedFixBox(rCtx, l, t, r, b, true)),
32149
+ raster: () => raster(drawBox),
32146
32150
  roundPen: true,
32147
32151
  fill: true,
32148
32152
  stroke: true
package/dist/index.mjs CHANGED
@@ -29998,7 +29998,7 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
29998
29998
  const ly = (-matrix[1] * dx + matrix[0] * dy) / det;
29999
29999
  let l = Math.hypot(lx, ly);
30000
30000
  if (wholePixelNorm) {
30001
- l = norm(Math.floor((lx + slack) / 16) * 16, Math.floor((ly + slack) / 16) * 16);
30001
+ l = norm(Math.sign(lx) * Math.floor((Math.abs(lx) + slack) / 16) * 16, Math.sign(ly) * Math.floor((Math.abs(ly) + slack) / 16) * 16);
30002
30002
  if (l === 0) return [0, 0];
30003
30003
  }
30004
30004
  const q = width / 2 * scale / l;
@@ -30011,7 +30011,8 @@ function squareExtension(width, dx, dy, scale = 1, height = width, matrix, whole
30011
30011
  const lx = dx / ax;
30012
30012
  const ly = dy / ay;
30013
30013
  const cut = ax === 1 && ay === 1 ? 0 : slack;
30014
- const whole = norm(Math.floor((lx + cut) / 16) * 16, Math.floor((ly + cut) / 16) * 16);
30014
+ const unit = (v) => cut ? Math.sign(v) * Math.floor((Math.abs(v) + cut) / 16) * 16 : Math.floor(v / 16) * 16;
30015
+ const whole = norm(unit(lx), unit(ly));
30015
30016
  if (whole === 0) return [0, 0];
30016
30017
  return [round(lx / whole * r), round(ly * ay / ax / whole * r)];
30017
30018
  }
@@ -30229,6 +30230,11 @@ var Outliner = class {
30229
30230
  this.pts.push([p[0], p[1]]);
30230
30231
  if (curveJoin && !this.originalRoundJoinSides) {
30231
30232
  this.push(p, sb);
30233
+ if (cap === "flat" && Da !== Db && !(a.curveEnd && b.curveEnd)) {
30234
+ const before = this.pts.length;
30235
+ this.wedge(p, rayB, rayA, false, false, this.extremeTail(side === "L", Da, a));
30236
+ if (this.pts.length - before < 2) this.pts.length = before;
30237
+ }
30232
30238
  this.push(p, sa);
30233
30239
  this.pts.push([p[0], p[1]]);
30234
30240
  }
@@ -30762,9 +30768,8 @@ function penWidenOptions(rCtx, opts = {}) {
30762
30768
  const unrotated = Math.abs(matrix[1]) < 1e-6 && Math.abs(matrix[2]) < 1e-6;
30763
30769
  const scaled2 = !rCtx.wholeDevicePixels && unrotated && (Math.abs(Math.abs(matrix[0]) - 1) > 1e-6 || Math.abs(Math.abs(matrix[3]) - 1) > 1e-6);
30764
30770
  const uniform = scaled2 && !ellipse && state.penExtended && (flags & 15) !== 6;
30765
- const nibWidth = uniform ? Math.max(1, Math.floor(widthPx + 0.5)) : widthPx;
30766
30771
  return {
30767
- width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : nibWidth) * 16),
30772
+ width: Math.round((ellipse ? state.penWidth * Math.abs(matrix[0]) : widthPx) * 16),
30768
30773
  ...ellipse ? { height: Math.round(state.penWidth * Math.abs(matrix[3]) * 16) } : {},
30769
30774
  cap: opts.roundPen || !state.penExtended || capBits === 0 ? "round" : capBits === 256 ? "square" : "flat",
30770
30775
  join: opts.roundPen ? "round" : opts.rectangle && !state.penExtended ? "miter" : !state.penExtended || joinBits === 0 ? "round" : joinBits === 4096 ? "bevel" : "miter",
@@ -30778,7 +30783,7 @@ function penWidenOptions(rCtx, opts = {}) {
30778
30783
  ...scaled2 && !dashes ? {
30779
30784
  cutToLogicalUnits: true,
30780
30785
  logicalScale: ellipse ? [Math.abs(matrix[0]), Math.abs(matrix[3])] : Math.abs(matrix[0]),
30781
- // The pen rounds to whole pixels, but a square cap extends by half the unrounded width.
30786
+ // A square cap extends by half the unrounded width in FIX.
30782
30787
  ...uniform ? { capWidth: state.penWidth * Math.abs(matrix[0]) * 16 } : {}
30783
30788
  } : {}
30784
30789
  };
@@ -32093,11 +32098,10 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32093
32098
  const cornerOnFrame = (fix, size, framedSize) => inset && size !== 0 ? Math.floor(Math.min(fix, size) * framedSize / size) : fix;
32094
32099
  let cw = cornerOnFrame(cornerFixW, Math.abs((r - l) * devM[0]) * 16, Math.abs(framed.exx));
32095
32100
  let ch = cornerOnFrame(cornerFixH, Math.abs((b - t) * devM[3]) * 16, Math.abs(framed.eyy));
32096
- if (!inset && rCtx.state.penStyle !== 6 && cornerW !== 0 && cornerH !== 0 && Math.abs(devM[1]) < 1e-9 && Math.abs(devM[2]) < 1e-9 && rCtx.state.penStyle !== 5 && !penIsCosmetic(rCtx) && rCtx.state.worldTransform.every((v, i) => v === [1, 0, 0, 1, 0, 0][i])) {
32097
- const fullW = (Math.abs(r - l) + 1) * Math.abs(devM[0]) * 16;
32098
- const fullH = (Math.abs(b - t) + 1) * Math.abs(devM[3]) * 16;
32099
- cw = Math.floor(Math.min(cornerFixW, fullW) * Math.abs(framed.exx) / fullW);
32100
- ch = Math.floor(Math.min(cornerFixH, fullH) * Math.abs(framed.eyy) / fullH);
32101
+ const drawBox = inset ? framed : curvedFixBox(rCtx, l, t, r, b, true);
32102
+ if (!inset && drawBox.exx !== unframed.exx && Math.abs(unframed.exx) > 0 && Math.abs(unframed.eyy) > 0 && cornerW !== 0 && cornerH !== 0) {
32103
+ cw = Math.floor(Math.min(cornerFixW, Math.abs(unframed.exx)) * Math.abs(drawBox.exx) / Math.abs(unframed.exx));
32104
+ ch = Math.floor(Math.min(cornerFixH, Math.abs(unframed.eyy)) * Math.abs(drawBox.eyy) / Math.abs(unframed.eyy));
32101
32105
  }
32102
32106
  const drawRoundRect = inset ? (c) => appendRoundRectPath(
32103
32107
  c,
@@ -32127,7 +32131,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32127
32131
  }
32128
32132
  const raster = (box = framed) => roundRectRasterPath(box, cw, ch, clockwise, cornerW === 0 || cornerH === 0);
32129
32133
  if (inPath) {
32130
- const box = framed;
32134
+ const box = drawBox;
32131
32135
  if (cornerW === 0 || cornerH === 0) recordRectangle(rCtx, box, clockwise);
32132
32136
  else {
32133
32137
  recordBezierShape(rCtx, roundRectDeviceBeziers(box, cw, ch, clockwise), 8);
@@ -32140,7 +32144,7 @@ function handleRoundRect(rCtx, dataOff, recSize) {
32140
32144
  c.beginPath();
32141
32145
  drawRoundRect(c);
32142
32146
  },
32143
- raster: () => raster(inset ? framed : curvedFixBox(rCtx, l, t, r, b, true)),
32147
+ raster: () => raster(drawBox),
32144
32148
  roundPen: true,
32145
32149
  fill: true,
32146
32150
  stroke: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emf-converter",
3
- "version": "4.15.0",
3
+ "version": "4.15.2",
4
4
  "description": "Convert EMF/WMF metafile binaries to PNG data URLs or SVG (markup, data URL, React/JSX)",
5
5
  "keywords": [
6
6
  "canvas",