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

Proper support for usage of multiple fonts in a chain

This commit is contained in:
Ivan Savenko
2024-09-24 10:41:39 +00:00
parent 557b72f2b3
commit 87274128e7
11 changed files with 284 additions and 83 deletions

View File

@@ -23,13 +23,33 @@ int IFont::getScalingFactor() const
return GH.screenHandler().getScalingFactor();
}
size_t IFont::getLineHeight() const
{
return getLineHeightScaled() / getScalingFactor();
}
size_t IFont::getGlyphWidth(const char * data) const
{
return getGlyphWidthScaled(data) / getScalingFactor();
}
size_t IFont::getStringWidth(const std::string & data) const
{
return getStringWidthScaled(data) / getScalingFactor();
}
size_t IFont::getFontAscent() const
{
return getFontAscentScaled() / getScalingFactor();
}
size_t IFont::getStringWidthScaled(const std::string & data) const
{
size_t width = 0;
for(size_t i=0; i<data.size(); i += TextOperations::getUnicodeCharacterSize(data[i]))
{
width += getGlyphWidth(data.data() + i);
width += getGlyphWidthScaled(data.data() + i);
}
return width;
}