Skip to content

Commit

Permalink
Merge pull request #255 from Psychtoolbox-3/master
Browse files Browse the repository at this point in the history
DrawFormattedText(): Add 'left' keyword to 'sx' argument, to position…
  • Loading branch information
kleinerm authored Oct 7, 2023
2 parents c719bf3 + eee46cd commit 397490a
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions Psychtoolbox/PsychBasic/DrawFormattedText.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
%
% 'sx' defines the left border of the text: If it is left out, text
% starts at x-position zero, otherwise it starts at the specified position
% 'sx'. If sx=='center', then each line of text is horizontally centered in
% the window. If sx=='right', then each line of text is right justified to
% the right border of the target window, or of 'winRect', if provided.
% 'sx' in the window. If sx=='left', then each line of text is left justified
% to the left border of the target window, or of 'winRect', if provided.
% If sx=='center', then each line of text is horizontally centered in
% the window or 'winRect'. If sx=='right', then each line of text is right
% justified to the right border of the target window, or of 'winRect'.
% The options sx == 'wrapat' and sx == 'justifytomax' try to align the start
% of each text line to the left border and the end of each text line to either
% the specified 'wrapat' number of columns, or to the width of the widest line
Expand Down Expand Up @@ -198,27 +200,23 @@
end

xcenter = 0;
ljustify = 0;
rjustify = 0;
bjustify = 0;
if ischar(sx)
if strcmpi(sx, 'center')
xcenter = 1;
end

if strcmpi(sx, 'right')
rjustify = 1;
end

if strcmpi(sx, 'wrapat')
bjustify = 1;
end

if strcmpi(sx, 'justifytomax')
bjustify = 2;
end

if strcmpi(sx, 'centerblock')
bjustify = 3;
switch lower(sx)
case 'center'
xcenter = 1;
case 'left'
ljustify = 1;
case 'right'
rjustify = 1;
case 'wrapat'
bjustify = 1;
case 'justifytomax'
bjustify = 2;
case 'centerblock'
bjustify = 3;
end

% Set sx to neutral setting:
Expand Down Expand Up @@ -366,7 +364,7 @@
disableClip = (ptb_drawformattedtext_disableClipping ~= -1) && ...
((ptb_drawformattedtext_disableClipping > 0) || (nargout >= 3));

if bjustify
if bjustify || ljustify
sx = winRect(RectLeft);
end

Expand Down

0 comments on commit 397490a

Please sign in to comment.