font size


Sorry for the newbie question, but I was looking through the doc for ages now and couldn't find it...
How can I change the font size of GUI text?


Usually, you do the font sizes in the import settings. I’m not sure I’m doing it in the best possible way, but for different font-sizes, I duplicate the font in the asset folder and then rename it to the font-size and change the import settings as needed…

Sunny regards,

That’s how I’ve been doing it, too. Seems a little funky, since it basically adds another texture to your assets. On the other hand, I don’t know how else you would be able to display the font at a large size without it looking rough.

If there’s a better way to do this, I would definitely like to know.

That seems to be the only way at present.

that is the way to do it. We need to get the font's images into the player somehow, so there's currently no way around this.

Good to know. I was asking myself the same question.


Currently? I thought this was actually quite a nice approach... It only took a moment to figure out how to do it (not sure if that's documented well enough - but I have to admit that I didn't try looking... the confusion around this may indicate lack of documentation, though)

Of course, being able to select the font-size whereever you use a font might be more convenient (ah, from the Scripts would be best) - but you'd still need the textures and by making this so "ultra-comfortable", that fact would be hidden, which I think might not be that great. It's a game engine and not Adobe Illustrator, after all ;-) (and also not Flash... even though... thinking about it... well... forget it ;-) ).

I'm just really thankful we don't have to do all the stuff behind the scenes ourselves (ever tried creating text in XNA? At least, in one of the earlier versions that was really quite a "difficult" process ... not sure if they've changed that by now ... and don't really care either ... now that I have Unity)...

Sunny regards,

Well, actually, a TrueType library would be cool. We do import .ttf fonts, why not treat them that way? There's probably a reason, but it eludes me.

Well, usually you use not more than two or three different fontstyles and to do a good and clear layout you need only about 3 different font sizes... that could easyly be done with this system. Its definitely enough for me, the way it is.

One reason is that font files, both TrueType, OpenType and PostScript, actually have licenses that govern how you can use them. And distributing the font file to others usually isn't a part of that license. So you can't just send the whole file along - you'd probably have to embed its data in some way similar to how Flash or PDF does.

Also, I guess it's more efficient to have a font ready as a texture and just show it, than it is to render it in realtime.

Ok, but couldn't that be left as my problem, same as with any other art or content?

Yes, it would be cool. Why it's not done - because it has to be implemented and tested. It would be a pretty complex system to create some textures to hold glyphs, cache already generated glyphs, resize textures when there's no space left on them for new glyps, and so on. Not rocket science, just work. And some practical reasons as well - e.g. including Freetype into the player will increase it's size (we're mostly concerned about plugin installer size).

So yes, this would be cool to have. Maybe someday we'll have this.

Of course, including 3-4 sizes of the same font increases player download size as well, although I don’t know how common this is.

Then again, who knows how large a TT library would be, either.

I know at this point player size is a big issue, but hopefully this feature makes the cut in the future.

Well, the thing is that it’s not a simple question of just including the font or not, like with other art or content. It’s a question of how you include it. Many fonts only allow embedding a subset of them, and so Unity would have to have a way of doing that, if you wanted to include those fonts.

I’m just saying that by only including bitmaps of fonts you get around all sorts of license issues that you’d otherwise have to deal with.