diff --git a/esbuild.app.mjs b/esbuild.app.mjs index e05c23f..f0efd88 100644 --- a/esbuild.app.mjs +++ b/esbuild.app.mjs @@ -28,7 +28,12 @@ export default (opt_options) => { // if not specified, this plugin uses ESBuild.build outdir/outfile options as base path. resolveFrom: 'cwd', assets: { - from: ['./public/*.png', './public/*.ico', './public/*.webmanifest'], + from: [ + './public/*.png', + './public/*.ico', + './public/*.webmanifest', + './public/*.ttf', + ], to: ['./dist'], }, watch: true, diff --git a/public/LiberationSans-Regular.ttf b/public/LiberationSans-Regular.ttf new file mode 100644 index 0000000..626dd93 Binary files /dev/null and b/public/LiberationSans-Regular.ttf differ diff --git a/src/worker/openSCAD.ts b/src/worker/openSCAD.ts index 6952ddd..dce4c64 100644 --- a/src/worker/openSCAD.ts +++ b/src/worker/openSCAD.ts @@ -10,6 +10,8 @@ const fontsConf = ` `; +let defaultFont; + class OpenSCADWrapper { log = { stdErr: [], @@ -24,6 +26,10 @@ class OpenSCADWrapper { print: this.logger('stdOut'), printErr: this.logger('stdErr'), }); + if (!defaultFont) { + const fontResponse = await fetch('/LiberationSans-Regular.ttf'); + defaultFont = await fontResponse.arrayBuffer(); + } // Make sure the root directory exists this.createDirectoryRecusive(instance, 'fonts'); @@ -31,6 +37,12 @@ class OpenSCADWrapper { // Write the font.conf file instance.FS.writeFile('/fonts/fonts.conf', fontsConf); + // Add default font + instance.FS.writeFile( + 'fonts/LiberationSans-Regular.ttf', + new Int8Array(defaultFont) + ); + for (const file of this.files) { // Make sure the directory of the file exists const path = file.path.split('/');