Docs @ Psychtoolbox Wiki : TextBounds

Search PTB Function help:
homepsychtoolbox.orgpage updateslogin

Revision [14165]

Last edited on 2011-07-27 11:55:53 by DocBot
Additions:
""<div class="subfct" id="Screen">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline] [,swapTextDirection]);%%
Accepts a window pointer and a 'text' string. Return in 'normBoundsRect' a rect
defining the size of the text in units of pixels. Returns in 'offsetBoundsRect'
offsets of the text bounds from the origin, assuming that the text will be drawn
at the current position of the text drawing cursor. Only the default high
quality text renderers returns a perfect bounding box. The optionally selectable
low-quality, fast renderers on Windows and Linux return a bounding box which
doesn't take letters with descenders into account - Descenders are outside the
returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats and
all additional parameters...
<<=====See also:=====
DrawText TextSize TextFont TextStyle TextColor TextBackgroundColor<<""</div>""
Deletions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychOneliners/TextBounds.m?op=log">changelog</a> of trunk branch</span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""


Revision [14103]

Edited on 2011-07-05 09:15:33 by DocBot
Additions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychOneliners/TextBounds.m?op=log">changelog</a> of trunk branch</span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""
Deletions:
""<div class="subfct" id="Screen">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline] [,swapTextDirection]);%%
Accepts a window pointer and a 'text' string. Return in 'normBoundsRect' a rect
defining the size of the text in units of pixels. Returns in 'offsetBoundsRect'
offsets of the text bounds from the origin, assuming that the text will be drawn
at the current position of the text drawing cursor. Only the default high
quality text renderers returns a perfect bounding box. The optionally selectable
low-quality, fast renderers on Windows and Linux return a bounding box which
doesn't take letters with descenders into account - Descenders are outside the
returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats and
all additional parameters...
<<=====See also:=====
DrawText TextSize TextFont TextStyle TextColor TextBackgroundColor<<""</div>""


Revision [14007]

Edited on 2011-07-05 05:21:19 by DocBot
Additions:
""<div class="subfct" id="Screen">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline] [,swapTextDirection]);%%
Accepts a window pointer and a 'text' string. Return in 'normBoundsRect' a rect
defining the size of the text in units of pixels. Returns in 'offsetBoundsRect'
offsets of the text bounds from the origin, assuming that the text will be drawn
at the current position of the text drawing cursor. Only the default high
quality text renderers returns a perfect bounding box. The optionally selectable
low-quality, fast renderers on Windows and Linux return a bounding box which
doesn't take letters with descenders into account - Descenders are outside the
returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats and
all additional parameters...
<<=====See also:=====
DrawText TextSize TextFont TextStyle TextColor TextBackgroundColor<<""</div>""
Deletions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychOneliners/TextBounds.m?op=log">changelog</a> of trunk branch</span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""


Revision [13497]

Edited on 2010-12-06 12:14:52 by DocBot
Additions:
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychOneliners/TextBounds.m?op=log">changelog</a> of trunk branch</span>
Deletions:
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view in <a href=
"http://svn.berlios.de/wsvn/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m?view=markup">WebSVN with changelog</a></span>


Revision [11518]

Edited on 2010-09-09 16:09:01 by DocBot
Additions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view in <a href=
"http://svn.berlios.de/wsvn/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m?view=markup">WebSVN with changelog</a></span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""
Deletions:
""<div class="subfct" id="Screen">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline] [,swapTextDirection]);%%
Accepts a window pointer and a 'text' string. Return in 'normBoundsRect' a rect
defining the size of the text in units of pixels. Returns in 'offsetBoundsRect'
offsets of the text bounds from the origin, assuming that the text will be drawn
at the current position of the text drawing cursor. Only the default high
quality text renderers returns a perfect bounding box. The optionally selectable
low-quality, fast renderers on Windows and Linux return a bounding box which
doesn't take letters with descenders into account - Descenders are outside the
returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats and
all additional parameters...
<<=====See also:=====
DrawText TextSize TextFont TextStyle TextColor TextBackgroundColor<<""</div>""


