`graphics->drawTextInRect` alignment across multiple lines?

I feel like I can't be the first person to have noticed this, but not seeing other reports in my searching! Sorry if I've missed something. I'm currently building against 2.7.3.

The C graphics->drawTextInRect function added in 2.6.0 doesn't seem to be applying text alignment for multiple lines correctly. Is this expected behavior? This code renders how I'd expect:

const char *text = "hello,\nthis is a test!";
int textLen = (int)strlen(text);

pd->graphics->drawTextInRect(text, textLen, kUTF8Encoding, 0, 0, 400, 80, kWrapWord, kAlignTextLeft);
pd->graphics->drawTextInRect(text, textLen, kUTF8Encoding, 0, 80, 400, 80, kWrapWord, kAlignTextCenter);
pd->graphics->drawTextInRect(text, textLen, kUTF8Encoding, 0, 160, 400, 80, kWrapWord, kAlignTextRight);

However, changing the string to "this is a test,\nhello!" renders center and right alignment with only the first line properly aligned. I get the same behavior regardless of the passed wrap mode:

Another example with three lines:

1 Like