Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Different font sizes
- - By SPK Date 2012-01-06 01:58
So I was wondering, why is the height of a font read only?

It would be cool to write ;
Font.draw("Hello", x, y, z, size1)
Font.draw("World", x, y, z, size2)

factor_x isn't really helpful and I don't want to initialize the same font with another size.
Parent - - By Spooner Date 2012-01-06 02:18
You are supposed to create a font object for each size you want to use - no way around that. This then caches all the outline fonts as bitmaps of the size requested - remember you aren't drawing from the actual fonts each time you write text on the screen, but drawing bitmaps of each character you ask for.

[EDIT: actually it only renders the outlines to the cached bitmaps when you ask for those particular letters, not when you create the Font object]
Parent - - By SPK Date 2012-01-06 03:27
Meh.
Well, thanks for your reply. :)
Guess I will have to use names like font25, font30 etc.
Parent - - By Spooner Date 2012-01-06 03:33
Actually, I'd consider rubyifying it if you really need a lot of differently sized versions of the same font:

font = Hash.new {|cache, size| cache[size] = Font.new $window, font_name, size }

font[25].draw ...
font[50].draw ...
Parent - By SPK Date 2012-01-06 15:11
You are right. That's easier to manage.

Thanks for the help.
It's so much fun with gosu. :)
Parent - - By Maverick Date 2012-01-06 04:15
You can always use window.scale(x) to resize.
Parent - - By Spooner Date 2012-01-06 17:51
That doesn't really work well, the same as scaling the individual #draws, since that scales the bitmap generated at a specific size; it doesn't re-render the outline font at the effective size.
Parent - By Maverick Date 2012-01-06 19:48
Honestly, I haven't noticed a big difference. Though I don't mess with fonts often.
Parent - By jlnr (dev) Date 2012-01-07 12:51
OS X font rendering generally has less hinting than Windows. Rendering at 100px and then scaling to 50px will look almost the same as rendering at 50px. But you and your troublemaker system... ;)
Up Topic Gosu / Gosu Exchange / Different font sizes

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill