UCanvas::TextSize() returns incorrect Height and Width for multi-line strings. Doesn't honor CRLFs.

When passing a multi-line string to UCanvas::TextSize(), for example “This\r\nis\r\nText\r\nyeah\r\nyeah\r\nyeah”, it will return a width proportional to all those characters (including the CRLFs), and the height of a single character. I would expect a result that respects the vertical space created by the CRLFs. Tracing the code, UCanvas::MeasureStringInternal() seems buggy/inadequate…

Parameters.DrawXL += CharWidth;

Parameters.DrawYL = FMath::Max(Parameters.DrawYL, CharHeight + ScaledVertSpacing );

Can we improve this function, or fix the UCanvas::TextSize() docs?

  • thanks