@pixldocs/canvas-renderer 0.5.55 → 0.5.56
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.cjs +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5289,6 +5289,10 @@ function createText(element) {
|
|
|
5289
5289
|
const splitByGrapheme = overflowPolicy === "auto-shrink" ? false : element.splitByGrapheme ?? element.wordWrap === "break-word";
|
|
5290
5290
|
if (overflowPolicy === "auto-shrink") {
|
|
5291
5291
|
const explicitLineCount = Math.max(1, text.split("\n").length);
|
|
5292
|
+
const debugAutoShrink = typeof window !== "undefined" && window.__pixldocsDebugAutoShrink === true;
|
|
5293
|
+
const startFontSize = fontSize;
|
|
5294
|
+
let breakReason = "min-font-size-reached";
|
|
5295
|
+
let lastIter = null;
|
|
5292
5296
|
while (fontSize > 1) {
|
|
5293
5297
|
const testTextbox = new fabric__namespace.Textbox(text, {
|
|
5294
5298
|
width: fixedWidth,
|
|
@@ -5310,11 +5314,47 @@ function createText(element) {
|
|
|
5310
5314
|
const lineWidths = testTextbox.__lineWidths;
|
|
5311
5315
|
const maxLineWidth = lineWidths && lineWidths.length > 0 ? Math.max(...lineWidths) : 0;
|
|
5312
5316
|
const fitsWidth = !widthDidGrow && maxLineWidth <= fixedWidth + 1;
|
|
5317
|
+
if (debugAutoShrink) {
|
|
5318
|
+
lastIter = {
|
|
5319
|
+
fontSize,
|
|
5320
|
+
renderedLineCount,
|
|
5321
|
+
explicitLineCount,
|
|
5322
|
+
textHeight,
|
|
5323
|
+
maxLineWidth,
|
|
5324
|
+
fixedWidth,
|
|
5325
|
+
widthDidGrow,
|
|
5326
|
+
hasNoImplicitWrap,
|
|
5327
|
+
fitsHeight,
|
|
5328
|
+
fitsWidth
|
|
5329
|
+
};
|
|
5330
|
+
}
|
|
5313
5331
|
if (hasNoImplicitWrap && fitsHeight && fitsWidth) {
|
|
5332
|
+
breakReason = "fits";
|
|
5314
5333
|
break;
|
|
5315
5334
|
}
|
|
5316
5335
|
fontSize--;
|
|
5317
5336
|
}
|
|
5337
|
+
if (debugAutoShrink) {
|
|
5338
|
+
console.log("[auto-shrink][diag]", {
|
|
5339
|
+
id: element.id,
|
|
5340
|
+
name: element.name,
|
|
5341
|
+
text,
|
|
5342
|
+
fontFamily: element.fontFamily,
|
|
5343
|
+
fontWeight: element.fontWeight,
|
|
5344
|
+
elementWidth: element.width,
|
|
5345
|
+
elementHeight: element.height,
|
|
5346
|
+
scaleX: element.scaleX ?? 1,
|
|
5347
|
+
scaleY: element.scaleY ?? 1,
|
|
5348
|
+
fixedWidth,
|
|
5349
|
+
baseHeight,
|
|
5350
|
+
startFontSize,
|
|
5351
|
+
finalFontSize: fontSize,
|
|
5352
|
+
breakReason,
|
|
5353
|
+
lastIter,
|
|
5354
|
+
fontCheckRegular: typeof document !== "undefined" && document.fonts ? document.fonts.check(`16px "${element.fontFamily || "Open Sans"}"`) : null,
|
|
5355
|
+
fontCheckBold: typeof document !== "undefined" && document.fonts ? document.fonts.check(`bold 16px "${element.fontFamily || "Open Sans"}"`) : null
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
5318
5358
|
}
|
|
5319
5359
|
if (overflowPolicy === "max-lines-ellipsis") {
|
|
5320
5360
|
const originalText = element.text || "Text";
|
|
@@ -15480,6 +15520,11 @@ async function warmTemplateFromForm(options) {
|
|
|
15480
15520
|
if (signal == null ? void 0 : signal.aborted) return;
|
|
15481
15521
|
await warmResolvedTemplateForPreview(resolved.config, { signal, imageProxyUrl });
|
|
15482
15522
|
}
|
|
15523
|
+
function setAutoShrinkDebug(enabled) {
|
|
15524
|
+
if (typeof window !== "undefined") {
|
|
15525
|
+
window.__pixldocsDebugAutoShrink = !!enabled;
|
|
15526
|
+
}
|
|
15527
|
+
}
|
|
15483
15528
|
exports.FONT_FALLBACK_DEVANAGARI = FONT_FALLBACK_DEVANAGARI;
|
|
15484
15529
|
exports.FONT_FALLBACK_SYMBOLS = FONT_FALLBACK_SYMBOLS;
|
|
15485
15530
|
exports.FONT_FILES = FONT_FILES;
|
|
@@ -15507,6 +15552,7 @@ exports.resolveFontWeight = resolveFontWeight;
|
|
|
15507
15552
|
exports.resolveFromForm = resolveFromForm;
|
|
15508
15553
|
exports.resolveTemplateData = resolveTemplateData;
|
|
15509
15554
|
exports.rewriteSvgFontsForJsPDF = rewriteSvgFontsForJsPDF;
|
|
15555
|
+
exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
15510
15556
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
15511
15557
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
15512
15558
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|