diff options
author | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2020-11-03 20:54:53 -0500 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-04 17:09:41 +0200 |
commit | eda5c2dc976f2d02cee5c8dc2feaa2d824d40c79 (patch) | |
tree | 1f2ce7d33f515e92adebb770c91d263d9ac21a08 /src/ui | |
parent | 9e555a0ba9e3b5b9234d42f38f68eabaa750c08c (diff) |
ui: Fix line wrapping of emoticons
While we do want to have special handling of punctuation to help wrap
pathologically-long-hyphenated-words-that-go-on-for-kilometers, we don't
want to wrap emoticons, so let's adjust the logic to account for this.
While we're at it, clean up and add a comment explaining the logic for
the benefit of future readers.
Fixes rendering of a recent post on CAPCOM at certain window sizes
=> gemini://rosenzweig.io/lagrange/Before.png Before the change
=> gemini://rosenzweig.io/lagrange/After.png After the change
Notice the wrapping of the ":D" in the second paragraph.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/text.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 2ceadb75..f998688a 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -586,11 +586,22 @@ static enum iFontId fontId_Text_(const iFont *font) { | |||
586 | return font - text_.fonts; | 586 | return font - text_.fonts; |
587 | } | 587 | } |
588 | 588 | ||
589 | iLocalDef iBool isWrapBoundary_(iChar a, iChar b) { | 589 | /* Line wrapping boundaries are determined by looking at a character and the |
590 | if (b == '/' || b == '-' || b == ',' || b == ';' || b == ':' || b == '.') { | 590 | * last character processed. We want to wrap at natural word boundaries where |
591 | * possible, so normally we wrap at a space followed a non-space character. As | ||
592 | * an exception, we also wrap after punctuation used to break up words, so we | ||
593 | * can wrap text like foo/bar/baz-abc-def.xyz at any puncation boundaries, | ||
594 | * without wrapping on other punctuation used for expressive purposes like | ||
595 | * emoticons :-) */ | ||
596 | |||
597 | iLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) { | ||
598 | if (isSpace_Char(prevC)) | ||
599 | return iFalse; | ||
600 | |||
601 | if (c == '/' || c == '-' || c == ',' || c == ';' || c == ':' || c == '.') | ||
591 | return iTrue; | 602 | return iTrue; |
592 | } | 603 | |
593 | return !isSpace_Char(a) && isSpace_Char(b); | 604 | return isSpace_Char(c); |
594 | } | 605 | } |
595 | 606 | ||
596 | iLocalDef iBool isMeasuring_(enum iRunMode mode) { | 607 | iLocalDef iBool isMeasuring_(enum iRunMode mode) { |