Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

font size

Discussion in 'Immediate Mode GUI (IMGUI)' started by gabrielh, Apr 1, 2008.

  1. gabrielh

    gabrielh

    Joined:
    Feb 24, 2008
    Posts:
    51
    Hi!

    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?

    Thanks
    Gabriel
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    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,
    Jashan
     
  3. trypho

    trypho

    Joined:
    Aug 2, 2007
    Posts:
    36
    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.
     
  4. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    That seems to be the only way at present.
     
  5. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    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.
     
  6. Alpha-Loup

    Alpha-Loup

    Joined:
    Jun 23, 2006
    Posts:
    797
    Good to know. I was asking myself the same question.

    Thanks!
     
  7. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    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,
    Jashan
     
  8. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    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.
     
  9. Alpha-Loup

    Alpha-Loup

    Joined:
    Jun 23, 2006
    Posts:
    797
    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.
     
  10. tolm

    tolm

    Joined:
    Feb 4, 2008
    Posts:
    61
    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.
     
  11. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Ok, but couldn't that be left as my problem, same as with any other art or content?
     
  12. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    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.
     
  13. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    411
    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.
     
  14. tolm

    tolm

    Joined:
    Feb 4, 2008
    Posts:
    61
    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.