@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 CHANGED
@@ -370,19 +370,48 @@ function resolveSeed(seed, fallback) {
370
370
  }
371
371
 
372
372
  // src/text.ts
373
- var NARROW = new Set("iIl.,:;'|!ftrj()[]{} ".split(""));
374
- var WIDE = new Set("mwMW@%".split(""));
375
- var CAPS = new Set("ABCDEFGHKNOQRSUVXYZ".split(""));
373
+ var ADVANCE = {
374
+ " ": 0.3,
375
+ i: 0.29,
376
+ j: 0.29,
377
+ l: 0.29,
378
+ I: 0.34,
379
+ ".": 0.3,
380
+ ",": 0.3,
381
+ ":": 0.3,
382
+ ";": 0.3,
383
+ "'": 0.24,
384
+ "!": 0.32,
385
+ "|": 0.26,
386
+ "(": 0.36,
387
+ ")": 0.36,
388
+ "[": 0.36,
389
+ "]": 0.36,
390
+ "{": 0.36,
391
+ "}": 0.36,
392
+ "-": 0.4,
393
+ "/": 0.4,
394
+ f: 0.38,
395
+ t: 0.4,
396
+ r: 0.44,
397
+ J: 0.5,
398
+ m: 0.92,
399
+ w: 0.86,
400
+ M: 0.98,
401
+ W: 0.98,
402
+ "@": 1,
403
+ "%": 0.95
404
+ };
376
405
  function estimateTextWidth(text, fontSize, tracking = 0) {
377
406
  let em = 0;
378
407
  for (const ch of text) {
379
- if (ch === " ") em += 0.3;
380
- else if (NARROW.has(ch)) em += 0.3;
381
- else if (WIDE.has(ch)) em += 0.92;
382
- else if (CAPS.has(ch)) em += 0.7;
383
- else em += 0.56;
408
+ const a = ADVANCE[ch];
409
+ if (a !== void 0) em += a;
410
+ else if (ch >= "A" && ch <= "Z") em += 0.72;
411
+ else if (ch >= "0" && ch <= "9") em += 0.58;
412
+ else em += 0.55;
384
413
  }
385
- return em * fontSize + Math.max(0, text.length - 1) * tracking;
414
+ return em * fontSize * 1.04 + Math.max(0, text.length - 1) * tracking;
386
415
  }
387
416
  function initials(name, max = 2) {
388
417
  const words = name.replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter(Boolean);
@@ -625,11 +654,12 @@ function fontImport(font) {
625
654
  function inkColor(spec) {
626
655
  return spec.background === "transparent" ? spec.palette.primary : spec.palette.on;
627
656
  }
628
- function wordmarkEl(spec, x, y, fontSize, anchor) {
657
+ function wordmarkEl(spec, x, y, fontSize, anchor, textLen) {
629
658
  const isLuxe = spec.font.mood.includes("luxe") || spec.font.mood.includes("elegant");
630
659
  const tracking = isLuxe ? fontSize * 0.04 : 0;
631
660
  const ls = tracking ? ` letter-spacing="${nn2(tracking)}"` : "";
632
- 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}>${esc(spec.name)}</text>`;
661
+ const tl = textLen ? ` textLength="${nn2(textLen)}" lengthAdjust="spacingAndGlyphs"` : "";
662
+ 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>`;
633
663
  }
634
664
  function background(spec, w, h, defsId) {
635
665
  if (spec.background === "transparent") return "";
@@ -657,7 +687,7 @@ function compose(spec, mark) {
657
687
  const w2 = Math.round(tw2 + pad * 2);
658
688
  const h2 = Math.round(fontSize2 * 1.5);
659
689
  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}"/>`;
660
- const body2 = tick + wordmarkEl(spec, pad, h2 / 2, fontSize2, "start");
690
+ const body2 = tick + wordmarkEl(spec, pad, h2 / 2, fontSize2, "start", tw2);
661
691
  return { svg: wrapSvg(spec, w2, h2, defs, body2), width: w2, height: h2 };
662
692
  }
663
693
  if (spec.layout === "icon-top" || spec.layout === "stacked") {
@@ -668,7 +698,7 @@ function compose(spec, mark) {
668
698
  const w2 = Math.round(Math.max(markSize2, tw2) + pad * 2);
669
699
  const h2 = Math.round(markSize2 + gap2 + fontSize2 * 1.3 + pad);
670
700
  const markX = (w2 - markSize2) / 2;
671
- const body2 = `<g transform="translate(${nn2(markX)} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, w2 / 2, pad + markSize2 + gap2 + fontSize2 * 0.5, fontSize2, "middle");
701
+ const body2 = `<g transform="translate(${nn2(markX)} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, w2 / 2, pad + markSize2 + gap2 + fontSize2 * 0.5, fontSize2, "middle", tw2);
672
702
  return { svg: wrapSvg(spec, w2, h2, defs, body2), width: w2, height: h2 };
673
703
  }
674
704
  const markSize = spec.size;
@@ -677,7 +707,7 @@ function compose(spec, mark) {
677
707
  const tw = estimateTextWidth(spec.name, fontSize, spec.font.mood.includes("luxe") ? fontSize * 0.04 : 0);
678
708
  const w = Math.round(markSize + gap + tw + pad * 2);
679
709
  const h = Math.round(markSize + pad * 2);
680
- const body = `<g transform="translate(${pad} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, pad + markSize + gap, h / 2, fontSize, "start");
710
+ const body = `<g transform="translate(${pad} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, pad + markSize + gap, h / 2, fontSize, "start", tw);
681
711
  return { svg: wrapSvg(spec, w, h, defs, body), width: w, height: h };
682
712
  }
683
713