Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Which Font works fine ?
- - By SPK Date 2011-09-30 05:20
Hello guys,

I'm loading Arial.ttf, but the font seems rather odd when rendering text ( a bit blurry and not like Arial at all...) .
Is there any Font thats looks good (sharp and simple) ?
Parent - - By Spooner Date 2011-09-30 12:12
Not sure why Arial should not work, but a key thing is never to scale fonts. If you need to render a font at multiple sizes, then create it at multiple sizes because the font is rendered when created, not when drawn.
Parent - - By SPK Date 2011-09-30 14:20
Well, I do not render it at different sizes.

I have something like this:

@font = Gosu::Font.new(self, "./Fonts/Arial.ttf", 20)

And somewhere in my draw()-method:

@font.draw(@charakter.name, 60, 50, 200)

It looks a bit uneven and slightly chopped.
Parent - - By Spooner Date 2011-09-30 14:57
I don't know then; That should look fine. I generally have to play around with a number of fonts before I can get one to render nicely, so it might be worth trying with similar fonts or different versions of Arial.

One other option for improving font rendering is to create it larger and scale it down when rendering it:

@font_scale = 4.0 # Generate at 4x the size, then scale it down so it anti-aliases - note this is significantly slower at creation time
@font = Gosu::Font.new(self, "./Fonts/Arial.ttf", 20 * @font_scale)

@font.draw(@charakter.name, 60, 50, 200, 1 / @font_scale, 1 / @font_scale)
Parent - - By jlnr (dev) Date 2011-10-01 07:35
Gosu internally scales up and down by 2x already. Scaling by another factor of 4 sounds overkill.

Also: Font#new does not render anything. Font#draw renders characters once, on demand. So it will be slow the first time you draw things :)
Parent - - By Spooner Date 2011-10-01 14:13
I definitely get an effect from additionally scaling fonts, but I am always wanting crisp, angular pixel fonts in retro-mode. Just a shot in the dark!

Thanks for clarifying that #new doesn't render the entire font up-front.
Parent - - By jlnr (dev) Date 2011-10-01 14:17 Edited 2011-10-01 14:27
Font really needs a write-up now that it has Font#[]=. Oh man, documenting is so annoying. Where to put stuff? I should really try yard. :)

To keep that little trick in the same thread as above information, my_font.text_width("ABCDEFG...putyourstuffhere") will render all these characters internally, so that the following draw call will be super fast, and can be called right after Font creation.
Parent - - By Spooner Date 2011-10-01 14:21
YARD is backwards compatible with Rdoc, so there is nothing to lose really and you have a lot of improvements waiting for you when you are ready for them! Win, win and win!

Nice trick to encourage rendering. I might use that myself, especially since I could render 5 characters per frame (in init) that way then it won't take forever to render the first screen with a lot of text. Another bit of optimisation that isn't strictly that necessary :D
Parent - By jlnr (dev) Date 2011-10-01 14:27
Yeah, preloading sound effects would make a bigger difference I guess, that is actually noticeable in some games (=Peter Morphose). But Sample.[] sure is convenient. ;)
Parent - By RavensKrag Date 2011-10-01 23:55
+1

Definitely prefer YARD.  Just saying :D Seems like overall a much cleaner interface for browsing documentation.
Parent - - By jlnr (dev) Date 2011-10-01 07:35
Does it change anything if you just use "Arial", not a filename? Also, what OS are you on?
Parent - By SPK Date 2011-10-04 17:18
I'm currently using Windows 7 Ultimate x68 until I get my old computer back with Ubuntu.
Hm. Well, I'm using the plain fontname now.
I don't know if I just got used to the font or it really looks normal now.

Sorry, for the confusion I brought up, but for now it looks alright.

Thanks a lot.

So long.
Up Topic Gosu / Gosu Exchange / Which Font works fine ?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill