1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Moved fonts handling from Graphics to RenderHandler class

This commit is contained in:
Ivan Savenko
2024-09-23 15:43:11 +00:00
parent 92c5fd4156
commit 248cff49a4
21 changed files with 132 additions and 101 deletions

View File

@@ -21,6 +21,7 @@
#include "../gui/Shortcut.h"
#include "../render/Canvas.h"
#include "../render/IFont.h"
#include "../render/IRenderHandler.h"
#include "../render/Graphics.h"
#include "../windows/CMessage.h"
#include "../windows/InfoWindows.h"
@@ -95,9 +96,11 @@ void CComponent::init(ComponentType Type, ComponentSubType Subtype, std::optiona
max = 80;
std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(max, pos.w), font);
const auto & fontPtr = GH.renderHandler().loadFont(font);
const int height = static_cast<int>(fontPtr->getLineHeight());
for(auto & line : textLines)
{
int height = static_cast<int>(graphics->fonts[font]->getLineHeight());
auto label = std::make_shared<CLabel>(pos.w/2, pos.h + height/2, font, ETextAlignment::CENTER, Colors::WHITE, line);
pos.h += height;