[bugfix] Samsung Duos LDPI fix

This commit is contained in:
Darafei Praliaskouski 2013-05-03 18:22:02 +03:00 committed by Alex Zolotarev
parent 26ebb956f6
commit b2b326749b
5 changed files with 72 additions and 38 deletions

View file

@ -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<int>(pSrc->height() * scale);
// fonts smaller than 8px look "jumpy" on LDPI devices
uint8_t const h = max(8, static_cast<int>(pSrc->height() * scale));
offset = m2::PointD(0,0);
if (pSrc->has_offset_x())

View file

@ -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() };

View file

@ -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();

View file

@ -13,6 +13,67 @@
#include <sys/vfs.h>
#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)
{

View file

@ -148,3 +148,7 @@ bool Platform::GetFileSizeByFullPath(string const & filePath, uint64_t & size)
}
return false;
}
void Platform::GetSystemFontNames(FilesList & res) const
{
}