MATLAB Programming/Psychtoolbox/Screen Commands/TextWidth
Usage:
width=Screen(windowPtr,'TextWidth',text);
Get width of text string. Width is the change in horizontal pen position that would be produced by calling DrawText; it's negative for right-to-left scripts (e.g. Hebrew). The text may include 2-byte characters (e.g. Chinese).