summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-11 20:47:54 +0000
committerStephan Bergmann <sbergman@redhat.com>2012-01-12 13:29:46 +0100
commit29a7cd20ac892003e3bbc622657a6028adc83759 (patch)
treed8d640396a213b2528801d3e0d422c36a2568b09
parentd3dca82e81c32433756ab7d92b1b8f901b9b23b5 (diff)
Resolves:fdo#44078 fix unfortunate name alias mixups with DejaVu fonts
Cherry-picked from <http://cgit.freedesktop.org/libreoffice/core/commit/?h=libreoffice-3-5&id=25b90909a7a22f6900abbe9df12570a24e528c9a>. Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--vcl/unx/source/fontmanager/fontconfig.cxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx
index a60da2a7de..ab2ff6be1c 100644
--- a/vcl/unx/source/fontmanager/fontconfig.cxx
+++ b/vcl/unx/source/fontmanager/fontconfig.cxx
@@ -297,7 +297,7 @@ public:
boost::unordered_map< rtl::OString, rtl::OString, rtl::OStringHash > m_aFontNameToLocalized;
boost::unordered_map< rtl::OString, rtl::OString, rtl::OStringHash > m_aLocalizedToCanonical;
private:
- void cacheLocalizedFontNames(FcChar8 *origfontname, FcChar8 *bestfontname, const std::vector< lang_and_element > &lang_and_elements);
+ void cacheLocalizedFontNames(const FcChar8 *origfontname, const FcChar8 *bestfontname, const std::vector< lang_and_element > &lang_and_elements);
};
oslGenericFunction FontCfgWrapper::loadSymbol( const char* pSymbol )
@@ -659,6 +659,7 @@ namespace
std::vector<lang_and_element>::const_iterator aEnd = elements.end();
bool alreadyclosematch = false;
+ bool found_fallback_englishname = false;
for( std::vector<lang_and_element>::const_iterator aIter = elements.begin(); aIter != aEnd; ++aIter )
{
const char *pLang = (const char*)aIter->first;
@@ -670,7 +671,8 @@ namespace
}
else if( alreadyclosematch )
{
- // override candidate only if there is a perfect match
+ // current candidate matches lang of lang-TERRITORY
+ // override candidate only if there is a full match
continue;
}
else if( rtl_str_compare( pLang, sLangMatch.getStr()) == 0)
@@ -679,10 +681,18 @@ namespace
candidate = aIter->second;
alreadyclosematch = true;
}
+ else if( found_fallback_englishname )
+ {
+ // already found an english fallback, don't override candidate
+ // unless there is a better language match
+ continue;
+ }
else if( rtl_str_compare( pLang, "en") == 0)
{
- // fallback to the english element name
+ // select a fallback candidate of the first english element
+ // name
candidate = aIter->second;
+ found_fallback_englishname = true;
}
}
return candidate;
@@ -690,7 +700,8 @@ namespace
}
//Set up maps to quickly map between a fonts best UI name and all the rest of its names, and vice versa
-void FontCfgWrapper::cacheLocalizedFontNames(FcChar8 *origfontname, FcChar8 *bestfontname, const std::vector< lang_and_element > &lang_and_elements)
+void FontCfgWrapper::cacheLocalizedFontNames(const FcChar8 *origfontname, const FcChar8 *bestfontname,
+ const std::vector< lang_and_element > &lang_and_elements)
{
std::vector<lang_and_element>::const_iterator aEnd = lang_and_elements.end();
for (std::vector<lang_and_element>::const_iterator aIter = lang_and_elements.begin(); aIter != aEnd; ++aIter)