| 473 | } |
| 474 | |
| 475 | float GLFont::getStringWidth(const std::wstring& str, float size, float viewAspect) { |
| 476 | |
| 477 | float scalex = size / viewAspect; |
| 478 | |
| 479 | float width = 0; |
| 480 | |
| 481 | for (int charId : str) { |
| 482 | if (characters.find(charId) == characters.end()) { |
| 483 | continue; |
| 484 | } |
| 485 | |
| 486 | GLFontChar *fchar = characters[charId]; |
| 487 | |
| 488 | float ofsx = (float) fchar->getXOffset() / (float) imageWidth; |
| 489 | float advx = (float) fchar->getXAdvance() / (float) imageWidth; |
| 490 | |
| 491 | if (charId == 32) { |
| 492 | advx = characters[L'_']->getAspect(); |
| 493 | } |
| 494 | |
| 495 | width += fchar->getAspect() + advx + ofsx; |
| 496 | } |
| 497 | |
| 498 | width *= scalex; |
| 499 | |
| 500 | return width; |
| 501 | } |
| 502 | |
| 503 | // Draw string, immediate |
| 504 | void GLFont::drawString(const std::wstring& str, int pxHeight, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) { |
nothing calls this directly
no test coverage detected