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

Can projects ship thier own fonts? #7

Open
boardend opened this issue Oct 24, 2023 · 2 comments
Open

Can projects ship thier own fonts? #7

boardend opened this issue Oct 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@boardend
Copy link
Collaborator

This question came up by @andreasneumann while testing out some own projects. See the notes in the Qt6 WebAssembly reference for context.

A real cool solution would be the proposed Local Font Access API by Google. Qt did some integration, but the API is only available in Chromium based browsers and behind a flag for the time of writing. So probably not the solution for qgis-js.

What we could do is to scan the uploaded folder for any known/supported font file extensions and add those via addApplicationFontFromData to the runtime.

@boardend boardend added the enhancement New feature or request label Oct 24, 2023
@wonder-sk
Copy link
Member

I don't think there's an official way to have fonts embedded in a project. But there is support in QGIS settings (see in QGIS options dialog > Fonts) to have user fonts defined (in addition to what is loaded by default in QFontDatabase) and preferred font replacements for missing fonts. In QGIS core there's QgsApplication::fontManager() that returns QgsFontManager to deal with that.

Indeed I would go with something non-standard like you suggest - maybe check for "fonts" subdirectory of the project and try to load any files from there to QFontDatabase...

@andreasneumann
Copy link
Member

What we could do is to scan the uploaded folder for any known/supported font file extensions and add those via addApplicationFontFromData to the runtime.

That sounds good to me. Should we go for the separate "fonts" subdirectory solution? Any ttf or otf font in there would be added?

For the long run I think it would be great if the whole setup would allow for inclusion of extra fonts. I can imagine that many projects provided from the same organizations would standardize around the same standard fonts - an in such case it would be nice if many projects could share the same fonts.

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

No branches or pull requests

3 participants