Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Wed, 2012-01-25 at 12:03 +0000, Caolán McNamara wrote:
Anyway, best would be to find the bit of locale matching code and see
why it doesn't do the right thing

The default fonts get selected via OutputDevice::GetDefaultFont in
vcl/source/gdi/outdev3.cxx which calls
DefaultFontConfiguration::getDefaultFont
in unotools/source/config/fontcfg.cxx which calls tryLocale with the
full locale string, then with variant cleared and then with Country
cleared if the earlier attempts fail

so...

if in master if I set my locale via export LANG=ta_IN.UTF-8 I get with
the attached debugging patch...

searching for a node for "ta" "IN" "" for type CTL_TEXT
result is ""
searching for a node for "ta" "" "" for type CTL_TEXT
result is "Lohit Tamil;Latha;Lucidasans;Lucida Sans;Arial Unicode MS"

so it does the right thing.

if I revert all the changes to officecfg I get..

searching for a node for "ta" "IN" "" for type CTL_TEXT
result is "Lohit Tamil;Latha;Lucidasans;Lucida Sans;Arial Unicode MS"

so it does the right thing there too for me.

So it seems to have been working correctly under Linux anyway. Can
you find out what the value of aLocale is in
OutputDevice::GetDefaultFont under windows for your failing case, i.e. a
trace with the attached patch in place.

C.
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index cab7eb3..7cac6ad 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -158,6 +158,11 @@ DefaultFontConfiguration::DefaultFontConfiguration()
                                 aLoc.Variant = OUString();
                             m_aConfig[ aLoc ] = LocaleAccess();
                             m_aConfig[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
+                            fprintf(stderr, "default-font entry for \"%s\" \"%s\" \"%s\" added\n",
+                                rtl::OUStringToOString(aLoc.Language, 
RTL_TEXTENCODING_UTF8).getStr(),
+                                rtl::OUStringToOString(aLoc.Country, 
RTL_TEXTENCODING_UTF8).getStr(),
+                                rtl::OUStringToOString(aLoc.Variant, 
RTL_TEXTENCODING_UTF8).getStr()
+                            );
                         }
                     }
                 }
@@ -193,6 +198,13 @@ DefaultFontConfiguration::~DefaultFontConfiguration()
 
 OUString DefaultFontConfiguration::tryLocale( const Locale& rLocale, const OUString& rType ) const
 {
+    fprintf(stderr, "searching for a node for \"%s\" \"%s\" \"%s\" for type %s\n",
+        rtl::OUStringToOString(rLocale.Language, RTL_TEXTENCODING_UTF8).getStr(),
+        rtl::OUStringToOString(rLocale.Country, RTL_TEXTENCODING_UTF8).getStr(),
+        rtl::OUStringToOString(rLocale.Variant, RTL_TEXTENCODING_UTF8).getStr(),
+        rtl::OUStringToOString(rType, RTL_TEXTENCODING_UTF8).getStr()
+    );
+
     OUString aRet;
 
     boost::unordered_map< Locale, LocaleAccess, LocaleHash >::const_iterator it =
@@ -237,6 +249,7 @@ OUString DefaultFontConfiguration::tryLocale( const Locale& rLocale, const OUStr
         }
     }
 
+    fprintf(stderr, "result is \"%s\"\n", rtl::OUStringToOString(aRet, 
RTL_TEXTENCODING_UTF8).getStr());
     return aRet;
 }
 
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index bf2628c..044375b 100755
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -474,6 +474,8 @@ Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang,
 {
     OSL_TRACE( "OutputDevice::GetDefaultFont()" );
 
+    fprintf(stderr, "vcl: search for font for lang %x of type %d\n", eLang, nType);
+
     com::sun::star::lang::Locale aLocale;
     if( eLang == LANGUAGE_NONE || eLang == LANGUAGE_SYSTEM || eLang == LANGUAGE_DONTKNOW )
     {
@@ -484,9 +486,20 @@ Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang,
         MsLangId::convertLanguageToLocale( eLang, aLocale );
     }
 
+    fprintf(stderr, "vcl: search for \"%s\" \"%s\" \"%s\"\n",
+        rtl::OUStringToOString(aLocale.Language, RTL_TEXTENCODING_UTF8).getStr(),
+        rtl::OUStringToOString(aLocale.Country, RTL_TEXTENCODING_UTF8).getStr(),
+        rtl::OUStringToOString(aLocale.Variant, RTL_TEXTENCODING_UTF8).getStr()
+    );
+
+
     utl::DefaultFontConfiguration& rDefaults = utl::DefaultFontConfiguration::get();
     String aSearch = rDefaults.getUserInterfaceFont( aLocale ); // ensure a fallback
     String aDefault = rDefaults.getDefaultFont( aLocale, nType );
+
+    fprintf(stderr, "vcl: default font string is %s\n", rtl::OUStringToOString(aDefault,
+        RTL_TEXTENCODING_UTF8).getStr());
+
     if( aDefault.Len() )
         aSearch = aDefault;
 

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.