Open kimitsu opened 4 years ago
I went in a little bit of debugging and one thing I noticed is that this:
if (canvas) { fontEl.on('load', () => { this.drawDrawings(); if (options.settings) { ui.notifications.info(game.i18n.localize('ForienCustomFonts.Notifications.FontAdded'), {permanent: true}); } });
is usually run when canvas is still null. But I don't think that's really the cause of the issue: even after you redraw the text with proper fonts on one scene, the fonts are still broken for another scene.
The main issue is with calling this.drawDrawings() before the font has fully rendered.
If I move the if statement to after you append the font and then wait a few seconds after the font's onLoad has been called it works. It would be better if it listened for when the font was fully rendered. Here is my current workaround for those lines:
fontEl.attr('rel', `stylesheet`);
fontEl.attr('type', `text/css`);
fontEl.attr('media', `all`);
fontEl.attr('href', `https://fonts.googleapis.com/css2?${fonts}&display=swap`);
$('head').append(fontEl);
//if (canvas) {
fontEl.on('load', () => {
setTimeout(() => this.drawDrawings(), 10000);
if (options.settings) {
ui.notifications.info(game.i18n.localize('ForienCustomFonts.Notifications.FontAdded'), {permanent: true});
}
});
//}
Module Version: v0.1.0
Describe the bug Fonts do not render properly after reloading the page until the scene with text drawings is visited twice or the "Drawing Tools" button is clicked.
To Reproduce Steps to reproduce the behavior:
Expected behavior I kinda hoped it is possible to draw fonts properly for each scene whenever it is rendered. It would be weird to tell your players to switch scenes back and forth to render the proper fonts.
Browser: Electron, Chrome, Firefox
Foundry Version: 0.6.5
Game System: dnd5e 0.93
Additional context