| 789 | } |
| 790 | |
| 791 | void RetinaTrueTypeFont::DrawString(std::string str, float size, float x, float y) |
| 792 | { |
| 793 | if (!mLoaded) |
| 794 | return; |
| 795 | |
| 796 | nvgFontFaceId(gNanoVG, mFontHandle); |
| 797 | nvgFontSize(gNanoVG, size); |
| 798 | |
| 799 | |
| 800 | if (ofIsStringInString(str, "\n") == false) |
| 801 | { |
| 802 | nvgText(gNanoVG, x, y, str.c_str(), nullptr); |
| 803 | } |
| 804 | else |
| 805 | { |
| 806 | std::vector<std::string> lines = ofSplitString(str, "\n"); |
| 807 | float bounds[4]; |
| 808 | nvgTextBounds(gNanoVG, 0, 0, str.c_str(), nullptr, bounds); |
| 809 | float lineHeight = bounds[3] - bounds[1]; |
| 810 | for (int i = 0; i < lines.size(); ++i) |
| 811 | { |
| 812 | nvgText(gNanoVG, x, y, lines[i].c_str(), nullptr); |
| 813 | y += lineHeight; |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | ofRectangle RetinaTrueTypeFont::DrawStringWrap(std::string str, float size, float x, float y, float width) |
| 819 | { |
no test coverage detected