Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fetching font from URL on wasm #28

Closed
Dimchikkk opened this issue Sep 12, 2023 · 3 comments
Closed

Allow fetching font from URL on wasm #28

Dimchikkk opened this issue Sep 12, 2023 · 3 comments

Comments

@Dimchikkk
Copy link
Owner

Something like https://github.com/johanhelsing/bevy_web_asset/blob/main/src/web_asset_io.rs#L26

  1. Fetch font from web location
  2. Supply to plugin

This will allow to use emoji fonts on wasm without bloating the binary size.

@bytemunch
Copy link
Collaborator

I worry this may be out of scope for the editor plugin, could be left as an exercise for the user? Then again it's your plugin, you know scope better than I ;)

Bevy can already load from a local web location (assets folder next to .wasm I think?) with the normal AssetServer though because we load fonts as bytes I'm fairly sure we can use any GET request and use the result straight away. The concern is with adding dependencies to manage the web requests, and there's a lot of options for them. Simplest for Bevy seems to be https://github.com/TotalKrill/bevy_mod_reqwest , and from experience reqwest on it's own is pretty friendly. But adding deps will increase bin size somewhat.

The next issue is one of timing. Web requests can take a long time, and I don't know what happens if we request to use a font that isn't loaded yet and load it to the fontdb later, will it un-fallback or does the editor need reconfiguring? And then there's async to think on too.

Maybe when Assets V2 drops it might be an idea to work on all font loading, and the PR mentions internet loading.

Sorry for rambling lol. I do think webfonts would be sweet, but wanna get the approach right.

@Dimchikkk
Copy link
Owner Author

Dimchikkk commented Sep 13, 2023

Yeah, I agree that it should be implemented upstream... like in velo that uses plugin rather than in plugin.

@Dimchikkk
Copy link
Owner Author

Dimchikkk commented Sep 13, 2023

Web requests can take a long time, and I don't know what happens if we request to use a font that isn't loaded yet and load it to the fontdb later, will it un-fallback or does the editor need reconfiguring?

If it's implemented upstream in an app that uses plugin - app may have just 2 states: loading_assets (including font) and main_app_state that enabled once all assets are loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants