V_TitleCardStringWidth: don't count punctuation, in order to help centering

Punctuation, like ellipsis, normally offsets the centered
position of text. But this looks subjectively weird. By
not counting it, punctuation is basically allowed to
extend further off to the sides.

The difference looks like:

                   CENTER
                     ||
                     \/
                     ||
    OLD:    |   TOO LATE...    |
                     ||
    NEW:    |     TOO LATE...  |
                     ||
                     /\
                     ||
                   CENTER
This commit is contained in:
James R 2023-08-16 00:43:40 -07:00 committed by toaster
parent ae2fdcbd12
commit 2328ceb4bc

View file

@ -1881,6 +1881,17 @@ INT32 V_TitleCardStringWidth(const char *str, boolean p4)
continue;
}
// For the sake of centering, don't count punctuation.
// TODO: This should ideally be more sophisticated:
// - Only apply on the ends of each line.
// - Check patch width directly for monospace or
// punctuation that isn't necessarily thin.
// - Apply to all string drawing.
if (ispunct(*ch))
{
continue;
}
c = *ch;
c = toupper(c);
c -= LT_FONTSTART;