You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
I'm using line_metrics.ascent.ceil() as usize + line_metrics.descent.floor() as usize to decide how tall each row is.
Then, when I rasterize, I'm doing line_metrics.ascent.ceil() as usize - char_metrics.ymin + char_metrics.height (with some casts to ensure the math can be done) to get the number of rows between the top of the rasterized buffer and the top of the line.
But that math is failing -- again, as far as I can tell, because ymin == 0, and the character's rasterized height is greater than the line's ascent.
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?
The text was updated successfully, but these errors were encountered:
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 theascent
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:
line_metrics.ascent.ceil() as usize + line_metrics.descent.floor() as usize
to decide how tall each row is.line_metrics.ascent.ceil() as usize - char_metrics.ymin + char_metrics.height
(with some casts to ensure the math can be done) to get the number of rows between the top of the rasterized buffer and the top of the line.ymin == 0
, and the character's rasterized height is greater than the line's ascent.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?
The text was updated successfully, but these errors were encountered: