CharacterInfo.glyphWidth always 0

Hello community.
I think I found a bug or maybe i am just too stupid :smiley:

When I want to get the glyphWidth of a character I always get 0 returned.
I am using this code:

text = GetComponent<Text>();

CharacterInfo ci;
text.font.GetCharacterInfo(getCurrentChar(), out ci);
print(ci.glyphWidth);           //this prints 0

I am trying to find out how to fix this for 3 hours now… Please help me. Thank you :slight_smile:

I keep running into this problem. Here are my two answers so far.

First:

    textObject.font.RequestCharactersInTexture(stringToBeParsed, fontSize, fontStyle);

^ this line is necessary to get the texture info into memory in the code. If you don’t do this, with the correct string you are referencing, fontSize, and fontStyle of the textbox, it will not work correctly. (EDIT: and it should come BEFORE any glyphWidth or characterInfo calls, afaik)

Second:

The other element is the font asset itself. Currently, I can’t seem to make Unicode characters work, but Dynamic characters work every time. Even if you use Unicode characters ultimately, the dynamic character info can at least be useful as an estimate (they don’t appear to be the same though)

What is getCurrentChar() and what values is it returning?