1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-11 13:15:38 +02:00

CComponent: do not always assume 80 for text

This commit is contained in:
Konstantin 2023-03-07 03:18:40 +03:00
parent 7a04c28815
commit da8840c499

View File

@ -73,7 +73,13 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
pos.h += 4; //distance between text and image
std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(80, pos.w), font);
auto max = 80;
if (size < medium)
max = 40;
if (size < small)
max = 30;
std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(max, pos.w), font);
for(auto & line : textLines)
{
int height = static_cast<int>(graphics->fonts[font]->getLineHeight());