diff --git a/map/proto_to_styles.cpp b/map/proto_to_styles.cpp index d8a09ed51b..162e6adf1f 100644 --- a/map/proto_to_styles.cpp +++ b/map/proto_to_styles.cpp @@ -122,7 +122,8 @@ void ConvertStyle(CircleRuleProto const * pSrc, double scale, graphics::Circle:: void ConvertStyle(CaptionDefProto const * pSrc, double scale, graphics::FontDesc & dest, m2::PointD & offset) { - uint8_t const h = static_cast(pSrc->height() * scale); + // fonts smaller than 8px look "jumpy" on LDPI devices + uint8_t const h = max(8, static_cast(pSrc->height() * scale)); offset = m2::PointD(0,0); if (pSrc->has_offset_x()) diff --git a/platform/platform.cpp b/platform/platform.cpp index bd5688f728..972c42d213 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -58,43 +58,7 @@ string Platform::DefaultUrlsJSON() const void Platform::GetFontNames(FilesList & res) const { - char const * fontsWhitelist[] = { - "Roboto-Regular.ttf", - "DroidSansArabic.ttf", - "DroidNaskh-Regular.ttf", - "Lohit-Bengali.ttf", - "Lohit-Devanagari.ttf", - "Lohit-Tamil.ttf", - "DroidSansThai.ttf", - "DroidSans.ttf", - "DroidSansArmenian.ttf", - "DroidSansEthiopic-Regular.ttf", - "DroidSansGeorgian.ttf", - "DroidSansHebrew-Regular.ttf", - "DroidSansHebrew.ttf", - "DroidSansJapanese.ttf", - "DroidSansFallback.ttf", - "LTe50872.ttf", - "LTe50259.ttf", - "DejaVuSans.ttf", - "arial.ttf" - }; - - char const * systemFontsPath[] = { - "/system/fonts/", - "/usr/share/fonts/truetype/droid/", - "/usr/share/fonts/truetype/ttf-dejavu/", - }; - - for (size_t i = 0; i < ARRAY_SIZE(fontsWhitelist); ++i) - { - for (size_t j = 0; j < ARRAY_SIZE(systemFontsPath); ++j) - { - string const path = string(systemFontsPath[j]) + fontsWhitelist[i]; - if (IsFileExistsByFullPath(path)) - res.push_back(path); - }; - }; + GetSystemFontNames(res); string const resourcesPaths[] = { WritableDir(), ResourcesDir() }; diff --git a/platform/platform.hpp b/platform/platform.hpp index b826dc970e..89c87ac1d9 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -129,6 +129,10 @@ public: /// @return JSON-encoded list of urls if metaserver is unreachable string DefaultUrlsJSON() const; + +private: + void GetSystemFontNames(FilesList & res) const; + }; extern Platform & GetPlatform(); diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp index d16291c1e7..6c11ecd16d 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -13,6 +13,67 @@ #include #endif +void Platform::GetSystemFontNames(FilesList & res) const +{ +#if defined(OMIM_OS_MAC) || defined(OMIM_OS_IPHONE) +#else + char const * fontsWhitelist[] = { + "Roboto-Regular.ttf", + "DroidSansFallback.ttf", + "DroidSans.ttf", + "DroidSansArabic.ttf", + "DroidNaskh-Regular.ttf", + "Lohit-Bengali.ttf", + "Lohit-Devanagari.ttf", + "Lohit-Tamil.ttf", + "DroidSansThai.ttf", + "DroidSansArmenian.ttf", + "DroidSansEthiopic-Regular.ttf", + "DroidSansGeorgian.ttf", + "DroidSansHebrew-Regular.ttf", + "DroidSansHebrew.ttf", + "DroidSansJapanese.ttf", + "LTe50872.ttf", + "LTe50259.ttf", + "DejaVuSans.ttf", + "arial.ttf" + }; + + char const * systemFontsPath[] = { + "/system/fonts/", + "/usr/share/fonts/truetype/droid/", + "/usr/share/fonts/truetype/ttf-dejavu/", + }; + + uint64_t fileSize = 0; + + for (size_t i = 0; i < ARRAY_SIZE(fontsWhitelist); ++i) + { + for (size_t j = 0; j < ARRAY_SIZE(systemFontsPath); ++j) + { + string const path = string(systemFontsPath[j]) + fontsWhitelist[i]; + if (IsFileExistsByFullPath(path)) + { + if (GetFileSizeByName(path, fileSize)) + { + res.push_back(path); + LOG(LINFO, ("Found system font", path, "with file size", fileSize)); + } + } + } + } + + // Ignoring system fonts if broken Samsung Duos font detected + if (GetPlatform().GetFileSizeByName("/system/fonts/DroidSans.ttf", fileSize)) + { + if (fileSize == 183560) + { + res.clear(); + LOG(LINFO, ("Ignoring system fonts")); + } + } +#endif +} bool Platform::IsFileExistsByFullPath(string const & filePath) { diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index 43541563e9..e7058814e2 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -148,3 +148,7 @@ bool Platform::GetFileSizeByFullPath(string const & filePath, uint64_t & size) } return false; } + +void Platform::GetSystemFontNames(FilesList & res) const +{ +}