diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-06-04 17:13:13 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-04 17:13:54 +0100 |
commit | b5bd2d1d8d09a44af354584ff187d9e935ffd973 (patch) | |
tree | 3a2026f7cccd644635e6082f9d23996967ef9e8f /vcl/generic | |
parent | b8400dbf46aeffd5991f71511ae27368d46a5c40 (diff) |
Related: rhbz#968892 discard impossible languages for glyph fallback
Change-Id: I14f1bab09eb0be9c2c896a1dde45913b99aab6df
Diffstat (limited to 'vcl/generic')
-rw-r--r-- | vcl/generic/fontmanager/fontconfig.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx index 1b36980b9c46..ff471fae8c94 100644 --- a/vcl/generic/fontmanager/fontconfig.cxx +++ b/vcl/generic/fontmanager/fontconfig.cxx @@ -847,6 +847,41 @@ namespace #endif } + //returns true if the given code-point couldn't possibly be in rLangTag. + bool isImpossibleCodePointForLang(const LanguageTag &rLangTag, sal_uInt32 currentChar) + { + //a non-default script is set, lets believe it + if (rLangTag.hasScript()) + return false; + + int32_t script = u_getIntPropertyValue(currentChar, UCHAR_SCRIPT); + UScriptCode eScript = static_cast<UScriptCode>(script); + bool bIsImpossible = false; + OUString sLang = rLangTag.getLanguage(); + switch (eScript) + { + case USCRIPT_TELUGU: + bIsImpossible = sLang != "te"; + break; + case USCRIPT_BENGALI: + bIsImpossible = sLang != "bn" && + sLang != "as" && sLang != "mkb" && + sLang != "kfv" && sLang != "ccp" && + sLang != "tnv" && sLang != "ctg" && + sLang != "haj" && sLang != "ksy" && + sLang != "rkt" && sLang != "rjs" && + sLang != "rhg" && sLang != "syl" && + sLang != "kyv" && sLang != "zrg" && + sLang != "nhh"; + break; + default: + break; + } + SAL_WARN_IF(bIsImpossible, "vcl", "Throwing away user set language of " + << sLang << " for finding a font for glyph fallback and autodetecting instead"); + return bIsImpossible; + } + LanguageTag getExemplerLangTagForCodePoint(sal_uInt32 currentChar) { int32_t script = u_getIntPropertyValue(currentChar, UCHAR_SCRIPT); @@ -954,6 +989,10 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi // also handle unicode surrogates const sal_uInt32 nCode = rMissingCodes.iterateCodePoints( &nStrIndex ); FcCharSetAddChar( unicodes, nCode ); + //if the codepoint is impossible for this lang tag, then clear it + //and autodetect something useful + if (!aLangAttrib.isEmpty() && isImpossibleCodePointForLang(aLangTag, nCode)) + aLangAttrib = OString(); //#i105784#/rhbz#527719 improve selection of fallback font if (aLangAttrib.isEmpty()) { |