| 268 | } |
| 269 | |
| 270 | Float2 SpriteFont::MeasureText(const wchar* text) const |
| 271 | { |
| 272 | Float2 size = Float2(0.0f, 0.0f); |
| 273 | Float2 curPos = Float2(0.0f, 0.0f);; |
| 274 | |
| 275 | size_t length = wcslen(text); |
| 276 | |
| 277 | for (uint64 i = 0; i < length; ++i) |
| 278 | { |
| 279 | wchar character = text[i]; |
| 280 | if(character == ' ') |
| 281 | curPos.x += SpaceWidth(); |
| 282 | else if(character == '\n') |
| 283 | { |
| 284 | curPos.y += CharHeight(); |
| 285 | curPos.x = 0; |
| 286 | } |
| 287 | else |
| 288 | { |
| 289 | SpriteFont::CharDesc desc = GetCharDescriptor(character); |
| 290 | curPos.x += desc.Width + 1; |
| 291 | } |
| 292 | |
| 293 | size.x = std::max(curPos.x, size.x); |
| 294 | size.y = std::max(curPos.y, size.y); |
| 295 | } |
| 296 | |
| 297 | return size; |
| 298 | } |
| 299 | |
| 300 | } |
no test coverage detected