| 244 | typename alloc |
| 245 | > |
| 246 | string_dims compute_string_dims ( |
| 247 | const std::basic_string<T, traits, alloc>& str, |
| 248 | const std::shared_ptr<font>& f_ptr = default_font::get_font() |
| 249 | ) |
| 250 | { |
| 251 | using string = std::basic_string<T, traits, alloc>; |
| 252 | |
| 253 | const font& f = *f_ptr; |
| 254 | |
| 255 | long height = f.height(); |
| 256 | long width = 0; |
| 257 | for (typename string::size_type i = 0; i < str.size(); ++i) |
| 258 | { |
| 259 | // ignore the '\r' character |
| 260 | if (str[i] == '\r') |
| 261 | continue; |
| 262 | |
| 263 | // A combining character should be applied to the previous character, and we |
| 264 | // therefore make one step back. If a combining comes right after a newline, |
| 265 | // then there must be some kind of error in the string, and we don't combine. |
| 266 | if (is_combining_char(str[i])) |
| 267 | { |
| 268 | width -= f[str[i]].width(); |
| 269 | } |
| 270 | |
| 271 | if (str[i] == '\n') |
| 272 | { |
| 273 | height += f.height(); |
| 274 | width = f.left_overflow(); |
| 275 | continue; |
| 276 | } |
| 277 | |
| 278 | const letter& l = f[str[i]]; |
| 279 | width += l.width(); |
| 280 | } |
| 281 | return string_dims(width, height); |
| 282 | } |
| 283 | |
| 284 | // ---------------------------------------------------------------------------------------- |
| 285 |
nothing calls this directly
no test coverage detected