revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

fix(font-fallback): Fix hang when font is duplicated between system / Revery #980

Closed bryphe closed 4 years ago

bryphe commented 4 years ago

Issue: Having a font installed system-wide, and locally, could cause a hang in our font-fallback code.

Defect: This is actually the same root cause as https://github.com/revery-ui/revery/pull/974 - however, there is a case exposed that we weren't handling.

This logic:

        | Ok(fallbackFont)
          when
          Skia.Typeface.getUniqueID(fallbackFont.skiaFace)
          == Skia.Typeface.getUniqueID(font.skiaFace) 

wasn't quite sufficient. It turns out, in the case where a system font is installed that is the same as local font - we could run into a case where we have different unique ids but actually the same font. So in this case - this equality check would be false, because the unique ids are different... but actually, we were getting the same font, so we'd hit the same loop as in #974

Fix: Use Skia.Typeface.equal instead - this works as we expected for that condition

github-actions[bot] commented 4 years ago

I have updated your lock dirs and formatted the code. Please @bryphe pull the last commit before pushing any more changes.