diff options
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/drape_engine.cpp | 20 | ||||
-rw-r--r-- | drape_frontend/drape_engine.hpp | 2 | ||||
-rw-r--r-- | drape_frontend/text_layout.cpp | 2 | ||||
-rw-r--r-- | drape_frontend/visual_params.cpp | 11 | ||||
-rw-r--r-- | drape_frontend/visual_params.hpp | 5 |
5 files changed, 38 insertions, 2 deletions
diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index 7944158951..8a02c7ecab 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -12,6 +12,11 @@ #include "std/bind.hpp" +namespace +{ + char const kFontScale[] = "FontScale"; +} + namespace df { DrapeEngine::DrapeEngine(Params && params) @@ -19,6 +24,10 @@ DrapeEngine::DrapeEngine(Params && params) { VisualParams::Init(params.m_vs, df::CalculateTileSize(m_viewport.GetWidth(), m_viewport.GetHeight())); + double scaleFactor = 1.0; + if (settings::Get(kFontScale, scaleFactor)) + df::VisualParams::Instance().SetFontScale(scaleFactor); + gui::DrapeGui & guiSubsystem = gui::DrapeGui::Instance(); guiSubsystem.SetLocalizator(bind(&StringsBundle::GetString, params.m_stringsBundle.get(), _1)); guiSubsystem.SetSurfaceSize(m2::PointF(m_viewport.GetWidth(), m_viewport.GetHeight())); @@ -538,4 +547,15 @@ void DrapeEngine::UpdateTraffic(vector<TrafficSegmentData> const & segmentsData) MessagePriority::Normal); } +void DrapeEngine::SetFontScaleFactor(double scaleFactor) +{ + double const kMinScaleFactor = 0.5; + double const kMaxScaleFactor = 2.0; + + scaleFactor = my::clamp(scaleFactor, kMinScaleFactor, kMaxScaleFactor); + + settings::Set(kFontScale, scaleFactor); + VisualParams::Instance().SetFontScale(scaleFactor); +} + } // namespace df diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 6c8b9a2b0b..e49a76aa37 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -165,6 +165,8 @@ public: void AddTrafficSegments(vector<pair<uint64_t, m2::PolylineD>> const & segments); void UpdateTraffic(vector<TrafficSegmentData> const & segmentsData); + void SetFontScaleFactor(double scaleFactor); + private: void AddUserEvent(drape_ptr<UserEvent> && e); void ModelViewChanged(ScreenBase const & screen); diff --git a/drape_frontend/text_layout.cpp b/drape_frontend/text_layout.cpp index a72e7f747e..009b69efe2 100644 --- a/drape_frontend/text_layout.cpp +++ b/drape_frontend/text_layout.cpp @@ -343,7 +343,7 @@ void TextLayout::Init(strings::UniString const & text, float fontSize, ref_ptr<dp::TextureManager> textures) { m_text = text; - m_textSizeRatio = fontSize / VisualParams::Instance().GetGlyphBaseSize(); + m_textSizeRatio = fontSize * VisualParams::Instance().GetFontScale() / VisualParams::Instance().GetGlyphBaseSize(); textures->GetGlyphRegions(text, m_metrics); } diff --git a/drape_frontend/visual_params.cpp b/drape_frontend/visual_params.cpp index 7f254b7e29..3089a50f26 100644 --- a/drape_frontend/visual_params.cpp +++ b/drape_frontend/visual_params.cpp @@ -57,6 +57,16 @@ uint32_t VisualParams::GetGlyphBaseSize() const return 22; } +double VisualParams::GetFontScale() const +{ + return m_fontScale; +} + +void VisualParams::SetFontScale(double fontScale) +{ + m_fontScale = fontScale; +} + VisualParams & VisualParams::Instance() { ASSERT_INITED; @@ -133,6 +143,7 @@ VisualParams::GlyphVisualParams const & VisualParams::GetGlyphVisualParams() con VisualParams::VisualParams() : m_tileSize(0) , m_visualScale(0.0) + , m_fontScale(1.0) { } diff --git a/drape_frontend/visual_params.hpp b/drape_frontend/visual_params.hpp index df5318a712..5d07162d3f 100644 --- a/drape_frontend/visual_params.hpp +++ b/drape_frontend/visual_params.hpp @@ -3,8 +3,8 @@ #include "geometry/rect2d.hpp" #include "geometry/screenbase.hpp" +#include "std/atomic.hpp" #include "std/cstdint.hpp" - #include "std/noncopyable.hpp" namespace df @@ -43,11 +43,14 @@ public: GlyphVisualParams const & GetGlyphVisualParams() const; uint32_t GetGlyphSdfScale() const; uint32_t GetGlyphBaseSize() const; + double GetFontScale() const; + void SetFontScale(double fontScale); private: int m_tileSize; double m_visualScale; GlyphVisualParams m_glyphVisualParams; + atomic<double> m_fontScale; }; m2::RectD const & GetWorldRect(); |