Merge pixi-webfont-loader with the @pixi/Text package #7682
miltoncandelero
started this conversation in
RFC
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context: Pixi doesn't have a way to load fonts to be displayed with the
Text
object. If a user adds their own font to the HTML document and doesn't "warm it up" with a hidden text, you run the risk of getting text without style since most browsers lazy-load the fonts.Read more: https://en.wikipedia.org/wiki/Flash_of_unstyled_content
To fix this problem I made a webfont loader plugin that leverages FontFaceObserver to wait for the fonts to be ready.
I was working on the next version of my plugin and I found that the FontFace browser API is quite supported
I've managed to load fonts from
.css
stylesheets and directly fromttf
,otf
,woff
, andwoff2
files. (eot
are too ancient andsvg
fonts are getting deprecated so I didn't bother).I even found a way to remove the dependency on https://github.com/bramstein/fontfaceobserver at the cost of IE support (https://caniuse.com/mdn-api_fontface)
Does it make sense to keep a Fonts package separate from the Text package?
Ramifications: The text package would get a new peerDependency on Loader
Precedence: BitmapText includes it's Loader for BitmapFonts but Text doesn't include one for regular fonts.
Side question: Should we keep the dependency on FontFaceObserver to be compatible with internet explorer or is it the user's job to polyfill?
Beta Was this translation helpful? Give feedback.
All reactions