[Libreoffice-commits] core.git: svtools/source

Matthew J. Francis mjay.francis at gmail.com
Tue Sep 2 14:00:43 PDT 2014


 svtools/source/misc/sampletext.cxx |   34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

New commits:
commit b6e581aec7f32fed8afeda1ca72ee613c6ac251a
Author: Matthew J. Francis <mjay.francis at gmail.com>
Date:   Sun Aug 31 11:28:44 2014 +0800

    fdo#82259 Hardcode script for "GB18030 Bitmap"
    
    Change-Id: I3b3ad955f1793197e970c837ff53aa85a74b8cfb
    Reviewed-on: https://gerrit.libreoffice.org/11213
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx
index b7e416d..2800cc2 100644
--- a/svtools/source/misc/sampletext.cxx
+++ b/svtools/source/misc/sampletext.cxx
@@ -13,6 +13,20 @@
 #include <vcl/metric.hxx>
 #include <i18nutil/unicode.hxx>
 
+// This should only be used when a commonly used font incorrectly declares its
+// coverage. If you add a font here, please leave a note explaining the issue
+// that caused it to be added
+static UScriptCode lcl_getHardCodedScriptNameForFont (const OutputDevice &rDevice)
+{
+    // As of OSX 10.9, the system font "GB18030 Bitmap" incorrectly declares
+    // that it only covers "Phoenician" when in fact it's a Chinese font.
+    if (rDevice.GetFont().GetName().equalsIgnoreAsciiCase("GB18030 Bitmap")) {
+        return USCRIPT_HAN;
+    }
+
+    return USCRIPT_INVALID_CODE;
+}
+
 bool isOpenSymbolFont(const Font &rFont)
 {
     return rFont.GetName().equalsIgnoreAsciiCase("starsymbol") ||
@@ -1191,14 +1205,20 @@ OUString makeShortRepresentativeTextForSelectedFont(OutputDevice &rDevice)
 
     aFontCapabilities.maUnicodeRange &= getCommonLatnSubsetMask();
 
-    //If this font is probably tuned to display a single non-Latin
-    //script and the font name is itself in Latin, then show a small
-    //chunk of representative text for that script
-    UScriptCode eScript = getScript(aFontCapabilities);
-    if (eScript == USCRIPT_COMMON)
-        return OUString();
+    UScriptCode eScript = lcl_getHardCodedScriptNameForFont (rDevice);
+
+    if (eScript == USCRIPT_INVALID_CODE) {
+
+        //If this font is probably tuned to display a single non-Latin
+        //script and the font name is itself in Latin, then show a small
+        //chunk of representative text for that script
+        eScript = getScript(aFontCapabilities);
+        if (eScript == USCRIPT_COMMON)
+            return OUString();
 
-    eScript = attemptToDisambiguateHan(eScript, rDevice);
+        eScript = attemptToDisambiguateHan(eScript, rDevice);
+
+    }
 
     OUString sSampleText = makeShortRepresentativeTextForScript(eScript);
     bool bHasSampleTextGlyphs = (-1 == rDevice.HasGlyphs(rDevice.GetFont(), sSampleText));


More information about the Libreoffice-commits mailing list