Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarMainInterface.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 14:21:51 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 14:21:51 +1000
commitd018957b098f00536d0d7641e13aaf1ebddf2238 (patch)
tree0a739eb78c402dd261e06381f77c822c607922ad /source/frontend/StarMainInterface.cpp
parent069d61e487947a8be38f6a3db52695db94fd306e (diff)
Fix font glyph generation to work correctly with other fonts
Diffstat (limited to 'source/frontend/StarMainInterface.cpp')
-rw-r--r--source/frontend/StarMainInterface.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 86c7bb6..37ff2e3 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -1261,33 +1261,44 @@ void MainInterface::renderDebug() {
auto assets = Root::singleton().assets();
m_guiContext->setFontSize(m_config->debugFontSize);
m_guiContext->setFont(m_config->debugFont);
+ m_guiContext->setFontProcessingDirectives(m_config->debugFontDirectives);
m_guiContext->setFontColor(Color::Green.toRgba());
+ m_guiContext->setFontMode(FontMode::Normal);
bool clearMap = m_debugMapClearTimer.wrapTick();
auto logMapValues = LogMap::getValues();
if (clearMap)
LogMap::clear();
+ List<String> formatted;
+ formatted.reserve(logMapValues.size());
+
int counter = 0;
for (auto const& pair : logMapValues) {
- TextPositioning positioning = {Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter)};
- m_debugTextRect.combine(m_guiContext->determineTextSize(strf("{}: {}", pair.first, pair.second), positioning).padded(m_config->debugBackgroundPad));
- ++counter;
+ TextPositioning positioning = {Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter++)};
+ String& text = formatted.emplace_back(strf("^white;{}^lightgray;:^reset; {}", pair.first, pair.second));
+ m_debugTextRect.combine(m_guiContext->determineTextSize(text, positioning).padded(m_config->debugBackgroundPad));
}
- if (!m_debugTextRect.isNull())
- m_guiContext->drawQuad(m_debugTextRect, m_config->debugBackgroundColor.toRgba());
+ if (!m_debugTextRect.isNull()) {
+ RenderQuad& quad = m_guiContext->renderer()->immediatePrimitives()
+ .emplace_back(std::in_place_type_t<RenderQuad>(), m_debugTextRect, m_config->debugBackgroundColor.toRgba(), 0.0f).get<RenderQuad>();
- if (clearMap)
- m_debugTextRect = RectF::null();
+ quad.b.color[3] = quad.c.color[3] = 0;
+ };
+
+ m_debugTextRect = RectF::null();
counter = 0;
for (auto const& pair : logMapValues) {
TextPositioning positioning = {Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter)};
- m_guiContext->renderText(strf("{}: {}", pair.first, pair.second), positioning);
+ m_guiContext->renderText(formatted[counter], positioning);
++counter;
}
+ m_guiContext->setFontSize(8);
+ m_guiContext->setDefaultFont();
m_guiContext->setFontColor(Vec4B::filled(255));
+ m_guiContext->setFontProcessingDirectives("");
auto const& camera = m_worldPainter->camera();