When a line of text has a new-line character (\n), the line seems to be measured to be wider than it should be.
This was noted back when work was being done on the summary screen to add the statistics of building capturing (#3216). There, it was noted that having the following, centred in a text object:
a / b\nc / d
was resulting in:
a / b c / d
(The workaround at the time was to add a new-line character to the second line so that both line have the same initial width/length.)
The reason appears to be as follows:
- \n is an unprintable character.
- Thus, it does not have a glyph in any of the font files.
- Thus, when it comes to measure that character, the measuring code (source/graphics/Font.cpp CFont::GetCharacterWidth()) returns the width of the "Missing Glyph" symbol.
For the purposes of demonstration, changes to the summary screen have been included to show how the second lines no longer need a new-line character tacked on the end. Whether or not these changes get committed with the c++ changes (should this revision be accepted) is up to the reviewer(s). (Further work to permit the postfix attribute to be optional is a possibility for another revision.)
Depends on D1298