Centering sentences in a block of text, sentences skewed?

Hi everyone,

I am trying to center individual sentences on the screen that together form a block of text (like a passage). I am first drawing “censored” sentences (with some words missing) and then replacing them one-by-one by the full, uncensored text.

For visual reference:

maskedpassage

However, when I “uncensor” the sentences, the sentences are no longer centered – everything is skewed to the left and I can’t figure out why this is the case.

Any suggestions to obtain our desired behavior?

Here is a snippet of the code that I am using:

% Draw masked passage based on current trial number
for maskedSentenceCount = 1:13
    if maskedSentenceCount > TrialIndex % plot the masked sentences
        DrawFormattedText(window,CurrentPassageMasked{maskedSentenceCount},'center',yCenter*TextPlacement(maskedSentenceCount), [1 1 1]);
    elseif maskedSentenceCount < TrialIndex % plot the green sentences
        DrawFormattedText(window,CurrentPassage{maskedSentenceCount},'center',yCenter*TextPlacement(maskedSentenceCount), [0 1 0]);
    endif
endfor

Both calls to DrawFormattedText use the same yCenter value and TextPlacement multiplier.

I am assuming this has something to do with the different sentence arrays that I’m pulling from (one censored and one uncensored), but even the green sentences are all in different horizontal positions. None of the uncensored sentences appear centered even though ALL of the white text is centered before “unmasking”.

I am running this in Ubuntu using Octave (v. 6.4.0) with Psychtoolbox version 3.0.18.

Thank you in advance!

I don’t understand your problem. Your screenshot doesn’t indicate a left skew or lack of centering for the green text vs. the white text?

Hi Mario,

Sorry for the confusion – the image is just to show our desired behavior. In practice, the white text is always centered on the screen, but the green sentences always appear shifted to the left. They look like they all have a different center point, too.

I’ll try to grab a screenshot of the actual output soon.

Thanks!

please provide complete (it can just be run) but as short as possible
example code showing the problem as well

Solved! In preparing some code for y’all to look over, we noticed there were added spaces after the text stimuli in one of the arrays.

Thanks for the help anyway. :slight_smile: