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

feat(reason-skia): bind to `FontMetrics` char width functions #904

Closed zbaylin closed 4 years ago

zbaylin commented 4 years ago

This is a really small change that just adds two functions from FontMetrics: the average character width and the maximum character width. These functions make it easy to test if a loaded font is monospace through

FontMetrics.avgCharacterWidth(metrics) == FontMetrics.maxCharacaterWidth(metrics)

I tested this with Consolas and it worked. Fortunately it also worked with FiraCode (I was worried that maybe the ligatures would register strangely).