void Text::GetWidthAndHeight(const std::string& str, const CFont& font, std::vector<float>& str_width, std::vector<float>& str_height, float& whole_width, float& whole_height) { std::wstring wstr(str_to_wstr(str)); str_width.resize(1); str_height.resize(1); UINT line = 0; UINT width, height; Application::GetScreenSize(width, height); width *= font.GetQuality(); height *= font.GetQuality(); whole_width = whole_height = 0.0f; for (const auto& it : wstr) { if (it == '\n') { whole_width = max(whole_width, str_width.at(line)); whole_height += str_height.at(line); str_height.emplace_back(0.0f); str_width.emplace_back(0.0f); line++; continue; } try { auto& ch = font.GetData(it); str_height.at(line) = max(str_height.at(line), ch.gm.gmptGlyphOrigin.y * 2.0f / (float)height); str_width.at(line) += ch.gm.gmCellIncX * 2.0f / (float)width; } catch (...) { continue; } } whole_width = max(whole_width, str_width.at(line)); whole_height += str_height.at(line); }