MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / GetStringWidth

Method GetStringWidth

Source/OpenFrameworksPort.cpp:834–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834float RetinaTrueTypeFont::GetStringWidth(std::string str, float size)
835{
836 if (!mLoaded)
837 return str.size() * 12;
838
839 NVGcontext* vg;
840 int handle;
841 if (TheSynth->GetOpenGLContext()->getCurrentContext() != nullptr)
842 {
843 vg = gNanoVG;
844 handle = mFontHandle;
845 }
846 else
847 {
848 vg = gFontBoundsNanoVG;
849 handle = mFontBoundsHandle;
850 }
851
852 nvgFontFaceId(vg, handle);
853 nvgFontSize(vg, size);
854 float bounds[4];
855 float width = nvgTextBounds(vg, 0, 0, str.c_str(), nullptr, bounds);
856
857 return width;
858}
859
860float RetinaTrueTypeFont::GetStringHeight(std::string str, float size)
861{

Callers 14

RenderMethod · 0.80
RenderOverlayMethod · 0.80
DrawModuleMethod · 0.80
GetModuleDimensionsMethod · 0.80
DrawModuleUnclippedMethod · 0.80
DrawModuleMethod · 0.80
DrawModuleMethod · 0.80
ConstructMethod · 0.80
RenderMethod · 0.80
GetDimensionsMethod · 0.80
OnClickedMethod · 0.80
DrawTextRightJustifyFunction · 0.80

Calls 5

nvgFontFaceIdFunction · 0.85
nvgFontSizeFunction · 0.85
nvgTextBoundsFunction · 0.85
sizeMethod · 0.80
GetOpenGLContextMethod · 0.80

Tested by

no test coverage detected