diff options
author | Hossein <hossein@libreoffice.org> | 2021-12-15 02:15:52 +0100 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2021-12-15 03:17:56 +0100 |
commit | ddd675c5a79b26d23da8d4affeeb888ac3664635 (patch) | |
tree | e9cc2b42ed677d6900697087da088e58a93736e5 /vcl/source/font | |
parent | 25ac6754d144a258d39cd9251677f3e35f4b3ee6 (diff) |
tdf#144961 vcl: fix CJK matching in FindFontFamilyByAttributes
Whilst testing CJK matching, I uncovered an issue. The matching
algorithm detects that the font is a CJK font if there are any CJK
characters in the font name. However, if you searched for a CJK font
against a font that was not a CJK font (i.e. the family name had no
CJK characters) then it would still match against this font family.
We now check if the font being matched against was a CJK font family
or not, if not then I reduced the testMatch value by CJK_MATCH_VALUE.
The fix can be tested with:
make CPPUNIT_TEST_NAME=testShouldNotFindCJKFamily -sr \
CppunitTest_vcl_font
Without the fix in place, the test fails with:
Test name: VclPhysicalFontCollectionTest::testShouldNotFindCJKFamily
assertion failed
- Expression: !aFontCollection.FindFontFamilyByAttributes( ImplFontAttrs::CJK, WEIGHT_NORMAL, WIDTH_NORMAL, ITALIC_NONE, "")
- family found
Change-Id: I18b246f151b2174dc4ae0f5507630a4e8e4bb442
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123309
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'vcl/source/font')
-rw-r--r-- | vcl/source/font/PhysicalFontCollection.cxx | 24 |
1 files changed, 17 insertions, 7 deletions
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 ) { |