diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2023-11-09 18:19:41 +1100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-12-05 04:39:05 +0100 |
commit | 042dc4a9186f526b625817dde50bb2f5a91fd2c6 (patch) | |
tree | dcb3195ade7cae900ffc49bcf0fe80fb5a388c86 /vcl/qa | |
parent | 1a74a87b442857567d20da5dc97bbbc278745afd (diff) |
vcl: add unit tests for a mixture of CJK and latin characters
To influence the fallback fonts chosen, I have introduced a new
OutputDevice function ForceFallbackFont() which injects ("forces") a
font as the first one in the font fallback chain.
Change-Id: I05856cbe829fde0eb140bb48a37795a84d780900
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159221
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/complextext.cxx | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx index 633dc2210e07..d4eb3db67093 100644 --- a/vcl/qa/cppunit/complextext.cxx +++ b/vcl/qa/cppunit/complextext.cxx @@ -491,6 +491,40 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf153440) #endif } +CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testMixedCJKLatinScript_glyph_advancements) +{ +#if HAVE_MORE_FONTS +#if !defined _WIN32 + OUString aTestScript(u"根据10.1(37BA) Eng"_ustr); + + ScopedVclPtrInstance<VirtualDevice> pOutDev; + // note you can only run this once and it was designed for tdf#107718 + bool bAdded = addFont(pOutDev, u"tdf107718.otf", u"Source Han Sans"); + CPPUNIT_ASSERT_EQUAL(true, bAdded); + + vcl::Font aFont(u"Source Han Sans"_ustr, u"Regular"_ustr, Size(0, 72)); + pOutDev->SetFont( aFont ); + + vcl::Font aFallbackFont("DejaVu Sans", "Book", Size(0, 72)); + pOutDev->ForceFallbackFont(aFallbackFont); + + // absolute character widths AKA text array. + tools::Long nRefTextWidth = 704; + std::vector<sal_Int32> aRefCharWidths = { 72, 144, 190, 236, 259, 305, 333, 379, 425, 474, 523, 551, 567, 612, 658, 704 }; + KernArray aCharWidths; + tools::Long nTextWidth = pOutDev->GetTextArray(aTestScript, &aCharWidths); + + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + + // text advance width and line height + CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aTestScript)); + CPPUNIT_ASSERT_EQUAL(tools::Long(105), pOutDev->GetTextHeight()); +#endif +#endif +} + CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718) { #if !defined _WIN32 // TODO: Fails on jenkins but passes locally @@ -498,9 +532,6 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718) ScopedVclPtrInstance<VirtualDevice> pOutDev; - bool bAdded = addFont(pOutDev, u"tdf107718.otf", u"Source Han Sans"); - CPPUNIT_ASSERT_EQUAL(true, bAdded); - OUString aText(u"\u4E16\u1109\u1168\u11BC\u302E"_ustr); for (bool bVertical : { false, true }) { |