@lacspace/logo 1.2.1 → 1.2.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/index.cjs +44 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -368,19 +368,48 @@ function resolveSeed(seed, fallback) {
|
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
// src/text.ts
|
|
371
|
-
var
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
var ADVANCE = {
|
|
372
|
+
" ": 0.3,
|
|
373
|
+
i: 0.29,
|
|
374
|
+
j: 0.29,
|
|
375
|
+
l: 0.29,
|
|
376
|
+
I: 0.34,
|
|
377
|
+
".": 0.3,
|
|
378
|
+
",": 0.3,
|
|
379
|
+
":": 0.3,
|
|
380
|
+
";": 0.3,
|
|
381
|
+
"'": 0.24,
|
|
382
|
+
"!": 0.32,
|
|
383
|
+
"|": 0.26,
|
|
384
|
+
"(": 0.36,
|
|
385
|
+
")": 0.36,
|
|
386
|
+
"[": 0.36,
|
|
387
|
+
"]": 0.36,
|
|
388
|
+
"{": 0.36,
|
|
389
|
+
"}": 0.36,
|
|
390
|
+
"-": 0.4,
|
|
391
|
+
"/": 0.4,
|
|
392
|
+
f: 0.38,
|
|
393
|
+
t: 0.4,
|
|
394
|
+
r: 0.44,
|
|
395
|
+
J: 0.5,
|
|
396
|
+
m: 0.92,
|
|
397
|
+
w: 0.86,
|
|
398
|
+
M: 0.98,
|
|
399
|
+
W: 0.98,
|
|
400
|
+
"@": 1,
|
|
401
|
+
"%": 0.95
|
|
402
|
+
};
|
|
374
403
|
function estimateTextWidth(text, fontSize, tracking = 0) {
|
|
375
404
|
let em = 0;
|
|
376
405
|
for (const ch of text) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
else if (
|
|
380
|
-
else if (
|
|
381
|
-
else em += 0.
|
|
406
|
+
const a = ADVANCE[ch];
|
|
407
|
+
if (a !== void 0) em += a;
|
|
408
|
+
else if (ch >= "A" && ch <= "Z") em += 0.72;
|
|
409
|
+
else if (ch >= "0" && ch <= "9") em += 0.58;
|
|
410
|
+
else em += 0.55;
|
|
382
411
|
}
|
|
383
|
-
return em * fontSize + Math.max(0, text.length - 1) * tracking;
|
|
412
|
+
return em * fontSize * 1.04 + Math.max(0, text.length - 1) * tracking;
|
|
384
413
|
}
|
|
385
414
|
function initials(name, max = 2) {
|
|
386
415
|
const words = name.replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter(Boolean);
|
|
@@ -623,11 +652,12 @@ function fontImport(font) {
|
|
|
623
652
|
function inkColor(spec) {
|
|
624
653
|
return spec.background === "transparent" ? spec.palette.primary : spec.palette.on;
|
|
625
654
|
}
|
|
626
|
-
function wordmarkEl(spec, x, y, fontSize, anchor) {
|
|
655
|
+
function wordmarkEl(spec, x, y, fontSize, anchor, textLen) {
|
|
627
656
|
const isLuxe = spec.font.mood.includes("luxe") || spec.font.mood.includes("elegant");
|
|
628
657
|
const tracking = isLuxe ? fontSize * 0.04 : 0;
|
|
629
658
|
const ls = tracking ? ` letter-spacing="${nn2(tracking)}"` : "";
|
|
630
|
-
|
|
659
|
+
const tl = textLen ? ` textLength="${nn2(textLen)}" lengthAdjust="spacingAndGlyphs"` : "";
|
|
660
|
+
return `<text x="${nn2(x)}" y="${nn2(y)}" font-family="${spec.font.stack}" font-weight="${spec.font.weight}" font-size="${nn2(fontSize)}" fill="${inkColor(spec)}" text-anchor="${anchor}" dominant-baseline="middle"${ls}${tl}>${esc(spec.name)}</text>`;
|
|
631
661
|
}
|
|
632
662
|
function background(spec, w, h, defsId) {
|
|
633
663
|
if (spec.background === "transparent") return "";
|
|
@@ -655,7 +685,7 @@ function compose(spec, mark) {
|
|
|
655
685
|
const w2 = Math.round(tw2 + pad * 2);
|
|
656
686
|
const h2 = Math.round(fontSize2 * 1.5);
|
|
657
687
|
const tick = `<rect x="${pad - Math.round(spec.size * 0.03)}" y="${Math.round(h2 / 2 - fontSize2 * 0.36)}" width="${Math.round(spec.size * 0.014)}" height="${Math.round(fontSize2 * 0.72)}" rx="2" fill="${spec.palette.primary}"/>`;
|
|
658
|
-
const body2 = tick + wordmarkEl(spec, pad, h2 / 2, fontSize2, "start");
|
|
688
|
+
const body2 = tick + wordmarkEl(spec, pad, h2 / 2, fontSize2, "start", tw2);
|
|
659
689
|
return { svg: wrapSvg(spec, w2, h2, defs, body2), width: w2, height: h2 };
|
|
660
690
|
}
|
|
661
691
|
if (spec.layout === "icon-top" || spec.layout === "stacked") {
|
|
@@ -666,7 +696,7 @@ function compose(spec, mark) {
|
|
|
666
696
|
const w2 = Math.round(Math.max(markSize2, tw2) + pad * 2);
|
|
667
697
|
const h2 = Math.round(markSize2 + gap2 + fontSize2 * 1.3 + pad);
|
|
668
698
|
const markX = (w2 - markSize2) / 2;
|
|
669
|
-
const body2 = `<g transform="translate(${nn2(markX)} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, w2 / 2, pad + markSize2 + gap2 + fontSize2 * 0.5, fontSize2, "middle");
|
|
699
|
+
const body2 = `<g transform="translate(${nn2(markX)} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, w2 / 2, pad + markSize2 + gap2 + fontSize2 * 0.5, fontSize2, "middle", tw2);
|
|
670
700
|
return { svg: wrapSvg(spec, w2, h2, defs, body2), width: w2, height: h2 };
|
|
671
701
|
}
|
|
672
702
|
const markSize = spec.size;
|
|
@@ -675,7 +705,7 @@ function compose(spec, mark) {
|
|
|
675
705
|
const tw = estimateTextWidth(spec.name, fontSize, spec.font.mood.includes("luxe") ? fontSize * 0.04 : 0);
|
|
676
706
|
const w = Math.round(markSize + gap + tw + pad * 2);
|
|
677
707
|
const h = Math.round(markSize + pad * 2);
|
|
678
|
-
const body = `<g transform="translate(${pad} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, pad + markSize + gap, h / 2, fontSize, "start");
|
|
708
|
+
const body = `<g transform="translate(${pad} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, pad + markSize + gap, h / 2, fontSize, "start", tw);
|
|
679
709
|
return { svg: wrapSvg(spec, w, h, defs, body), width: w, height: h };
|
|
680
710
|
}
|
|
681
711
|
|