Search Unity

A way to know the size of a certain font character

Discussion in 'Scripting' started by GuyTidhar, Sep 2, 2009.

  1. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    I would like to identify the excat width or height of certain characters of certain font type, during run time.
    Is such a thing possible?
     
  2. Anim

    Anim

    Joined:
    Aug 11, 2008
    Posts:
    289
    Each letter in a Text Mesh font can be a different width. You could examine the TextMesh Bounds to get its total width tho.
     
  3. ElmarKleijn

    ElmarKleijn

    Joined:
    May 11, 2009
    Posts:
    87
    Perhaps by using:

    Vector2 vSize = YourSkin.GetStyle("label").CalcSize(new GUIContent("A"));

    It might require a skin without other graphical elements, paddding/margins etc to properly work though.
     
  4. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    Thanks buddy.
    This will help me solve my issue!