Skip to content

fix: load bitmap font fail in browser #1383

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xdoer
Copy link

@xdoer xdoer commented May 10, 2025

Jimp supports loading fonts from URLs, but on the browser, I found that it performs abnormally under non localhost domains.

Then I found that there was a problem with the following line of code,

CharacterJimp.read(path.join(path.dirname(file), page))

and it will eventually construct a similar one https:/raw.githubusercontent.com/jimp-dev/jimp/main/plugins/plugin-print/fonts/open-sans/open-sans-16-black/open-sans-16-black.png

The link clearly shows that there is a missing '/' after 'https'.

@xdoer
Copy link
Author

xdoer commented May 10, 2025

I found it is interesting, I used the following code to test it separately in Node environment, browser environment under localhost URL, and https URL.

fetch("https:/raw.githubusercontent.com/jimp-dev/jimp/main/plugins/plugin-print/fonts/open-sans/open-sans-16-black/open-sans-16-black.png")

It can take effect in both Node environment and browser localhost address.
But it does not take effect in HTTPS address.

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

Successfully merging this pull request may close these issues.

1 participant