The "insertText" function uses TrueType fonts to render the text. TrueType is software that is embedded in both Windows and Mac operating systems and is outside of MATLAB. Currently there is no way for "insertText" to request the font height in pixels using the underling rendering library. However, once the font is rendered, the "insertText" function will "know" the font height in pixels but this value is currently inaccessible from outside the function.
As a workaround, you can measure the number of pixels of the output text to get the relationship between font height in pixels and the font size.
The workaround steps are as follows:
1. Select whatever string you wish to render.
2. Set the 'BoxOpacity' parameter of "insertText" to 1 to see the background box.
3. Use "imtool" function to measure the height of the box. "imtool" doc is linked below: