mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Fixed multiple issues with text rendering for legacy themes.
This commit is contained in:
parent
10d0a89a47
commit
645b41afa4
|
@ -273,17 +273,11 @@ void TextComponent::onTextChanged()
|
|||
const bool isScrollable {mParent && mParent->isScrollable()};
|
||||
std::shared_ptr<Font> 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};
|
||||
|
||||
|
|
|
@ -320,8 +320,9 @@ template <typename T> void TextListComponent<T>::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<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
}
|
||||
|
||||
setFont(Font::getFromTheme(elem, properties, mFont, 0.0f, mLegacyMode));
|
||||
if (mLegacyMode)
|
||||
mFont->useLegacyMaxGlyphHeight();
|
||||
const float selectorHeight {mFont->getHeight(mLineSpacing)};
|
||||
mSelectorHeight = selectorHeight;
|
||||
|
||||
|
|
|
@ -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<FontTexture*, std::vector<Renderer::Vertex>> vertMap;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue