# Width of single character on screen

**URL:** <https://psychtoolbox.discourse.group/t/width-of-single-character-on-screen/3131>\
**Category:** Programming Help\
**Created:** [March 18, 2020, 6:25pm UTC](https://psychtoolbox.discourse.group/t/width-of-single-character-on-screen/3131 "2020-03-18T18:25:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpaape](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dpaape](https://psychtoolbox.discourse.group/u/dpaape)\
**Post date:** [March 18, 2020, 6:25pm UTC](https://psychtoolbox.discourse.group/t/width-of-single-character-on-screen/3131/1 "2020-03-18T18:25:20Z")

</div>

Dear all,

I am on Win10, running PsychToolbox Version 3.0.16, Octave 5.1.

What I am trying to do is find out how wide in pixels a character for a monospaced font is on my screen, using Screen(‘TextBounds’).

I have tried the following:

[vm, vr] = Screen(‘OpenWindow’, const.mainScreen, visual.white);  
window = Screen(‘MakeTexture’, vm, visual.white(1)\*ones(vr(RectBottom),vr(RectRight)));  
LetterRect = Screen(‘TextBounds’, window, ‘g’)  
0.00000 0.00000 12.01562 16.00000  
LetterRect = Screen(‘TextBounds’, window, ‘gh’)  
0.00000 0.00000 25.81250 20.00000  
LetterRect = Screen(‘TextBounds’, window, ‘ghj’)  
0.00000 0.00000 36.18750 22.00000  
LetterRect = Screen(‘TextBounds’, window, ‘g h’)  
0.00000 0.00000 39.81250 20.00000

As far as I understand, with a monospaced font, the third value of the output divided by the number of characters should give the character width - which should be the same for all characters - but the numbers don’t add up correctly. Does this have something to do with the properties of the window I’m using?

I would appreciate any input on this issue.

Best,  
Dario

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [March 18, 2020, 10:58pm UTC](https://psychtoolbox.discourse.group/t/width-of-single-character-on-screen/3131/2 "2020-03-18T22:58:36Z")

</div>

I’m not completely sure, but i think that monospace only means that the xAdvance (fourth return param of TextBounds) is constant per character. An i could still be narrower than an m in terms of ink used.
