@office-kit/pptx-preview 0.8.0 → 0.8.1

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as MONO, c as TIMES, d as substituteFamily, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout } from "./src-D95l1T9U.js";
1
+ import { a as MONO, c as TIMES, d as substituteFamily, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout } from "./src-BMb2-vud.js";
2
2
  export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, defaultMeasurer, renderSlideSvg as renderSlideToSvg, substituteFamily };
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as MONO, c as TIMES, d as substituteFamily, i as AVG_GLYPH_W_RATIO, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout, u as isCjk } from "./src-D95l1T9U.js";
1
+ import { a as MONO, c as TIMES, d as substituteFamily, i as AVG_GLYPH_W_RATIO, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout, u as isCjk } from "./src-BMb2-vud.js";
2
2
  import { getSlideSize } from "@office-kit/pptx";
3
3
  import { Resvg } from "@resvg/resvg-js";
4
4
  import * as fontkit from "fontkit";
@@ -16,11 +16,11 @@ const substituteFamily = (family) => {
16
16
  return SANS;
17
17
  };
18
18
  const isCjk = (cp) => cp >= 12352 && cp <= 12447 || cp >= 12448 && cp <= 12543 || cp >= 19968 && cp <= 40959 || cp >= 44032 && cp <= 55215;
19
- const AVG_GLYPH_W_RATIO$1 = .55;
19
+ const AVG_GLYPH_W_RATIO = .55;
20
20
  const defaultMeasurer = (text, spec) => {
21
21
  let w = 0;
22
22
  for (const ch of text) {
23
- const ratio = isCjk(ch.codePointAt(0) ?? 0) ? 1 : AVG_GLYPH_W_RATIO$1;
23
+ const ratio = isCjk(ch.codePointAt(0) ?? 0) ? 1 : AVG_GLYPH_W_RATIO;
24
24
  w += spec.sizePx * ratio;
25
25
  }
26
26
  const n = [...text].length;
@@ -1876,7 +1876,6 @@ const renderRun = (text, format, theme, effectivePt, _wasDefault = false) => {
1876
1876
  return `<span style="${styles.join(";")}">${content}</span>`;
1877
1877
  };
1878
1878
  const LINE_HEIGHT = 1.05;
1879
- const AVG_GLYPH_W_RATIO = .55;
1880
1879
  const AUTOFIT_FLOOR = .25;
1881
1880
  const AUTOFIT_STEP = .05;
1882
1881
  const underlineStyleOf = (fmt) => {
@@ -2254,33 +2253,7 @@ const resolveTextBodyModel = (pres, shape, bounds, theme, phType, measure, defau
2254
2253
  if (!hasAnyText) return null;
2255
2254
  const authoredAutofit = getShapeTextAutoFitParams(shape);
2256
2255
  let autoFitScale = authoredAutofit?.fontScale ?? 1;
2257
- let lineHeightScale = 1 - (authoredAutofit?.lnSpcReduction ?? 0);
2258
- if (!authoredAutofit) {
2259
- const innerWPx = innerW / EMU_PER_PX;
2260
- const innerHPx = innerH / EMU_PER_PX;
2261
- let totalH = 0;
2262
- for (const para of paraData) {
2263
- let maxSize = defaultPt;
2264
- let totalChars = 0;
2265
- let cjkChars = 0;
2266
- for (const run of para.runs) {
2267
- if (run.sizePt > maxSize) maxSize = run.sizePt;
2268
- totalChars += run.text.length;
2269
- for (let i = 0; i < run.text.length; i++) {
2270
- const c = run.text.charCodeAt(i);
2271
- if (c >= 12352 && c <= 12447 || c >= 12448 && c <= 12543 || c >= 19968 && c <= 40959 || c >= 44032 && c <= 55215) cjkChars++;
2272
- }
2273
- }
2274
- if (totalChars === 0) totalChars = 1;
2275
- const cjkRatio = cjkChars / totalChars;
2276
- const glyphRatio = cjkRatio * 1 + (1 - cjkRatio) * AVG_GLYPH_W_RATIO;
2277
- const sizePx = maxSize * PX_PER_PT;
2278
- const charsPerLine = Math.max(1, Math.floor(innerWPx / Math.max(1, sizePx * glyphRatio)));
2279
- const lineCount = Math.max(1, Math.ceil(totalChars / charsPerLine));
2280
- totalH += sizePx * LINE_HEIGHT * lineCount;
2281
- }
2282
- if (totalH > innerHPx) autoFitScale = Math.max(.4, innerHPx / totalH);
2283
- }
2256
+ const lineHeightScale = 1 - (authoredAutofit?.lnSpcReduction ?? 0);
2284
2257
  LINE_HEIGHT * lineHeightScale;
2285
2258
  const numberLabels = Array.from({ length: paraData.length }, () => null);
2286
2259
  {
@@ -4616,6 +4589,6 @@ const auditTextLayout = (pres, options = {}) => {
4616
4589
  return issues;
4617
4590
  };
4618
4591
  //#endregion
4619
- export { MONO as a, TIMES as c, substituteFamily as d, AVG_GLYPH_W_RATIO$1 as i, defaultMeasurer as l, renderSlideSvg as n, SANS as o, ARIAL as r, SERIF as s, auditTextLayout as t, isCjk as u };
4592
+ export { MONO as a, TIMES as c, substituteFamily as d, AVG_GLYPH_W_RATIO as i, defaultMeasurer as l, renderSlideSvg as n, SANS as o, ARIAL as r, SERIF as s, auditTextLayout as t, isCjk as u };
4620
4593
 
4621
- //# sourceMappingURL=src-D95l1T9U.js.map
4594
+ //# sourceMappingURL=src-BMb2-vud.js.map