From b6e581aec7f32fed8afeda1ca72ee613c6ac251a Mon Sep 17 00:00:00 2001 From: "Matthew J. Francis" Date: Sun, 31 Aug 2014 11:28:44 +0800 Subject: fdo#82259 Hardcode script for "GB18030 Bitmap" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3b3ad955f1793197e970c837ff53aa85a74b8cfb Reviewed-on: https://gerrit.libreoffice.org/11213 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svtools/source/misc/sampletext.cxx | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'svtools/source/misc/sampletext.cxx') diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx index b7e416de8a6c..2800cc220e5e 100644 --- a/svtools/source/misc/sampletext.cxx +++ b/svtools/source/misc/sampletext.cxx @@ -13,6 +13,20 @@ #include #include +// 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)); -- cgit