draws a string
| 680 | |
| 681 | // draws a string |
| 682 | void grtext_RenderString(int x, int y, char *str) { |
| 683 | int cur_x = x, cur_y = y, gx, gy; |
| 684 | char *line = str, *save_pos; |
| 685 | |
| 686 | do { |
| 687 | // Look for newline, and if found, put in a 0 to terminate the line |
| 688 | save_pos = strchr(line, '\n'); |
| 689 | if (save_pos) // found an newline |
| 690 | *save_pos = 0; // terminate the line |
| 691 | |
| 692 | int line_width; |
| 693 | int clipped; |
| 694 | |
| 695 | line_width = grtext_GetTextLineWidth(line); |
| 696 | |
| 697 | gy = cur_y; |
| 698 | gx = cur_x; // Clip function needs global coords. |
| 699 | |
| 700 | clipped = 0; |
| 701 | if ((CLIP_TOP > (gy + CHAR_HEIGHT(Grtext_font))) || (CLIP_BOTTOM < gy)) |
| 702 | clipped = 2; |
| 703 | else if ((CLIP_LEFT > (gx + line_width)) || (CLIP_RIGHT < gx)) |
| 704 | clipped = 2; |
| 705 | |
| 706 | if (clipped != 2) { |
| 707 | if (CLIP_LEFT > gx || CLIP_RIGHT < (gx + line_width)) |
| 708 | clipped = 1; |
| 709 | if (CLIP_TOP > gy || CLIP_BOTTOM < (gy + CHAR_HEIGHT(Grtext_font))) |
| 710 | clipped = 1; |
| 711 | |
| 712 | if (clipped == 0) |
| 713 | grtext_DrawTextLine(gx, gy, line); |
| 714 | else if (clipped == 1) |
| 715 | grtext_DrawTextLineClip(gx, gy, line); |
| 716 | } |
| 717 | cur_y += (Grtext_line_spacing + CHAR_HEIGHT(Grtext_font)); |
| 718 | cur_x = CLIP_LEFT; |
| 719 | |
| 720 | // replace the newline, if there was one |
| 721 | if (save_pos) |
| 722 | *save_pos++ = '\n'; |
| 723 | |
| 724 | line = save_pos; |
| 725 | |
| 726 | } while (line); |
| 727 | } |
| 728 | |
| 729 | int grtext_GetTextHeightTemplate(tFontTemplate *ft, const char *str) { |
| 730 | int cur_h = 0; |
no test coverage detected