Is there a way to measure interletter spacing for Fixed Width font in MATLAB?
12 views (last 30 days)
Hello, I am trying to calculate the physical characteristics of the text we plan to use for our experiment. Now to finalize this, I need to know these following information PER character: size of letters, interletter spacing in cm and degrees of visual angle per font size (font size 16, 18, 20 and 22). I am relatively a newbie in MATLAB and I cannot find a function that could work. I am using Fixed Width font style.
I would appreciate any help I could get.
J. Alex Lee on 27 Oct 2021
I have no idea what you mean by "visual angle per font size", but I know of one way:
lbl = uicontrol("Style","text","String","X","FontName","courier")
This creates a text label on a figure, and once it is rendered, you can query its "Extent" property:
which is a [position,extent] vector, so the 3rd element is the width.
So playing around with it can give hints about how the UI system will position characters
lbl = uicontrol("Style","text","String","X","FontName","courier").Extent
lbl = uicontrol("Style","text","String","XX","FontName","courier").Extent
lbl = uicontrol("Style","text","String","XX X","FontName","courier").Extent
Scott MacKenzie on 27 Oct 2021
Edited: Scott MacKenzie on 27 Oct 2021
For text fonts, 1 pt = 1/72 inches. So, if you set the font size of the text to, say, 36 pt., the character height will be 1/2 inch or 1.27 cm. I suggest you do some actual measurements to verify and work with those measurements. MATLAB's "extent" property for text includes margins, so I'd be hesitant to use those width and height values.
As for visual angle, that's an arctan calculation. You need the size of the characters and the distance of the participant's eye from the display. For example, the visual angle in degrees for a character 1 cm in size viewed from a distance of 65 cm is