Revision [9786]

Edited on 2010-01-11 08:38:00 by DocBot
Additions:
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline] [,swapTextDirection]);%%
Accepts a window pointer and a 'text' string. Return in 'normBoundsRect' a rect
defining the size of the text in units of pixels. Returns in 'offsetBoundsRect'
offsets of the text bounds from the origin, assuming that the text will be drawn
at the current position of the text drawing cursor. Only the default high
quality text renderers returns a perfect bounding box. The optionally selectable
low-quality, fast renderers on Windows and Linux return a bounding box which
doesn't take letters with descenders into account - Descenders are outside the
returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats and
all additional parameters...
<<=====See also:=====
DrawText TextSize TextFont TextStyle TextColor TextBackgroundColor<<""</div>""
Deletions:
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
""</div>""


Revision [9202]

Edited on 2008-11-05 06:23:01 by DocBot
Additions:
""<div class="subfct" id="Screen">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
""</div>""
Deletions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view in <a href=
"http://svn.berlios.de/viewcvs/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m?view=markup">WebSVN with changelog</a></span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""


Revision [7978]

Edited on 2008-09-25 18:27:57 by DocBot
Additions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view in <a href=
"http://svn.berlios.de/viewcvs/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m?view=markup">WebSVN with changelog</a></span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""
Deletions:
""<div class="subfct" id="Screen" style="background-color:#eee; padding:1em; border-width:1px; border-style:solid; border-color:#ddd; margin-bottom: 2em;border-top: 5px solid #999999;">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
""</div>""


Revision [7622]

Edited on 2008-09-25 18:14:22 by DocBot
Additions:
""<div class="subfct" id="Screen" style="background-color:#eee; padding:1em; border-width:1px; border-style:solid; border-color:#ddd; margin-bottom: 2em;border-top: 5px solid #999999;">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
""</div>""
Deletions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view in <a href=
"http://svn.berlios.de/viewcvs/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m?view=markup">WebSVN with changelog</a></span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""


Revision [7303]

Edited on 2008-09-25 17:57:45 by DocBot
Additions:
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of TextBounds.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m">beta</a> | view in <a href=
"http://svn.berlios.de/viewcvs/osxptb/beta/Psychtoolbox/PsychOneliners/TextBounds.m?view=markup">WebSVN with changelog</a></span>
</div>
<div class="code">
<code>Psychtoolbox/PsychOneliners/TextBounds.m</code>
</div>
""
Deletions:
%%(php;Path)Psychtoolbox/PsychOneliners/TextBounds.m%%


Revision [7226]

Edited on 2008-09-16 11:55:16 by DocBot
Additions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
%%(php;Path)Psychtoolbox/PsychOneliners/TextBounds.m%%
Deletions:
""<div class="subfct" id="Screen" style="background-color:#eee; padding:1em; border-width:1px; border-style:solid; border-color:#ddd; margin-bottom: 2em;border-top: 5px solid #999999;">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
""</div>""


Revision [7087]

Edited on 2008-07-10 16:13:16 by DocBot
Additions:
""<div class="subfct" id="Screen" style="background-color:#eee; padding:1em; border-width:1px; border-style:solid; border-color:#ddd; margin-bottom: 2em;border-top: 5px solid #999999;">""===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
""</div>""
Deletions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
%%(php;Path)Psychtoolbox/PsychOneliners/TextBounds.m%%


Revision [5953]

Edited on 2008-06-22 01:46:11 by DocBot
Additions:
===[[TextBounds]]===
==[[Psychtoolbox]] › [[PsychOneliners]]==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'[[Close]]');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
%%(php;Path)Psychtoolbox/PsychOneliners/TextBounds.m%%
Deletions:
===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...


Revision [5028]

Edited on 2008-04-26 21:33:53 by DocBot
Additions:
===[[TextBounds Screen('TextBounds')]]===
==[[Psychtoolbox]] › [[Screen]].{mex*,dll} subfunction==
%%(matlab;Usage)[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);%%
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for [[Screen]]('DrawText') for info about accepted text string formats...
Deletions:
===[[TextBounds]]===
==[[Psychtoolbox]] › PsychOneliners==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'Close');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
%%(php;Path)Psychtoolbox/PsychOneliners/TextBounds.m%%


