mooman219 / fontdue

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

Characters not rendered at size == scale can be "off" by a pixel #60

Closed aclysma closed 3 years ago

aclysma commented 3 years ago

I have in-engine text rendering working. For now I hardcode scale == 40.0. I noticed when I render font size at 40px it looks great, but this other text at 15px has the appearance of character spacing/alignment being off by a pixel.

image

1) There's a good chance that this is expected behavior, but if you know for certain it is/isn't, would appreciate it! I have tried mipmapping the font texture but it did not improve it. 2) I would consider rasterizing the font at two different scales to solve this, but some fonts have many characters and makes creating a new "copy" of the font at a different scale very expensive, even if I'm only going to rasterize a few of them. (mentioned in #59). Would you be interested in a pull request to add a way to filter what characters to load?

Thanks for the great library!

mooman219 commented 3 years ago

Have you tried switching your CoordinateSystem?

aclysma commented 3 years ago

I think I did but it was long enough ago that I don’t recall exactly what happened. I can try it again

mooman219 commented 3 years ago

I recognize the positioning error, it happens when you tell Fontdue the wrong coordinate system. It needs to know if Y+ is up relative to the monitor or Y+ is down relative to the monitor. If you get a chance, if you're calling let mut layout = Layout::new(CoordinateSystem::PositiveYUp); anywhere, try using CoordinateSystem::PositiveYDown (or vice versa). If you're still having an issue please re-open this bug or make a new one.