diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index d392d0ed7..9499165b9 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -273,17 +273,11 @@ void TextComponent::onTextChanged() const bool isScrollable {mParent && mParent->isScrollable()}; std::shared_ptr font {mFont}; - if (mLegacyTheme && !isScrollable && (mVerticalAutoSizing || mAutoCalcExtent.x)) { - // This is needed to retain a bug from the legacy theme engine where lineSpacing - // is not sized correctly when using automatic text element sizing. This is only - // applied to legacy themes for backward compatibility reasons. + // Used to initialize all glyphs, which is needed to populate mMaxGlyphHeight. + lineHeight = mFont->loadGlyphs(text + "\n") * mLineSpacing; + + if (mLegacyTheme) font->useLegacyMaxGlyphHeight(); - lineHeight = font->getHeight(mLineSpacing); - } - else { - // Used to initialize all glyphs, which is needed to populate mMaxGlyphHeight. - lineHeight = mFont->loadGlyphs(text + "\n") * mLineSpacing; - } const bool isMultiline {mAutoCalcExtent.y == 1 || mSize.y > lineHeight}; diff --git a/es-core/src/components/primary/TextListComponent.h b/es-core/src/components/primary/TextListComponent.h index e2c74ffff..16d537b3f 100644 --- a/es-core/src/components/primary/TextListComponent.h +++ b/es-core/src/components/primary/TextListComponent.h @@ -320,8 +320,9 @@ template void TextListComponent::render(const glm::mat4& parentT // The vertical spacing between rows for legacy themes is very inaccurate and will look // different depending on the resolution, but it's done for maximum backward compatibility. if (mLegacyMode) { - entrySize = std::floor(font->getSize()) * mLineSpacing; - lineSpacingHeight = std::floor(font->getSize()) * mLineSpacing - font->getSize() * 1.0f; + font->useLegacyMaxGlyphHeight(); + entrySize = std::max(font->getHeight(mLineSpacing), font->getSize() * mLineSpacing); + lineSpacingHeight = std::floor(font->getSize() * mLineSpacing - font->getSize()); } else { entrySize = font->getSize() * mLineSpacing; @@ -525,6 +526,8 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, } setFont(Font::getFromTheme(elem, properties, mFont, 0.0f, mLegacyMode)); + if (mLegacyMode) + mFont->useLegacyMaxGlyphHeight(); const float selectorHeight {mFont->getHeight(mLineSpacing)}; mSelectorHeight = selectorHeight; diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index 05cd00b42..0f05fce14 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -154,7 +154,7 @@ TextCache* Font::buildTextCache(const std::string& text, yBot = getHeight(lineSpacing); } - float y {std::round(offset[1] + (yBot + yTop) / 2.0f)}; + float y {offset[1] + (yBot + yTop) / 2.0f}; // Vertices by texture. std::map> vertMap; diff --git a/es-core/src/resources/Font.h b/es-core/src/resources/Font.h index 7ba8b93d5..02b387391 100644 --- a/es-core/src/resources/Font.h +++ b/es-core/src/resources/Font.h @@ -46,8 +46,7 @@ public: // guaranteed and can be exceeded by a few pixels for some glyphs. int loadGlyphs(const std::string& text); - // This is needed to retain a bug from the legacy theme engine where lineSpacing is not - // sized correctly when using automatic text element sizing. + // This is needed to maintain maximum compatibility with legacy theme sets. void useLegacyMaxGlyphHeight() { mMaxGlyphHeight = mLegacyMaxGlyphHeight; } TextCache* buildTextCache(const std::string& text,