Recent TextLayout fixes cause new issue


#1

The most recent fixes for TextLayout cause a new problem. It seems that newline characters (ie. Newline::getDefault()) will sometimes be printed out in labels as a symbol (we have seen square symbols and ‘!’) depending on the font.


#2

Hmm, well all I changed was to make sure leading whitespace in a string gets printed. Presumably this is just on windows?


#3

Sorry, its on Mac, CoreGraphicsContext


#4

Just double checked, the problem was introduced in this commit:


by the line:
t.font.getGlyphPositions (getTrimmedEndIfNotAllWhitespace (t.text), newGlyphs, xOffsets);
whereas the old version:
t.font.getGlyphPositions (t.text.trimEnd(), newGlyphs, xOffsets);
does not produce the issue. However, the old version cause problems with tabs in the code editor.


#5

Can you give me a code snippet that shows the problem?


#6

Ok, so i debugged it and this is the problem:

The new getTrimmedEndIfNotAllWhitespace will return a “\n” on a “\n” input. This goes into t.font.getGlyphPositions which in my case returns a glyph to be added to the token list. It happens only for some fonts, but I suppose its a simple condition that a newline should not be added to the glyph list.


#7

Ok, I can’t reproduce it with a normal font, but perhaps this would help:

[code] static String getTrimmedEndIfNotAllWhitespace (const String& s)
{
String trimmed (s.trimEnd());
if (trimmed.isEmpty() && ! s.isEmpty())
trimmed = s.replaceCharacters ("\r\n\t", " ");

[/code]


#8

Yes, that works fine.