diff --git a/frontend/src/freetype-preview.js b/frontend/src/freetype-preview.js new file mode 100644 index 0000000..3b0d261 --- /dev/null +++ b/frontend/src/freetype-preview.js @@ -0,0 +1,185 @@ +// FreeType-in-wasm glyph rendering for Print.vue's font-candidate comparison card - draws each +// candidate through FreeType's own monochrome rasterizer (FT_LOAD_TARGET_MONO), the same rendering +// mode ptouch-print.c uses (see weblabel.js's TEXT_COVERAGE comment), rather than the canvas +// fillText-then-threshold approximation drawCandidateCell uses for its own cell. Experimental-only, +// same as the rest of that card - not part of the real label pipeline. See +// prototypes/freetype-wasm/ for the source this wasm build comes from. + +// Served unbundled from public/vendor/, same reasoning as libweblabel.js (see +// docs/implementation.md#libweblabel-served-unbundled) - its emscripten glue resolves +// freetype.wasm relative to its own import.meta.url, so both files must sit together, unhashed. +const FREETYPE_URL = "/vendor/freetype.js"; + +// A literal (or traceably-constant) specifier in `import()` - even dynamic, even @vite-ignore'd - +// gets resolved by Vite's dev server the moment it's requested, and it refuses to serve anything +// under public/ that way ("This file is in /public and will be copied as-is during build without +// going through the plugin transforms, and therefore should not be imported from source code. It +// can only be referenced via HTML tags."). A blob: URL re-export module sidesteps Vite's own +// import analysis (it never sees the blob's contents), but the app's CSP `script-src` allows +// `'unsafe-inline'`, not `blob:`, so a blob-URL module gets blocked at the browser level instead +// ("Failed to fetch dynamically imported module: blob:..."). An actual inline `