@clypra-studio/engine 1.5.0 → 1.6.0
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/{chunk-Q7XYDP4X.js → chunk-V5D5SJPO.js} +57 -9
- package/dist/chunk-V5D5SJPO.js.map +1 -0
- package/dist/{index-DrzRbR7G.d.cts → index-DKJxLj6P.d.cts} +1 -1
- package/dist/{index-WsvrOpAy.d.cts → index-DbojK0dC.d.ts} +4 -2
- package/dist/{index-B1lFl4p2.d.ts → index-QSvA1MMy.d.ts} +1 -1
- package/dist/{index-Cpps1DKP.d.ts → index-l2Qgw6Dt.d.cts} +4 -2
- package/dist/index.cjs +545 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -52
- package/dist/index.d.ts +68 -52
- package/dist/index.js +516 -27
- package/dist/index.js.map +1 -1
- package/dist/rendering/index.cjs +57 -8
- package/dist/rendering/index.cjs.map +1 -1
- package/dist/rendering/index.d.cts +2 -2
- package/dist/rendering/index.d.ts +2 -2
- package/dist/rendering/index.js +3 -1
- package/dist/textEffects/index.d.cts +2 -2
- package/dist/textEffects/index.d.ts +2 -2
- package/dist/{types-IYwXGYkB.d.cts → types-CoshNXmU.d.cts} +2 -1
- package/dist/{types-IYwXGYkB.d.ts → types-CoshNXmU.d.ts} +2 -1
- package/package.json +1 -1
- package/dist/chunk-Q7XYDP4X.js.map +0 -1
package/dist/rendering/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(rendering_exports, {
|
|
|
25
25
|
renderCanonicalToCanvas: () => renderCanonicalToCanvas,
|
|
26
26
|
renderTextEffectToCanvas: () => renderTextEffectToCanvas,
|
|
27
27
|
renderTextTemplateToCanvas: () => renderTextTemplateToCanvas,
|
|
28
|
+
resolveTemplateFontFamily: () => resolveTemplateFontFamily,
|
|
28
29
|
resolveTextTemplateArtifact: () => resolveTextTemplateArtifact
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(rendering_exports);
|
|
@@ -2707,7 +2708,8 @@ function legacyLayerToNode(layer2, index) {
|
|
|
2707
2708
|
style: {
|
|
2708
2709
|
fontFamily: resolveStringProperty(text?.fontFamily, "Inter Variable"),
|
|
2709
2710
|
fontSize: resolveNumericProperty(text?.fontSize, 48),
|
|
2710
|
-
fontWeight:
|
|
2711
|
+
fontWeight: resolveAnimatableValue(text?.fontWeight, 400),
|
|
2712
|
+
fontStyle: text?.fontStyle === "italic" ? "italic" : "normal",
|
|
2711
2713
|
textColor: resolveStringProperty(
|
|
2712
2714
|
text?.color ?? text?.textColor,
|
|
2713
2715
|
"#FFFFFF"
|
|
@@ -3509,13 +3511,57 @@ function letterSpacedText(ctx, text, x, y, maxWidth, letterSpacing) {
|
|
|
3509
3511
|
}
|
|
3510
3512
|
ctx.textAlign = align;
|
|
3511
3513
|
}
|
|
3514
|
+
var FONT_ALIAS_MAP = {
|
|
3515
|
+
"inter": "Inter Variable",
|
|
3516
|
+
"inter variable": "Inter Variable",
|
|
3517
|
+
"outfit": "Outfit Variable",
|
|
3518
|
+
"outfit variable": "Outfit Variable",
|
|
3519
|
+
"playfair display": "Playfair Display Variable",
|
|
3520
|
+
"playfair display variable": "Playfair Display Variable",
|
|
3521
|
+
"montserrat": "Montserrat Variable",
|
|
3522
|
+
"montserrat variable": "Montserrat Variable",
|
|
3523
|
+
"roboto": "Roboto Variable",
|
|
3524
|
+
"roboto variable": "Roboto Variable",
|
|
3525
|
+
"roboto condensed": "Roboto Condensed Variable",
|
|
3526
|
+
"roboto condensed variable": "Roboto Condensed Variable",
|
|
3527
|
+
"raleway": "Raleway Variable",
|
|
3528
|
+
"raleway variable": "Raleway Variable",
|
|
3529
|
+
"space grotesk": "Space Grotesk Variable",
|
|
3530
|
+
"space grotesk variable": "Space Grotesk Variable",
|
|
3531
|
+
"nunito": "Nunito Variable",
|
|
3532
|
+
"nunito variable": "Nunito Variable",
|
|
3533
|
+
"open sans": "Open Sans Variable",
|
|
3534
|
+
"open sans variable": "Open Sans Variable",
|
|
3535
|
+
"oswald": "Oswald Variable",
|
|
3536
|
+
"oswald variable": "Oswald Variable",
|
|
3537
|
+
"geist": "Geist Variable",
|
|
3538
|
+
"geist variable": "Geist Variable",
|
|
3539
|
+
"dancing script": "Dancing Script Variable",
|
|
3540
|
+
"dancing script variable": "Dancing Script Variable"
|
|
3541
|
+
};
|
|
3542
|
+
function resolveTemplateFontFamily(family) {
|
|
3543
|
+
if (!family) return "sans-serif";
|
|
3544
|
+
const clean = String(family).trim().replace(/^["']|["']$/g, "");
|
|
3545
|
+
const lower = clean.toLowerCase();
|
|
3546
|
+
return FONT_ALIAS_MAP[lower] || clean;
|
|
3547
|
+
}
|
|
3548
|
+
function constructFontStack(fontStyle, fontWeight, fontSize, rawFamily) {
|
|
3549
|
+
const canonical = resolveTemplateFontFamily(rawFamily);
|
|
3550
|
+
const cleanRaw = String(rawFamily || "").trim().replace(/^["']|["']$/g, "");
|
|
3551
|
+
const style = fontStyle === "italic" ? "italic" : "normal";
|
|
3552
|
+
const weight = fontWeight ?? 400;
|
|
3553
|
+
if (canonical && cleanRaw && canonical.toLowerCase() !== cleanRaw.toLowerCase()) {
|
|
3554
|
+
return `${style} ${weight} ${fontSize}px "${canonical}", "${cleanRaw}", sans-serif`;
|
|
3555
|
+
}
|
|
3556
|
+
return `${style} ${weight} ${fontSize}px "${canonical || cleanRaw || "sans-serif"}", sans-serif`;
|
|
3557
|
+
}
|
|
3512
3558
|
function drawTextLayer(ctx, layer2, style) {
|
|
3513
3559
|
const text = layer2.text ?? "";
|
|
3514
3560
|
const fontSize = finite2(style.fontSize, 48);
|
|
3515
3561
|
const fontWeight = style.fontWeight ?? 400;
|
|
3516
|
-
const fontStyle = "normal";
|
|
3517
|
-
const
|
|
3518
|
-
ctx.font =
|
|
3562
|
+
const fontStyle = style.fontStyle || "normal";
|
|
3563
|
+
const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
|
|
3564
|
+
ctx.font = constructFontStack(fontStyle, fontWeight, fontSize, rawFamily);
|
|
3519
3565
|
ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
|
|
3520
3566
|
ctx.textAlign = style.textAlign ?? "left";
|
|
3521
3567
|
ctx.textBaseline = style.verticalAlign === "top" ? "top" : style.verticalAlign === "bottom" ? "bottom" : "middle";
|
|
@@ -3532,8 +3578,10 @@ function drawTextLayer(ctx, layer2, style) {
|
|
|
3532
3578
|
function drawSplitTextLayer(ctx, layer2, style, animator, progress) {
|
|
3533
3579
|
const text = layer2.text ?? "";
|
|
3534
3580
|
const fontSize = finite2(style.fontSize, 48);
|
|
3535
|
-
const
|
|
3536
|
-
|
|
3581
|
+
const fontWeight = style.fontWeight ?? 400;
|
|
3582
|
+
const fontStyle = style.fontStyle || "normal";
|
|
3583
|
+
const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
|
|
3584
|
+
ctx.font = constructFontStack(fontStyle, fontWeight, fontSize, rawFamily);
|
|
3537
3585
|
ctx.textBaseline = "middle";
|
|
3538
3586
|
ctx.textAlign = "left";
|
|
3539
3587
|
ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
|
|
@@ -3623,9 +3671,9 @@ function renderTextTemplateToCanvas(ctx, input) {
|
|
|
3623
3671
|
// Measure with the exact Canvas context that will draw the layer. This
|
|
3624
3672
|
// makes auto-sized nodes use loaded font metrics instead of a fixed box.
|
|
3625
3673
|
measureText: (text, style) => {
|
|
3626
|
-
const
|
|
3674
|
+
const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
|
|
3627
3675
|
ctx.save();
|
|
3628
|
-
ctx.font =
|
|
3676
|
+
ctx.font = constructFontStack(style.fontStyle, style.fontWeight, finite2(style.fontSize, 48), rawFamily);
|
|
3629
3677
|
const width = ctx.measureText(text).width + Math.max(0, text.length - 1) * finite2(style.letterSpacing, 0);
|
|
3630
3678
|
ctx.restore();
|
|
3631
3679
|
return { width };
|
|
@@ -3689,6 +3737,7 @@ function renderCanonicalToCanvas(ctx, input) {
|
|
|
3689
3737
|
renderCanonicalToCanvas,
|
|
3690
3738
|
renderTextEffectToCanvas,
|
|
3691
3739
|
renderTextTemplateToCanvas,
|
|
3740
|
+
resolveTemplateFontFamily,
|
|
3692
3741
|
resolveTextTemplateArtifact
|
|
3693
3742
|
});
|
|
3694
3743
|
//# sourceMappingURL=index.cjs.map
|