From 098f95ab8235710d2a555a17e640b407b6c09153 Mon Sep 17 00:00:00 2001 From: vng Date: Tue, 11 Nov 2014 17:53:37 +0300 Subject: [PATCH] [android] Fixed fonts getting routine. Made it simple and fast. --- map/framework.cpp | 2 +- platform/platform.cpp | 37 +++++++++++++-------------------- platform/platform_unix_impl.cpp | 13 ++++-------- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 94ac13ad49..f090090cae 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -173,7 +173,7 @@ void Framework::GetMaps(vector & maps) const pl.GetFilesByExt(pl.ResourcesDir(), DATA_FILE_EXTENSION, maps); pl.GetFilesByExt(pl.WritableDir(), DATA_FILE_EXTENSION, maps); - // Remove duplicate maps if they're both present in resources and in WritableDir. + // Remove duplicate maps if they're both present in Resources and in Writable dirs. sort(maps.begin(), maps.end()); maps.erase(unique(maps.begin(), maps.end()), maps.end()); diff --git a/platform/platform.cpp b/platform/platform.cpp index bf2e1adaf7..5f713d53a7 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -65,30 +65,23 @@ string Platform::DefaultUrlsJSON() const void Platform::GetFontNames(FilesList & res) const { + ASSERT(res.empty(), ()); + + /// @todo Actually, this list should present once in all our code. + /// We can take it from data/external_resources.txt + char const * arrDef[] = { + "00_roboto_regular.ttf", + "01_dejavusans.ttf", + "02_wqy-microhei.ttf", + "03_jomolhari-id-a3d.ttf", + "04_padauk.ttf", + "05_khmeros.ttf", + "06_code2000.ttf", + }; + res.insert(res.end(), arrDef, arrDef + ARRAY_SIZE(arrDef)); + GetSystemFontNames(res); - size_t n = 0; - string const * arrPaths[4]; - - arrPaths[n++] = &m_writableDir; -#ifdef OMIM_OS_ANDROID - for (size_t i = 0; i < m_extResFiles.size(); ++i) - arrPaths[n++] = &m_extResFiles[i]; -#else - arrPaths[n++] = &m_resourcesDir; -#endif - - FilesList fonts; - for (size_t i = 0; i < n; ++i) - { - LOG(LDEBUG, ("Searching for fonts in", *(arrPaths[i]))); - GetFilesByExt(*(arrPaths[i]), FONT_FILE_EXTENSION, fonts); - } - - sort(fonts.begin(), fonts.end()); - fonts.erase(unique(fonts.begin(), fonts.end()), fonts.end()); - res.insert(res.end(), fonts.begin(), fonts.end()); - LOG(LINFO, ("Available font files:", (res))); } diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp index 64bd6851af..f344b2612b 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -50,17 +50,11 @@ void Platform::GetSystemFontNames(FilesList & res) const "DejaVuSans.ttf", "arial.ttf", "AbyssinicaSIL-R.ttf", - "00_roboto_regular.ttf", - "01_dejavusans.ttf", - "02_wqy-microhei.ttf", - "03_jomolhari-id-a3d.ttf", - "04_padauk.ttf", - "05_khmeros.ttf", - "06_code2000.ttf" }; char const * systemFontsPath[] = { "/system/fonts/", +#ifdef OMIM_OS_LINUX "/usr/share/fonts/truetype/roboto/", "/usr/share/fonts/truetype/droid/", "/usr/share/fonts/truetype/ttf-dejavu/", @@ -72,9 +66,10 @@ void Platform::GetSystemFontNames(FilesList & res) const "/usr/share/fonts/truetype/tlwg/", "/usr/share/fonts/truetype/abyssinica/", "/usr/share/fonts/truetype/paktype/", - "/usr/share/fonts/truetype/mapswithme/" + "/usr/share/fonts/truetype/mapswithme/", +#endif }; - + const uint64_t fontSizeBlacklist[] = { 183560, // Samsung Duos DroidSans 7140172, // Serif font without Emoji