| 811 | } |
| 812 | |
| 813 | fcyVec2 AppFrame::CalcuTextSize(ResFont* p, const wchar_t* strBuf, fcyVec2 scale)LNOEXCEPT |
| 814 | { |
| 815 | if (m_GraphType != GraphicsType::Graph2D) |
| 816 | { |
| 817 | LERROR("RenderText: 只有2D渲染器可以执行该方法"); |
| 818 | return false; |
| 819 | } |
| 820 | |
| 821 | f2dFontProvider* pFontProvider = p->GetFontProvider(); |
| 822 | |
| 823 | int iLineCount = 1; |
| 824 | float fLineWidth = 0.f; |
| 825 | float fMaxLineWidth = 0.f; |
| 826 | while (*strBuf) |
| 827 | { |
| 828 | if (*strBuf == L'\n') |
| 829 | { |
| 830 | ++iLineCount; |
| 831 | fMaxLineWidth = max(fMaxLineWidth, fLineWidth); |
| 832 | fLineWidth = 0.f; |
| 833 | } |
| 834 | else |
| 835 | { |
| 836 | f2dGlyphInfo tGlyphInfo; |
| 837 | if (FCYOK(pFontProvider->QueryGlyph(m_Graph2D, *strBuf, &tGlyphInfo))) |
| 838 | fLineWidth += tGlyphInfo.Advance.x * scale.x; |
| 839 | } |
| 840 | ++strBuf; |
| 841 | } |
| 842 | fMaxLineWidth = max(fMaxLineWidth, fLineWidth); |
| 843 | |
| 844 | return fcyVec2(fMaxLineWidth, iLineCount * pFontProvider->GetLineHeight() * scale.y); |
| 845 | } |
| 846 | |
| 847 | LNOINLINE bool AppFrame::RenderText(const char* name, const char* str, float x, float y, float scale, ResFont::FontAlignHorizontal halign, ResFont::FontAlignVertical valign)LNOEXCEPT |
| 848 | { |
nothing calls this directly
no test coverage detected