summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/qa/cppunit/physicalfontcollection.cxx14
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx24
2 files changed, 31 insertions, 7 deletions
diff --git a/vcl/qa/cppunit/physicalfontcollection.cxx b/vcl/qa/cppunit/physicalfontcollection.cxx
index a147fb1dea4f..7df20ce76b66 100644
--- a/vcl/qa/cppunit/physicalfontcollection.cxx
+++ b/vcl/qa/cppunit/physicalfontcollection.cxx
@@ -35,6 +35,7 @@ public:
void testShouldFindFontFamilyByTokenNames();
void testShouldFindNoFamilyWithWorthlessAttributes();
void testShouldFindCJKFamily();
+ void testShouldNotFindCJKFamily();
void testShouldFindStarsymbolFamily();
void testShouldFindOpensymbolFamilyWithMultipleSymbolFamilies();
void testShouldFindSymboltypeFamily();
@@ -65,6 +66,7 @@ public:
CPPUNIT_TEST(testShouldFindFontFamilyByTokenNames);
CPPUNIT_TEST(testShouldFindNoFamilyWithWorthlessAttributes);
CPPUNIT_TEST(testShouldFindCJKFamily);
+ CPPUNIT_TEST(testShouldNotFindCJKFamily);
CPPUNIT_TEST(testShouldFindStarsymbolFamily);
CPPUNIT_TEST(testShouldFindOpensymbolFamilyWithMultipleSymbolFamilies);
CPPUNIT_TEST(testShouldFindSymboltypeFamily);
@@ -186,6 +188,18 @@ void VclPhysicalFontCollectionTest::testShouldFindCJKFamily()
pCJKFamily->GetSearchName());
}
+void VclPhysicalFontCollectionTest::testShouldNotFindCJKFamily()
+{
+ vcl::font::PhysicalFontCollection aFontCollection;
+ vcl::font::PhysicalFontFamily* pFontFamily
+ = aFontCollection.FindOrCreateFontFamily(GetEnglishSearchFontName(u"No CJK characters"));
+ AddNormalFontFace(pFontFamily, "No CJK characters");
+
+ CPPUNIT_ASSERT_MESSAGE("family found",
+ !aFontCollection.FindFontFamilyByAttributes(
+ ImplFontAttrs::CJK, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE, ""));
+}
+
void VclPhysicalFontCollectionTest::testShouldFindStarsymbolFamily()
{
vcl::font::PhysicalFontCollection aFontCollection;
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 0cb503a7df54..211e4e65bd57 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -445,13 +445,23 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes(ImplFontA
// test CJK script attributes
if ( nSearchType & ImplFontAttrs::CJK )
{
- // Matching language
- if( ImplFontAttrs::None == ((nSearchType ^ nMatchType) & ImplFontAttrs::CJK_AllLang) )
- nTestMatch += 10000000*3;
- if( nMatchType & ImplFontAttrs::CJK )
- nTestMatch += 10000000*2;
- if( nMatchType & ImplFontAttrs::Full )
- nTestMatch += 10000000;
+ // if the matching font doesn't support any CJK languages, then
+ // it is not appropriate
+ if ( !(nMatchType & ImplFontAttrs::CJK_AllLang) )
+ {
+ nTestMatch -= 10000000;
+ }
+ else
+ {
+ // Matching language
+ if ( (nSearchType & ImplFontAttrs::CJK_AllLang)
+ && (nMatchType & ImplFontAttrs::CJK_AllLang) )
+ nTestMatch += 10000000*3;
+ if ( nMatchType & ImplFontAttrs::CJK )
+ nTestMatch += 10000000*2;
+ if ( nMatchType & ImplFontAttrs::Full )
+ nTestMatch += 10000000;
+ }
}
else if ( nMatchType & ImplFontAttrs::CJK )
{