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

Support loading font assets in data URLs #8898

Merged
merged 2 commits into from Nov 28, 2022
Merged

Conversation

SuperSodaSea
Copy link
Member

@SuperSodaSea SuperSodaSea commented Nov 26, 2022

Support loading font assets in data URLs.

Closes #8891.

Description of Change

  • loadWebFont now support data URLs
    • Valid MIME types are font/ttf, font/otf, font/woff, font/woff2
  • packages/assets/src/loader/parsers/textures/utils/index.ts is moved to packages/assets/src/utils/checkExtension.ts
  • packages/assets/src/utils/checkDataUrl.ts is added to check if a URL is a data URL with the given MIME types
  • 🔥 Breaking Change: image/jpg is no longer considered as a valid MIME type for loadTextures (only image/jpeg should be valid)

Pre-Merge Checklist

  • Tests and/or benchmarks are included
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

@SuperSodaSea SuperSodaSea added this to the v7.1.0 milestone Nov 26, 2022
@bigtimebuddy
Copy link
Member

Awesome! Can you add a test for loading a font from data-uri?

@SuperSodaSea
Copy link
Member Author

Let me see if I can find a small font file for test...

@bigtimebuddy
Copy link
Member

icomoon.io is a good place to make a font with a single glyph

@SuperSodaSea
Copy link
Member Author

Test added!

@bigtimebuddy bigtimebuddy added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Nov 27, 2022
@bigtimebuddy
Copy link
Member

Nice work!

@bigtimebuddy bigtimebuddy merged commit 03bbc56 into dev Nov 28, 2022
@bigtimebuddy bigtimebuddy deleted the feature/font-data-url branch November 28, 2022 20:46
@ManHunterGroms
Copy link

@SuperSodaSea thank u so much!!! Nice work 👍

@pleek91
Copy link

pleek91 commented Oct 6, 2023

Is there any documentation for this? I'm unable to get this working. No errors, just a weird asset cached and Pixi.Text uses the standard serif font when rendering my text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for loading fonts in base64 format
4 participants