- Home /
Unity’s TextMesh, Font.lineHeight, and the number 9.75f
I’m working on implementing my own version of a text mesh.
My first step is to make it work exactly like unity’s TextMesh, before adding new functionality. I’ve got it drawing well now, rich text and everything, but I’m running into one strange issue I just can’t seem to figure out.
When scaling the results of Font and GetCharacterInfo functions, one must divide the values by 10.0f. This yields the correct character widths and heights, for the customTextMesh’s model space. These values are then transformed normally using the CustomTextMesh’s transform.
However, when scaling the font lineHeight (http://docs.unity3d.com/ScriptReference/Font-lineHeight.html), I need to divide by 9.75f, rather than 10.0f, in order for the spacing to match unity’s text mesh.
I came to 9.75f experimentally, by manually adjusting this number, until the text lined up exactly with the standard unity TextMesh that was displayed in the same location.
I worry that I’m missing something here. Does anyone know why I need to use 9.75f, rather than 10.0f?
(Note this 9.75f does not change, even if font size, font style, and rich rich-text markup is used/changed.)
Edit: Font.ascent also requires I divide by 9.75f, rather than 10.0f