From 199ef64a19d66f358ea93fdb0989b7a6a741351b Mon Sep 17 00:00:00 2001 From: scamiv <6170744+scamiv@users.noreply.github.com> Date: Sat, 9 May 2026 15:32:43 +0200 Subject: [PATCH] Address namelayer asset builder review nits Pass the pinned Twemoji font path to FontLibrary.use as an explicit path array, name the color-detection threshold used by atlas validation, and make SVG viewBox width/height extraction easier to read. Validated with the namelayer asset build and eslint for scripts/build-namelayer-assets.mjs. --- scripts/build-namelayer-assets.mjs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/build-namelayer-assets.mjs b/scripts/build-namelayer-assets.mjs index 5debd25ca..5f99ccb85 100644 --- a/scripts/build-namelayer-assets.mjs +++ b/scripts/build-namelayer-assets.mjs @@ -17,6 +17,7 @@ const emojiFontFamily = "NameLayerEmoji"; const emojiFontPath = require.resolve("twemoji-colr-font/twemoji.woff2"); const emojiFontSize = 96; const atlasFramePaddingRatio = 1 / 16; +const colorDetectionThreshold = 12; const fontSourceCandidates = [ "overpass-regular.otf", "overpass-regular.ttf", @@ -51,7 +52,7 @@ const iconSources = [ fs.mkdirSync(fontsDir, { recursive: true }); fs.mkdirSync(imagesDir, { recursive: true }); -FontLibrary.use(emojiFontFamily, emojiFontPath); +FontLibrary.use(emojiFontFamily, [emojiFontPath]); await buildMsdfFont(); await buildIconAtlas(); @@ -188,14 +189,12 @@ async function loadIconImage(sourcePath) { let svg = fs.readFileSync(sourcePath, "utf8"); if (!/]*\swidth=/i.test(svg) || !/]*\sheight=/i.test(svg)) { - const [, , , width, height] = - svg.match( - /viewBox=["']\s*([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)\s*["']/i, - ) ?? []; - svg = svg.replace( - / 12) { + if (Math.max(r, g, b) - Math.min(r, g, b) > colorDetectionThreshold) { colorfulPixels++; } }