| 832 | } |
| 833 | |
| 834 | float 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 | |
| 860 | float RetinaTrueTypeFont::GetStringHeight(std::string str, float size) |
| 861 | { |
no test coverage detected