From 2328ceb4bcaab01da2fa455191d16ecaba664ce9 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 16 Aug 2023 00:43:40 -0700 Subject: [PATCH] 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 --- src/v_video.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/v_video.cpp b/src/v_video.cpp index 224530269..740df7b80 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -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;