I know it’s been a VERY long while since this question was asked, but I think I’ve just found the answer, after a two hour headache of fonts disappearing when partially off screen and vertical anchor settings being ignored…
The height of the renderer bounding box is set by the line spacing of the .fontsettings asset multiplied by the TextMesh character size and line spacing.
The TextMesh line spacing assumes space under each character, so if it is set to 1, your bounds will be twice the font line height, even if you only have one line of text.
Bounds height = 2*(Number of Lines)(Asset Line Spacing)(TextMesh Line Spacing)*(TextMesh Character Size)
Edit: That headache was worse than I thought… This should be:
The TextMesh line spacing assumes space under each character, so if it is set to 2, your bounds will be twice the font line height, even if you only have one line of text. If your asset’s line spacing is wrong, it’ll all be wrong.
Bounds height = (Number of Lines)(Asset Line Spacing)(TextMesh Line Spacing)*(TextMesh Character Size)
The asset line height should automatically be calculated for font assets generated by the TrueTypeFontImporter, while for custom fonts it should manually be set.
If you have a custom font, draw the renderer bounds, make sure that the text mesh line spacing is set to 1 and modify the font asset’s line spacing until the bounding box perfectly covers the tallest letter in your font.
Oh, also, to get the asset line spacing for a font imported using the TrueTypeFontImporter, since it does not publicly expose this, or in fact to set it via script, you can grab it using serialized properties, as per here.
SerializedObject so = new SerializedObject(customFont);
Debug.Log(so.FindProperty("m_LineSpacing").floatValue);