
220 8. Text
else // Non displayable character
{
switch(ch)
{
case ' ': // Space
if(proportional)
{
width = textNS::FONT_WIDTH/2;
scaledWidth = static_cast<int>(width*spriteData.scale);
}
drawChar(' ');
spriteData.x += scaledWidth;
break;
Listing 8.18. Handling nondisplayable characters.
If the character is not displayable, a switch statement is used to check for escape se-
quences. If the character is a space and proportional spacing is enabled, the width
and scaledWidth of a proportional space are calculated. e space is displayed by
drawChar(' ') and the screen X location is advanced (Listing 8.18). If the character is a
new line \n, the ...