Fix a runtime warning in text rendering

This commit is contained in:
Henrik Rydgård 2024-11-21 14:53:45 +01:00
parent c6c9e32d15
commit 617bef73ee

View File

@ -297,6 +297,10 @@ float UIContext::CalculateTextScale(std::string_view str, float availWidth, floa
}
void UIContext::DrawTextRectSqueeze(std::string_view str, const Bounds &bounds, uint32_t color, int align) {
if (bounds.w <= 0 || bounds.h <= 0) {
// Probably mid-layout.
return;
}
float origScaleX = fontScaleX_;
float origScaleY = fontScaleY_;
float scale = CalculateTextScale(str, bounds.w / origScaleX, bounds.h / origScaleY);