mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.52k stars 238 forks source link

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

Closed aloisklink closed 2 months ago

aloisklink commented 5 months 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 4 months ago

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

aloisklink commented 2 months ago

This doesn't seem to be working for some reason, so I'm closing the PR.

I think maybe we might need to add an await document.fonts.ready in the Mermaid project instead, but I'm not 100%, since I can't figure out why sometimes the fonts still aren't loading :shrug: