From 6c096bb63bce61468481aecad7113fa5dec5e1ef Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 8 Jul 2019 10:57:59 +0800 Subject: [PATCH] Fix #3989 --- src/graphics/stk_text_billboard.cpp | 14 ++++++++++---- src/graphics/stk_text_billboard.hpp | 4 +++- src/karts/kart.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/graphics/stk_text_billboard.cpp b/src/graphics/stk_text_billboard.cpp index e8172bd81..826bc2f33 100644 --- a/src/graphics/stk_text_billboard.cpp +++ b/src/graphics/stk_text_billboard.cpp @@ -29,9 +29,9 @@ STKTextBillboard::STKTextBillboard(const video::SColor& color_top, ISceneNode* parent, ISceneManager* mgr, s32 id, const core::vector3df& position, - const core::vector3df& size) + const core::vector3df& scale) : ISceneNode(parent, mgr, id, position, - core::vector3df(0.0f, 0.0f, 0.0f), size) + core::vector3df(0.0f, 0.0f, 0.0f), scale) { using namespace SP; m_color_top = color_top; @@ -52,6 +52,12 @@ STKTextBillboard::STKTextBillboard(const video::SColor& color_top, static_assert(sizeof(GLTB) == 20, "Wrong compiler padding"); } // STKTextBillboard +// ---------------------------------------------------------------------------- +float STKTextBillboard::getDefaultScale(FontWithFace* face) +{ + return 1.0f / (float)face->getDPI(); +} // getDefaultScale + // ---------------------------------------------------------------------------- void STKTextBillboard::updateAbsolutePosition() { @@ -92,7 +98,7 @@ void STKTextBillboard::init(const core::stringw& text, FontWithFace* face) face->drawText(text, core::rect(0, 0, size.Width, size.Height), video::SColor(255,255,255,255), false, false, NULL, NULL, this); - const float scale = 0.02f; + const float scale = getDefaultScale(face); float max_x = 0; float min_y = 0; float max_y = 0; @@ -262,7 +268,7 @@ void STKTextBillboard::initLegacy(const core::stringw& text, FontWithFace* face) face->drawText(text, core::rect(0, 0, size.Width, size.Height), video::SColor(255,255,255,255), false, false, NULL, NULL, this); - const float scale = 0.02f; + const float scale = getDefaultScale(face); float max_x = 0; float min_y = 0; float max_y = 0; diff --git a/src/graphics/stk_text_billboard.hpp b/src/graphics/stk_text_billboard.hpp index e2f78412d..55e50cf85 100644 --- a/src/graphics/stk_text_billboard.hpp +++ b/src/graphics/stk_text_billboard.hpp @@ -83,13 +83,15 @@ private: core::aabbox3df m_bbox; + // ------------------------------------------------------------------------ + float getDefaultScale(FontWithFace* face); public: // ------------------------------------------------------------------------ STKTextBillboard(const video::SColor& color_top, const video::SColor& color_bottom, ISceneNode* parent, ISceneManager* mgr, s32 id, const core::vector3df& position, - const core::vector3df& size); + const core::vector3df& scale = core::vector3df(1, 1, 1)); // ------------------------------------------------------------------------ ~STKTextBillboard() { diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 2c1574b59..8a532ef3c 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -3446,7 +3446,7 @@ void Kart::setOnScreenText(const core::stringw& text) GUIEngine::getSkin()->getColor("font::top"), getNode(), irr_driver->getSceneManager(), -1, core::vector3df(0.0f, 1.5f, 0.0f), - core::vector3df(0.35f, 0.35f, 0.35f)); + core::vector3df(0.5f, 0.5f, 0.5f)); if (CVS->isGLSL()) tb->init(text, bold_face); else