diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-08-24 00:26:10 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-08-25 13:03:55 +0200 |
commit | 19787042b1f139cb9c366801d283c6c0227e85e6 (patch) | |
tree | 8a51f8e03f6d1a0cabb639376dd6b455a294149a /vcl/qa | |
parent | 7581fcde3c6a8d098a37b2c89c74e54696d4c346 (diff) |
FeatureCollector: Get feature labels for ssXX/cvXX features from the font
If the font provides feature labels for ssXX/cvXX features, fetch and
use them.
Switches also to using the UI language not locale for finding labels as
the UI language is what controls the UI localization.
Change-Id: Ic7eeae9df25692e7f2924b2db65905666999c904
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138748
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/FontFeatureTest.cxx | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/vcl/qa/cppunit/FontFeatureTest.cxx b/vcl/qa/cppunit/FontFeatureTest.cxx index 91bcda29b74f..103870306bcf 100644 --- a/vcl/qa/cppunit/FontFeatureTest.cxx +++ b/vcl/qa/cppunit/FontFeatureTest.cxx @@ -25,16 +25,18 @@ public: { } - void testGetFontFeatures(); + void testGetFontFeaturesGraphite(); + void testGetFontFeaturesOpenType(); void testParseFeature(); CPPUNIT_TEST_SUITE(FontFeatureTest); - CPPUNIT_TEST(testGetFontFeatures); + CPPUNIT_TEST(testGetFontFeaturesGraphite); + CPPUNIT_TEST(testGetFontFeaturesOpenType); CPPUNIT_TEST(testParseFeature); CPPUNIT_TEST_SUITE_END(); }; -void FontFeatureTest::testGetFontFeatures() +void FontFeatureTest::testGetFontFeaturesGraphite() { #if HAVE_MORE_FONTS ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(), @@ -118,6 +120,55 @@ void FontFeatureTest::testGetFontFeatures() #endif // HAVE_MORE_FONTS } +void FontFeatureTest::testGetFontFeaturesOpenType() +{ +#if HAVE_MORE_FONTS + ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(), + DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); + aVDev->SetOutputSizePixel(Size(10, 10)); + + OUString aFontName("Amiri"); + CPPUNIT_ASSERT(aVDev->IsFontAvailable(aFontName)); + + vcl::Font aFont = aVDev->GetFont(); + aFont.SetFamilyName(aFontName); + aFont.SetWeight(FontWeight::WEIGHT_NORMAL); + aFont.SetItalic(FontItalic::ITALIC_NORMAL); + aFont.SetWidthType(FontWidth::WIDTH_NORMAL); + aVDev->SetFont(aFont); + + std::vector<vcl::font::Feature> rFontFeatures; + CPPUNIT_ASSERT(aVDev->GetFontFeatures(rFontFeatures)); + + OUString aFeaturesString; + for (vcl::font::Feature const& rFeature : rFontFeatures) + aFeaturesString += vcl::font::featureCodeAsString(rFeature.m_nCode) + " "; + + CPPUNIT_ASSERT_EQUAL(size_t(17), rFontFeatures.size()); + + CPPUNIT_ASSERT_EQUAL(OUString("calt calt dnom liga numr pnum ss01 ss02 " + "ss03 ss04 ss05 ss06 ss07 ss08 kern kern " + "ss05 "), + aFeaturesString); + + // Check ss01 feature + { + vcl::font::Feature& rFeature = rFontFeatures[6]; + CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("ss01"), rFeature.m_nCode); + + vcl::font::FeatureDefinition& rFeatureDefinition = rFeature.m_aDefinition; + CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("ss01"), rFeatureDefinition.getCode()); + CPPUNIT_ASSERT_EQUAL(OUString("Low Baa dot following a Raa or Waw"), + rFeatureDefinition.getDescription()); + CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::BOOL, rFeatureDefinition.getType()); + + CPPUNIT_ASSERT_EQUAL(size_t(0), rFeatureDefinition.getEnumParameters().size()); + } + + aVDev.disposeAndClear(); +#endif // HAVE_MORE_FONTS +} + void FontFeatureTest::testParseFeature() { { // No font features specified |