Skip to content

Commit

Permalink
Don't pass newline characters to bidi algorithm
Browse files Browse the repository at this point in the history
If you copy-paste a newline character where it's not interpreted, such
as in a level title, the print function wouldn't treat it any special.
font::print_wrap() would, but that's not used here.

However, now that bidi is involved, the newline is passed straight to
SheenBidi which interprets it as a new line (which would need a new
SBLine to be created, or maybe even a new SBParagraph if there's two).
All while we're still treating it as a single line. This means the text
would just stop being displayed after the first newline. This is now
fixed by treating all newlines as spaces.
  • Loading branch information
Daaaav committed Jan 5, 2024
1 parent e949b28 commit 6a5437a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions desktop_version/src/FontBidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,16 @@ const char* bidi_transform(const bool rtl, const char* text)
int n_codepoints = 0;

const char* text_ptr = text;
while ((utf32_in[n_codepoints] = UTF8_next(&text_ptr)))
uint32_t codepoint;
while ((codepoint = UTF8_next(&text_ptr)))
{
n_codepoints++;
if (codepoint == '\r' || codepoint == '\n')
{
// Don't treat newlines in font::print differently in bidi
codepoint = ' ';
}

utf32_in[n_codepoints++] = codepoint;

if (n_codepoints >= 1023)
{
Expand Down

0 comments on commit 6a5437a

Please sign in to comment.