Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Changing Font Size in GUI

Discussion in 'Immediate Mode GUI (IMGUI)' started by gizzerd91, Sep 3, 2008.

Thread Status:
Not open for further replies.
  1. gizzerd91

    gizzerd91

    Joined:
    May 4, 2008
    Posts:
    311
    I've been working on a GUI, and until now I've just used photoshop for my text, but I really need to be able to use text. The problem is its too small. Here's my code:

    function DrawLabelBottomAligned (pos : Vector2, text : String)
    {
    GUI.Label(Rect (pos.x, nativeVerticalResolution - pos.y, 100, 100), text);
    }

    I tried using a transform matrix but then it gets too pixelated. Any help greatly appreciated.
     
  2. gizzerd91

    gizzerd91

    Joined:
    May 4, 2008
    Posts:
    311
    is there something blindingly obvious I'm missing, or can it not be done?
     
  3. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    Can't be done, at least not directly. We usually keep a few of the same fonts copied to have different import settings.

    You could also scale a GUI element with GUIUtility.ScaleAroundPoint to make it bigger. It's a pain, though...
     
  4. gizzerd91

    gizzerd91

    Joined:
    May 4, 2008
    Posts:
    311
    Wow. Unity's GUI system sucks. First they dont have alpha for images, now they dont have font size. They need to get on this for some soon release.
     
  5. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    This is incorrect. What problem are you seeing?
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Of course there's alpha for images, and of course there's font size. There just isn't any dynamic font size where you get any arbitrary size from one font file. If your text is too small just import the text at a larger size.

    (The lack of vector fonts is actually a blessing in disguise anyway IMO, since having to make separate font files for each size makes people keep the number of font sizes down to a bare minimum, and from a typographic point of view this is a good thing. ;) )

    --Eric
     
  7. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    Yeah, I should've clarified--when I say we keep multiple fonts with different import settings, it's the same font at different sizes: 10 point, 14 point, 18 point, etc. The texture size isn't terrible, because it's alpha 8-bit.

    I think it would be cleaner to select point sizes in the GUI skin/style, rather than reference different fonts, but it is workable now (and you can do dynamic scaling if you absolutely need to).
     
  8. gizzerd91

    gizzerd91

    Joined:
    May 4, 2008
    Posts:
    311
    How do I load it in different sizes?
     
  9. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
  10. thecreatrix

    thecreatrix

    Joined:
    Dec 19, 2008
    Posts:
    94
    So in your assets folder, do you have multiple copies of each font, maybe renamed so that they each import as a unique font?

    Or is there a way to duplicate a font within the IDE and then adjust import settings on the copy that way?
     
  11. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    For the editor, I have Lucida Grande (main gui font). I duplicated that (copy/paste), renamed it to Lucida Grande Large and changed the import settings to be 11 points rather than 10. Same for small. Etc...
     
Thread Status:
Not open for further replies.