- if (strlen(text) <= max_chars_per_line) // only one line of text
- ystart += getFontHeight(font_nr) / 2;
+ DisableDrawingText();
+
+ // first get number of text lines to calculate offset for centering text
+ int num_lines_printed =
+ DrawTextBuffer(0, 0, text, font_nr,
+ max_chars_per_line, -1, max_lines_per_text, line_spacing, -1,
+ autowrap, centered, parse_comments);
+
+ EnableDrawingText();
+
+ int size_lines_printed = num_lines_printed * line_height - line_spacing;
+ int yoffset = (row_height - size_lines_printed) / 2;