Is there a way to measure interletter spacing for Fixed Width font in MATLAB?
조회 수: 7(최근 30일)
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 2021년 10월 27일
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 2021년 10월 27일
편집: Scott MacKenzie 2021년 10월 27일
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