mooman219 / fontdue

The fastest font renderer in the world, written in pure rust.
Apache License 2.0
1.42k stars 70 forks source link

Font line metrics don't match character metrics #130

Open nic-hartley opened 1 year ago

nic-hartley commented 1 year ago

Heyo!

I'm trying to do some basic font rendering. As part of testing I started iterating over each character in Inconsolata and rendering each one. Just a couple of characters in, I tried to render (index 4), and it failed, seemingly because when rasterized it reaches higher than the ascent reported in the horizontal line metrics (char height=18.04, line ascent=17.18)

I'm not sure if my code is broken because I don't understand fonts, if the font has a slight bug, or if fontdue has an issue, so I've also attached the code I discovered this with and the TTF file (zipped to make GitHub happy). In brief:

So my questions are: Is my math just wrong? (If so, what's the right way to do this?) Otherwise, is this an issue with this font specifically, and what would be the nicest way to work around it?