mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25: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()};
|
const bool isScrollable {mParent && mParent->isScrollable()};
|
||||||
std::shared_ptr<Font> font {mFont};
|
std::shared_ptr<Font> font {mFont};
|
||||||
|
|
||||||
if (mLegacyTheme && !isScrollable && (mVerticalAutoSizing || mAutoCalcExtent.x)) {
|
// Used to initialize all glyphs, which is needed to populate mMaxGlyphHeight.
|
||||||
// This is needed to retain a bug from the legacy theme engine where lineSpacing
|
lineHeight = mFont->loadGlyphs(text + "\n") * mLineSpacing;
|
||||||
// is not sized correctly when using automatic text element sizing. This is only
|
|
||||||
// applied to legacy themes for backward compatibility reasons.
|
if (mLegacyTheme)
|
||||||
font->useLegacyMaxGlyphHeight();
|
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};
|
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
|
// 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.
|
// different depending on the resolution, but it's done for maximum backward compatibility.
|
||||||
if (mLegacyMode) {
|
if (mLegacyMode) {
|
||||||
entrySize = std::floor(font->getSize()) * mLineSpacing;
|
font->useLegacyMaxGlyphHeight();
|
||||||
lineSpacingHeight = std::floor(font->getSize()) * mLineSpacing - font->getSize() * 1.0f;
|
entrySize = std::max(font->getHeight(mLineSpacing), font->getSize() * mLineSpacing);
|
||||||
|
lineSpacingHeight = std::floor(font->getSize() * mLineSpacing - font->getSize());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
entrySize = font->getSize() * mLineSpacing;
|
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));
|
setFont(Font::getFromTheme(elem, properties, mFont, 0.0f, mLegacyMode));
|
||||||
|
if (mLegacyMode)
|
||||||
|
mFont->useLegacyMaxGlyphHeight();
|
||||||
const float selectorHeight {mFont->getHeight(mLineSpacing)};
|
const float selectorHeight {mFont->getHeight(mLineSpacing)};
|
||||||
mSelectorHeight = selectorHeight;
|
mSelectorHeight = selectorHeight;
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ TextCache* Font::buildTextCache(const std::string& text,
|
||||||
yBot = getHeight(lineSpacing);
|
yBot = getHeight(lineSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
float y {std::round(offset[1] + (yBot + yTop) / 2.0f)};
|
float y {offset[1] + (yBot + yTop) / 2.0f};
|
||||||
|
|
||||||
// Vertices by texture.
|
// Vertices by texture.
|
||||||
std::map<FontTexture*, std::vector<Renderer::Vertex>> vertMap;
|
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.
|
// guaranteed and can be exceeded by a few pixels for some glyphs.
|
||||||
int loadGlyphs(const std::string& text);
|
int loadGlyphs(const std::string& text);
|
||||||
|
|
||||||
// This is needed to retain a bug from the legacy theme engine where lineSpacing is not
|
// This is needed to maintain maximum compatibility with legacy theme sets.
|
||||||
// sized correctly when using automatic text element sizing.
|
|
||||||
void useLegacyMaxGlyphHeight() { mMaxGlyphHeight = mLegacyMaxGlyphHeight; }
|
void useLegacyMaxGlyphHeight() { mMaxGlyphHeight = mLegacyMaxGlyphHeight; }
|
||||||
|
|
||||||
TextCache* buildTextCache(const std::string& text,
|
TextCache* buildTextCache(const std::string& text,
|
||||||
|
|
Loading…
Reference in a new issue