Myriad-Dreamin / typst.ts

Run Typst in JavaScriptWorld.
https://myriad-dreamin.github.io/typst.ts
Apache License 2.0
423 stars 25 forks source link

Loading custom fonts `build_raw_font feature is not enabled` #600

Open hat618 opened 1 week ago

hat618 commented 1 week ago

Thanks for this package; it's worked a charm to date. I am trying to load custom fonts for rendering in the browser. Following the commentary listed in the documentation and previous issues (#514), the general consensus will be to use the node compiler for future reference. But in the meantime, what is the correct way to load remote fonts? I can't seem to get it working.

Is your feature request related to a problem? Please describe. The functionality to load custom fonts (both working for font families and individual fonts), just seems to be missing either an example of how it all ties together when attempting to render these in the browser with preloadSystemFonts.

Describe the solution you'd like An integrated working example of the beforeBuild and preloadSystemFonts working for the latest version of the typst lib.

Describe alternatives you've considered See below for an attempt to do this so far.

Additional context



![image](https://github.com/user-attachments/assets/3900ab71-fc84-4781-a7d2-5a81e5fd93d6)
Myriad-Dreamin commented 1 week ago

Hi, thank you for taking time to submit issue.

For preloadSystemFonts, the feature it depends (queryLocalFonts() function) seems not be very widely deployed on modern browsers so I suggest not to use it in production.

For preloadRemoteFonts, since I'm not knowing whether we have problem when loading data from google fonts, I would like to experiment it by myself a bit and answer you. I'm currently busy with publishing tinymist and typst.ts so I may go back in a few days.

After experiements, I would like to add some documentation to help all people in future.

If you find I forget it in next days, you can @me to remind me.

hat618 commented 1 day ago

@Myriad-Dreamin bumping this as mentioned (and thanks for the helpful response so far).