mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.2k stars 207 forks source link

fix: add some checks for FontAwesome fonts to load #700

Open aloisklink opened 3 weeks ago

aloisklink commented 3 weeks ago

:bookmark_tabs: Summary

Sometimes, await Promise.all(Array.from(document.fonts, (font) => font.load())) (added in https://github.com/mermaid-js/mermaid-cli/commit/c179bc1f7ad0066f331217cb2dbea0b8aa9a1d1c) doesn't actually wait for fonts to load.

I can't seem to reproduce this on my computer, but it does occasionally happen in GitHub CI (I've seen it happen with Percy).

I'm not exactly sure why this is, (maybe it doesn't include actually applying the fonts?), but just to be safe, I've added some explicit await document.fonts.read checks, and even added a warning if Font Awesome is not loaded, and maybe that might help?

flowchart3-run

:straight_ruler: Design Decisions

N/A

:clipboard: Tasks

Make sure you

MindaugasLaganeckas commented 1 week ago

Awesome! Please, merge, when you are ready! :)