Revision [2969]

Edited on 2008-03-21 09:18:26 by DocBot
Additions:
==[[Psychtoolbox]] › PsychOneliners==
bounds=TextBounds(window,string)
Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=[[Screen]]('OpenWindow',0,0);
woff=[[Screen]](w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
[[Screen]](woff,'TextFont','Arial');
[[Screen]](woff,'TextSize',textSize);
[[Screen]](woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
[[Screen]](woff,'Close');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are [[Screen]] 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see [[Screen]] 'TextBounds'.
The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
%%(php;Path)Psychtoolbox/PsychOneliners/TextBounds.m%%
Deletions:
==ScreenFunctions==
Usage:
[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for Screen('DrawText') for info about accepted text string formats...
ScreenFunctions


Revision [2549]

Edited on 2008-03-15 23:19:18 by DocBot
Additions:
===[[TextBounds]]===
==ScreenFunctions==
Usage:
[normBoundsRect, offsetBoundsRect]= Screen('TextBounds', windowPtr, text [,x] [,y] [,yPositionIsBaseline]);
Accept a window pointer and a string. Return in normBoundsRect a rect defining
the size of the text in units of pixels. Return in offsetBoundsRect offsets of
the text bounds from the origin, assuming that the text will be drawn at the
current position of the text drawing cursor. Currently, only the OS-X version
returns a perfect bounding box. The M$-Windows version returns a perfect
bounding box if the GDI text renderer is enabled, but not with the default
renderer. GNU/Linux versions and Windows with default renderer return a bounding
box which doesn't take letters with descenders into account - Descenders are
outside the returned box.
See help for Screen('DrawText') for info about accepted text string formats...
ScreenFunctions
Deletions:
===PsychOneliners===
bounds=TextBounds(window,string)

Returns the smallest enclosing rect for the drawn text, relative to
the current location. This bound is based on the actual pixels
drawn, so it incorporates effects of text smoothing, etc. "text"
may be a cell array or matrix of 1 or more strings. The strings are
drawn one on top of another, at the same initial position, before
the bounds are calculated. This returns the smallest box that will
contain all the strings. The prior contents of the scratch window
are lost. Usually it should be an offscreen window, so the user
won't see it. The scratch window should be at least twice as wide
and height as the text, because the text to cope with uncertainties
about text direction (e.g. Hebrew) and some unusual characters that extend
greatly to the left of their nominal starting point. If you only
know your nominal text size and number of characters, you might do
this to create your scratch window:
textSize=24;
string='Hello world.';
With 'w' being the handle of the onscreen window, e.g., w=Screen('OpenWindow',0,0);
woff=Screen(w,'OpenOffscreenWindow',[],[0 0 3*textSize*length(string) 2*textSize]);
Screen(woff,'TextFont','Arial');
Screen(woff,'TextSize',textSize);
Screen(woff,'TextStyle',1); % 0=plain (default for new window), 1=bold, etc.
bounds=TextBounds(woff,string);
...
Screen(woff,'Close');
The suggested window size in that call is generously large because there
aren't any guarantees from the font makers about how big the text might
be for a specified point size. Set your window's font, size, and
(perhaps) style before calling TextBounds.
Be warned that TextBounds and TextCenteredBounds are slow (taking many
seconds) if the window is large. They use the whole window, so if the
window is 1024x1204 they process a million pixels. The two slowest calls
are Screen 'GetImage' and FIND. Their processing time is proportional to
the number of pixels in the window.
OSX: Also see Screen 'TextBounds'.

The user interface would be cleaner if this function opened and closed
its own offscreen window, instead of writing in the user's window.
Unfortunately, this might cause some prohibitive overhead.
Also see TextCenteredBounds.
PsychOneliners


Revision [709]

The oldest known version of this page was created on 2008-03-15 10:30:02 by DocBot
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.3586 seconds