MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / getStringWidth

Method getStringWidth

src/util/GLFont.cpp:475–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475float 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
504void GLFont::drawString(const std::wstring& str, int pxHeight, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {

Callers

nothing calls this directly

Calls 4

findMethod · 0.80
getXOffsetMethod · 0.80
getXAdvanceMethod · 0.80
getAspectMethod · 0.80

Tested by

no test coverage detected