summaryrefslogtreecommitdiffstats
path: root/src/graphics/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/engine')
-rw-r--r--src/graphics/engine/engine.cpp2
-rw-r--r--src/graphics/engine/text.cpp10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index f7e300e..7c90a8d 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -281,6 +281,8 @@ void CEngine::Destroy()
void CEngine::ResetAfterDeviceChanged()
{
+ m_size = m_app->GetVideoConfig().size;;
+
m_text->FlushCache();
// TODO reload textures, reset device state, etc.
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 101e01a..da1a290 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -46,7 +46,7 @@ struct CachedFont
};
-
+const Math::IntPoint REFERENCE_SIZE(800, 600);
CText::CText(CInstanceManager *iMan, CEngine* engine)
@@ -147,6 +147,10 @@ void CText::FlushCache()
f->cache.clear();
}
}
+
+ m_lastFontType = FONT_COLOBOT;
+ m_lastFontSize = 0;
+ m_lastCachedFont = nullptr;
}
void CText::DrawText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
@@ -723,8 +727,8 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
CachedFont* CText::GetOrOpenFont(FontType font, float size)
{
- // TODO: sizing
- int pointSize = static_cast<int>(size);
+ Math::IntPoint windowSize = m_engine->GetWindowSize();
+ int pointSize = static_cast<int>(size * (windowSize.Length() / REFERENCE_SIZE.Length()));
if (m_lastCachedFont != nullptr)
{