web: Add defaultFonts and fontSources config options #13604
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Font sources
Each URL provided to this config option will try to eagerly load as a font source.
If the URL cannot load, it will be ignored (but a warning will print).
If the URL cannot parse into a valid font, it will be ignored (but a warning will print).
Right now it only supports fonts embeded inside SWFs. Any number of fonts can be inside a single SWF, but they need to be embedded with DefineFont2 and you need to make sure it's actually inside the swf (not stripped out by not being used).
A future PR will enable TTF/OTF support.
How to make a font SWF
1. Create a new document in Flash Pro or Animate, make sure it's ActionScript 3.
2. On the right hand side, click the Library tab and right click somewhere in the big empty space, and hit New Font
3. Set the name, pick the font and style from the list, and then choose which characters you want to embed. Only these characters will be available to use from this font.
4. In the ActionScript tab, check "Export for ActionScript" to make sure it stays inside the swf, and make sure it's "DF3" not "DF4".
5. Export the SWF. Make sure you export it as a SWF
6. Configure Ruffle to load that SWF as a font source.
Default fonts
There are 3 "default" device fonts in Flash.
_sans
,_serif
,_typewriter
. In Ruffle they are our Noto Sans fallback unless configured otherwise.To change that, set:
The font in question needs to be loaded with fontSources or it won't be found.