#1131·makepad

\r in \r\n line endings renders as tofu (.notdef) glyph instead of being treated as line separator

Author: zzl221000Created Jun 24, 2026Updated Jul 14, 2026

Problem

When text contains Windows-style \r\n line endings, the \r character is rendered as a visible tofu box (.notdef glyph) instead of being consumed as part of the line separator.

Root Cause

In draw/src/text/layouter.rs, layout_multiline() splits lines using split('\n'):

https://github.com/makepad/makepad/blob/82db45a00c5c26502edc084da70f592ba36eba63/draw/src/text/layouter.rs#L281-L286

This leaves \r at the end of each line. The \r is then passed to the shaper (rustybuzz), which looks it up in the font's cmap table. Since \r (U+000D) is a control character with no visible glyph, it maps to glyph ID 0 (.notdef), which renders as a tofu box.

Additionally, finish_current_row() hardcodes a +1 byte skip for the newline:

https://github.com/makepad/makepad/blob/82db45a00c5c26502edc084da70f592ba36eba63/draw/src/text/layouter.rs#L433-L436

This assumes all line endings are exactly 1 byte (\n), so \r\n (2 bytes) and standalone \r (old Mac style) are not handled correctly.

Impact

  • \r\n line endings: \r renders as a visible tofu box at the end of every line
  • Standalone \r line endings: text is not split into lines at all

Reproduction

Any text with \r\n line endings passed to a Label, TextInput, CodeEditor, or any widget that uses the layouter will exhibit this behavior. This is especially common on Windows where files typically use \r\n.