// Renders label.js's bitmap-style FONT_TIERS entries (Terminus/Pixelon/Chava/Silkscreen) through // libfreetype-wasm's own monochrome rasterizer (FT_LOAD_TARGET_MONO) instead of canvas fillText. // fillText is always anti-aliased, however carefully its size/position are snapped to the pixel // grid - Canvas 2D has no monochrome/hinted-bitmap text mode - and that soft edge becomes // stray/missing pixels once canvasToBitmap's hard threshold runs on it. Rendering through // FreeType's own 1-bit rasterizer and blitting the result at integer pixel offsets removes both // problems at the source instead of trying to compensate for them after the fact. See // prototypes/freetype-wasm/README.md and docs/implementation.md#pixel-font-selection. import terminusFontUrl from "@/assets/fonts/pixel/Terminus.ttf?url"; import pixelonFontUrl from "@/assets/fonts/pixel/Pixelon.ttf?url"; import chavaFontUrl from "@/assets/fonts/pixel/Chava.ttf?url"; import silkscreenFontUrl from "@/assets/fonts/pixel/Silkscreen.ttf?url"; // Every family fontTierFor (label.js) can pick with `pixel: true` - fetched once by // preloadPixelFontRenderer, not lazily, so a first draw never races the font's own fetch. const FONT_URLS = { Terminus: terminusFontUrl, Pixelon: pixelonFontUrl, Chava: chavaFontUrl, Silkscreen: silkscreenFontUrl, }; // Served unbundled so its wasm sibling stays resolvable. See docs/implementation.md#libweblabel-served-unbundled. const FREETYPE_URL = "/vendor/freetype.js"; // Vite refuses to import anything under public/ from source (see the long comment this is copied // from, originally in freetype-preview.js) - an inline `