Skip to content

Commit 1cbed65

Browse files
peterhorvath111lgritz
authored andcommitted
fix: Windows newline shows invalid character in text render (#4501)
Newline in strings on Windows is encoded as '\r\n', that is currently not handled by the text render code and so carriage return (\r) shows up in the rendered text. As a fix we simply ignore this character. We came across this issue while exporting user specified text from DCCs to render on Windows. I'm not sure how to make a proper test case for this. Current tests specify a command as a string that is passed to oiiotool as arguments and executed in the command line. But adding a newline to the text breaks the command. Signed-off-by: Peter Horvath <peter.horvath@autodesk.com> Signed-off-by: peter.horvath <peter.horvath@autodesk.com>
1 parent ebe6c80 commit 1cbed65

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/libOpenImageIO/imagebufalgo_draw.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,11 @@ ImageBufAlgo::render_text(ImageBuf& R, int x, int y, string_view text,
11231123
// Glyph by glyph, fill in our textimg buffer
11241124
int origx = x;
11251125
for (auto ch : utext) {
1126+
// on Windows a newline is encoded as '\r\n'
1127+
// we simply ignore carriage return here
1128+
if (ch == '\r') {
1129+
continue;
1130+
}
11261131
if (ch == '\n') {
11271132
x = origx;
11281133
y += fontsize;

0 commit comments

Comments
 (0)