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

Access to Font Character Position

Discussion in 'Scripting' started by CedarParkDad, May 7, 2009.

  1. CedarParkDad

    CedarParkDad

    Joined:
    May 28, 2008
    Posts:
    98
    Hello,

    As easy as it is to miss something, I've read as much as I can find on fonts in Unity. I know how to bring custom fonts in and how to get access to the font, material, and texture. What I can't find is how to get access to the UV information for a single character on a texture in a font. It doesn't look like we get access to this information, but I'm just trying to find out if I'm wrong and we can in some fashion find out how to display a font (outside of using fixed-width fonts). Any ideas, knowledge, or pointers would be helpful :)
     
  2. lesguerra

    lesguerra

    Joined:
    Apr 20, 2009
    Posts:
    24
    have you tried using a bitmap font generator like BMFont?
     
  3. CedarParkDad

    CedarParkDad

    Joined:
    May 28, 2008
    Posts:
    98
    Oh, yes, I can get them manually and enter them one at a time. But, I'm trying to make a system which handles them in-game regardless of the font or point-size used. It's looking like I'll be using TextMesh and putting them together into a single mesh. Should prove...interesting :)
     
  4. lesguerra

    lesguerra

    Joined:
    Apr 20, 2009
    Posts:
    24
    i'm also trying to make a manager, should be useful for buttons. i'm using your SpriteUI and brady's SpriteManager. increasing the width and height in AddElement doesn't work really well. I haven't tried TextMesh, but will do.
     
  5. Matt_001

    Matt_001

    Joined:
    Sep 17, 2010
    Posts:
    101
    I have exactly the same problem here.

    I would be so happy if anyone could help.


    There is only "workaround" I found, which can cause problems:

    You can put each character in a fixed-width font and then use kerning to correct the empty space beside each character that have a lower width of the fixed one.

    The problem with that is it only controls the cursor starting location, so if you don't have, and maybe even if you have, transparent background you might have some problems with overlapping at the end of the line.

    Hope someone can help!
     
  6. Matt_001

    Matt_001

    Joined:
    Sep 17, 2010
    Posts:
    101
  7. Matt_001

    Matt_001

    Joined:
    Sep 17, 2010
    Posts:
    101