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) ?
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.
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.
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)
Gosu internally scales up and down by 2x already. Scaling by another factor of 4 sounds overkill.
Font#new does not render anything.
Font#draw renders characters once, on demand. So it will be slow the first time you draw things :)
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.
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.
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
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. ;)
Definitely prefer YARD. Just saying :D Seems like overall a much cleaner interface for browsing documentation.
Does it change anything if you just use "Arial", not a filename? Also, what OS are you on?
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.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill