| 229 | // returns length in pixels of text line using current text spacing settings |
| 230 | |
| 231 | int grViewport::get_text_line_width(char *str) { |
| 232 | int line_width = 0; |
| 233 | int rgb_define_mode = 0; |
| 234 | |
| 235 | for (int i = 0; i < (int)strlen(str); i++) { |
| 236 | int width; |
| 237 | |
| 238 | // note that if we hit the GR_COLOR_CHAR then the next three values should |
| 239 | // not count when defining the width of the line. |
| 240 | if (rgb_define_mode == 3) |
| 241 | rgb_define_mode = 0; |
| 242 | else if (str[i] == GR_COLOR_CHAR) |
| 243 | rgb_define_mode = 1; |
| 244 | if (!rgb_define_mode) { |
| 245 | if (str[i] == '\t') { // tab char |
| 246 | int space_width; |
| 247 | text_Font.get_char_info(' ', &space_width); |
| 248 | space_width += text_Spacing; |
| 249 | line_width = (line_width + space_width - 1) / space_width * space_width; |
| 250 | } else { |
| 251 | text_Font.get_char_info((int)str[i], &width); |
| 252 | line_width += (width + get_text_spacing()); |
| 253 | } |
| 254 | } else |
| 255 | rgb_define_mode++; |
| 256 | } |
| 257 | |
| 258 | return line_width - get_text_spacing(); |
| 259 | } |
| 260 | |
| 261 | /* These internal routines just draw a line of text. depending on the function |
| 262 | we clip or don't clip |
nothing calls this directly
no test coverage detected