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(shaping): Hang on non-printable ASCII characters #974

Closed bryphe closed 4 years ago

bryphe commented 4 years ago

Issue: When a string with a non-printable ASCII character (like CR - ascii 10 or LF - ascii code 13) was passed to be shaped, it would hit an infinite loop.

Defect: The shaping code would resolve that there was no glyph available, and then enter the fallback code path - fallbackFor. The problem, though, is in these cases, we'd return the same font - and then we'd try and resolve the hole using the 'new' (really, the same) font - endlessly.

There also seemed to be an off-by-one issue in resolveHole that caused an additional glyph to be surfaced in this case.

Fix: In the case where the fallback font is the same as the source font, resolving the hole isn't going to help, so detect that case and handle it the same as the error case.

Test Impact:

bryphe commented 4 years ago

Thanks for reviewing @zbaylin !