MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / draw_text_line

Method draw_text_line

2dlib/pentext.cpp:336–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336void grViewport::draw_text_line(int x, int y, char *str) {
337 unsigned i, cur_x;
338
339 /* perform string drawing without viewport clipping.
340 supports bitmap fonts or color(alpha) mapped fonts.
341 */
342 cur_x = x;
343 for (i = 0; i < (int)strlen(str); i++) {
344 uint8_t ch;
345
346 ch = (uint8_t)str[i];
347
348 if (ch == GR_COLOR_CHAR) {
349 if ((i + 3) >= (int)strlen(str))
350 Int3(); // This shouldn't happen! bad string!
351 set_text_color(GR_RGB(str[i + 1], str[i + 2], str[i + 3]));
352 i += 4;
353 if (i >= (int)strlen(str))
354 Int3(); // This shouldn't happen too.
355 ch = (uint8_t)str[i];
356 } else if (ch == '\t') { // tab char
357 int space_width;
358 text_Font.get_char_info(' ', &space_width);
359 space_width += text_Spacing;
360 cur_x = (cur_x + space_width - 1) / space_width * space_width;
361 } else {
362 cur_x = text_Font.draw_char(sf_Parent, cur_x, y, ch, &char_Props);
363 cur_x += text_Spacing;
364 }
365 }
366}

Callers

nothing calls this directly

Calls 3

get_char_infoMethod · 0.80
draw_charMethod · 0.80
GR_RGBFunction · 0.50

Tested by

no test coverage detected