Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use loaded font with Image::from_text #649

Open
runnerpack opened this issue Jul 17, 2023 · 2 comments
Open

Add ability to use loaded font with Image::from_text #649

runnerpack opened this issue Jul 17, 2023 · 2 comments

Comments

@runnerpack
Copy link

Unless I'm dense, I don't see a way to render a Gosu::Image from text using a previously loaded (and modified with Font#[]=) Gosu::Font, since the latter takes the name of a font as an argument, rather than a Gosu::Font instance.
Could this be put on the enhancement list?

@jlnr
Copy link
Member

jlnr commented Jul 18, 2023

You are right, Font#[]= and Image::from_text are not compatible right now. The technical/philosophical background is that Gosu::Font is a bitmap font with no support for kerning, and Image::from_text will apply proper kerning, which results in prettier but more expensive text rendering. This is also why Font#width and Image#text_width are separate methods with separate results.

I think the best way forward would be to add kerning support to Font so that both mechanisms become more interchangeable.

@runnerpack
Copy link
Author

Thank you for the clarification. My current use case doesn't really need the extra performance of prerendered text, so I'll just use the Font#draw_* methods, perhaps with Gosu#record where appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants