1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/bootstrapfixture.hxx>
11 #include <config_features.h>
12 #include <config_fonts.h>
13 #include <cppunit/TestAssert.h>
15 #include <vcl/font/Feature.hxx>
16 #include <vcl/font/FeatureParser.hxx>
17 #include <vcl/virdev.hxx>
18 #include <vcl/svapp.hxx>
20 class FontFeatureTest
: public test::BootstrapFixture
24 : BootstrapFixture(true, false)
28 void testGetFontFeaturesGraphite();
29 void testGetFontFeaturesOpenType();
30 void testGetFontFeaturesOpenTypeEnum();
31 void testParseFeature();
33 CPPUNIT_TEST_SUITE(FontFeatureTest
);
34 CPPUNIT_TEST(testGetFontFeaturesGraphite
);
35 CPPUNIT_TEST(testGetFontFeaturesOpenType
);
36 CPPUNIT_TEST(testGetFontFeaturesOpenTypeEnum
);
37 CPPUNIT_TEST(testParseFeature
);
38 CPPUNIT_TEST_SUITE_END();
41 void FontFeatureTest::testGetFontFeaturesGraphite()
44 ScopedVclPtrInstance
<VirtualDevice
> aVDev(*Application::GetDefaultDevice(),
45 DeviceFormat::DEFAULT
, DeviceFormat::DEFAULT
);
46 aVDev
->SetOutputSizePixel(Size(10, 10));
48 OUString
aFontName("Linux Libertine G");
49 CPPUNIT_ASSERT(aVDev
->IsFontAvailable(aFontName
));
51 vcl::Font aFont
= aVDev
->GetFont();
52 aFont
.SetFamilyName(aFontName
);
53 aFont
.SetWeight(FontWeight::WEIGHT_NORMAL
);
54 aFont
.SetItalic(FontItalic::ITALIC_NORMAL
);
55 aFont
.SetWidthType(FontWidth::WIDTH_NORMAL
);
56 aVDev
->SetFont(aFont
);
58 std::vector
<vcl::font::Feature
> rFontFeatures
;
59 CPPUNIT_ASSERT(aVDev
->GetFontFeatures(rFontFeatures
));
61 OUString aFeaturesString
;
62 for (vcl::font::Feature
const& rFeature
: rFontFeatures
)
64 aFeaturesString
+= vcl::font::featureCodeAsString(rFeature
.m_nCode
) + " ";
67 CPPUNIT_ASSERT_EQUAL(size_t(53), rFontFeatures
.size());
69 CPPUNIT_ASSERT_EQUAL(OUString("c2sc case dlig fina frac hlig liga lnum "
70 "locl onum pnum sa01 sa02 sa03 sa04 sa05 "
71 "sa06 sa07 sa08 salt sinf smcp ss01 ss02 "
72 "ss03 sups tnum zero ingl cpsp lith litt "
73 "itlc para algn arti circ dash dbls foot "
74 "frsp grkn hang lng minu nfsp name quot "
75 "texm thou vari caps ligc "),
80 vcl::font::Feature
& rFeature
= rFontFeatures
[0];
81 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("c2sc"), rFeature
.m_nCode
);
83 vcl::font::FeatureDefinition
& rFracFeatureDefinition
= rFeature
.m_aDefinition
;
84 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("c2sc"), rFracFeatureDefinition
.getCode());
85 CPPUNIT_ASSERT(!rFracFeatureDefinition
.getDescription().isEmpty());
86 CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::BOOL
,
87 rFracFeatureDefinition
.getType());
89 CPPUNIT_ASSERT_EQUAL(size_t(0), rFracFeatureDefinition
.getEnumParameters().size());
94 vcl::font::Feature
& rFeature
= rFontFeatures
[4];
95 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("frac"), rFeature
.m_nCode
);
97 vcl::font::FeatureDefinition
& rFracFeatureDefinition
= rFeature
.m_aDefinition
;
98 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("frac"), rFracFeatureDefinition
.getCode());
99 CPPUNIT_ASSERT(!rFracFeatureDefinition
.getDescription().isEmpty());
100 CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::ENUM
,
101 rFracFeatureDefinition
.getType());
103 CPPUNIT_ASSERT_EQUAL(size_t(3), rFracFeatureDefinition
.getEnumParameters().size());
105 vcl::font::FeatureParameter
const& rParameter1
106 = rFracFeatureDefinition
.getEnumParameters()[0];
107 CPPUNIT_ASSERT_EQUAL(uint32_t(0), rParameter1
.getCode());
108 CPPUNIT_ASSERT(!rParameter1
.getDescription().isEmpty());
110 vcl::font::FeatureParameter
const& rParameter2
111 = rFracFeatureDefinition
.getEnumParameters()[1];
112 CPPUNIT_ASSERT_EQUAL(uint32_t(1), rParameter2
.getCode());
113 CPPUNIT_ASSERT(!rParameter2
.getDescription().isEmpty());
115 vcl::font::FeatureParameter
const& rParameter3
116 = rFracFeatureDefinition
.getEnumParameters()[2];
117 CPPUNIT_ASSERT_EQUAL(uint32_t(2), rParameter3
.getCode());
118 CPPUNIT_ASSERT(!rParameter2
.getDescription().isEmpty());
121 aVDev
.disposeAndClear();
122 #endif // HAVE_MORE_FONTS
125 void FontFeatureTest::testGetFontFeaturesOpenType()
128 ScopedVclPtrInstance
<VirtualDevice
> aVDev(*Application::GetDefaultDevice(),
129 DeviceFormat::DEFAULT
, DeviceFormat::DEFAULT
);
130 aVDev
->SetOutputSizePixel(Size(10, 10));
132 OUString
aFontName("Amiri");
133 CPPUNIT_ASSERT(aVDev
->IsFontAvailable(aFontName
));
135 vcl::Font aFont
= aVDev
->GetFont();
136 aFont
.SetFamilyName(aFontName
);
137 aFont
.SetWeight(FontWeight::WEIGHT_NORMAL
);
138 aFont
.SetItalic(FontItalic::ITALIC_NORMAL
);
139 aFont
.SetWidthType(FontWidth::WIDTH_NORMAL
);
140 aVDev
->SetFont(aFont
);
142 std::vector
<vcl::font::Feature
> rFontFeatures
;
143 CPPUNIT_ASSERT(aVDev
->GetFontFeatures(rFontFeatures
));
145 OUString aFeaturesString
;
146 for (vcl::font::Feature
const& rFeature
: rFontFeatures
)
147 aFeaturesString
+= vcl::font::featureCodeAsString(rFeature
.m_nCode
) + " ";
149 CPPUNIT_ASSERT_EQUAL(size_t(17), rFontFeatures
.size());
151 CPPUNIT_ASSERT_EQUAL(OUString("calt calt dnom liga numr pnum ss01 ss02 "
152 "ss03 ss04 ss05 ss06 ss07 ss08 kern kern "
156 // Check ss01 feature
158 vcl::font::Feature
& rFeature
= rFontFeatures
[6];
159 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("ss01"), rFeature
.m_nCode
);
161 vcl::font::FeatureDefinition
& rFeatureDefinition
= rFeature
.m_aDefinition
;
162 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("ss01"), rFeatureDefinition
.getCode());
163 CPPUNIT_ASSERT_EQUAL(OUString("Low Baa dot following a Raa or Waw"),
164 rFeatureDefinition
.getDescription());
165 CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::BOOL
, rFeatureDefinition
.getType());
167 CPPUNIT_ASSERT_EQUAL(size_t(0), rFeatureDefinition
.getEnumParameters().size());
170 aVDev
.disposeAndClear();
171 #endif // HAVE_MORE_FONTS
174 void FontFeatureTest::testGetFontFeaturesOpenTypeEnum()
177 ScopedVclPtrInstance
<VirtualDevice
> aVDev(*Application::GetDefaultDevice(),
178 DeviceFormat::DEFAULT
, DeviceFormat::DEFAULT
);
179 aVDev
->SetOutputSizePixel(Size(10, 10));
181 OUString
aFontName("Reem Kufi");
182 CPPUNIT_ASSERT(aVDev
->IsFontAvailable(aFontName
));
184 vcl::Font aFont
= aVDev
->GetFont();
185 aFont
.SetFamilyName(aFontName
);
186 aFont
.SetWeight(FontWeight::WEIGHT_NORMAL
);
187 aFont
.SetItalic(FontItalic::ITALIC_NORMAL
);
188 aFont
.SetWidthType(FontWidth::WIDTH_NORMAL
);
189 aVDev
->SetFont(aFont
);
191 std::vector
<vcl::font::Feature
> rFontFeatures
;
192 CPPUNIT_ASSERT(aVDev
->GetFontFeatures(rFontFeatures
));
194 OUString aFeaturesString
;
195 for (vcl::font::Feature
const& rFeature
: rFontFeatures
)
196 aFeaturesString
+= vcl::font::featureCodeAsString(rFeature
.m_nCode
) + " ";
198 CPPUNIT_ASSERT_EQUAL(size_t(10), rFontFeatures
.size());
200 CPPUNIT_ASSERT_EQUAL(OUString("aalt case cv01 cv02 cv03 frac ordn sups "
204 // Check aalt feature
206 vcl::font::Feature
& rFeature
= rFontFeatures
[0];
207 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("aalt"), rFeature
.m_nCode
);
209 vcl::font::FeatureDefinition
& rFeatureDefinition
= rFeature
.m_aDefinition
;
210 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("aalt"), rFeatureDefinition
.getCode());
211 CPPUNIT_ASSERT(!rFeatureDefinition
.getDescription().isEmpty());
212 CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::ENUM
, rFeatureDefinition
.getType());
214 CPPUNIT_ASSERT_EQUAL(size_t(3), rFeatureDefinition
.getEnumParameters().size());
216 vcl::font::FeatureParameter
const& rParameter1
= rFeatureDefinition
.getEnumParameters()[0];
217 CPPUNIT_ASSERT_EQUAL(uint32_t(0), rParameter1
.getCode());
218 CPPUNIT_ASSERT(!rParameter1
.getDescription().isEmpty());
220 vcl::font::FeatureParameter
const& rParameter2
= rFeatureDefinition
.getEnumParameters()[1];
221 CPPUNIT_ASSERT_EQUAL(uint32_t(1), rParameter2
.getCode());
222 CPPUNIT_ASSERT(!rParameter2
.getDescription().isEmpty());
224 vcl::font::FeatureParameter
const& rParameter3
= rFeatureDefinition
.getEnumParameters()[2];
225 CPPUNIT_ASSERT_EQUAL(uint32_t(2), rParameter3
.getCode());
226 CPPUNIT_ASSERT(!rParameter2
.getDescription().isEmpty());
229 aVDev
.disposeAndClear();
230 #endif // HAVE_MORE_FONTS
233 void FontFeatureTest::testParseFeature()
235 { // No font features specified
236 vcl::font::FeatureParser
aParser(u
"Font name with no features");
237 CPPUNIT_ASSERT_EQUAL(size_t(0), aParser
.getFeatures().size());
239 { // One feature specified, no value
240 vcl::font::FeatureParser
aParser(u
"Font name:abcd");
241 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
242 auto aFeatures
= aParser
.getFeatures();
244 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
245 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
247 { // One feature specified, explicit value
248 vcl::font::FeatureParser
aParser(u
"Font name:abcd=5");
249 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
250 auto aFeatures
= aParser
.getFeatures();
252 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
253 CPPUNIT_ASSERT_EQUAL(uint32_t(5), aFeatures
[0].m_nValue
);
255 { // One feature specified, explicit zero value
256 vcl::font::FeatureParser
aParser(u
"Font name:abcd=0");
257 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
258 auto aFeatures
= aParser
.getFeatures();
260 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
261 CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures
[0].m_nValue
);
263 { // One feature specified, using plus prefix
264 vcl::font::FeatureParser
aParser(u
"Font name:+abcd");
265 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
266 auto aFeatures
= aParser
.getFeatures();
268 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
269 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
271 { // One feature specified, using minus prefix
272 vcl::font::FeatureParser
aParser(u
"Font name:-abcd");
273 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
274 auto aFeatures
= aParser
.getFeatures();
276 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
277 CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures
[0].m_nValue
);
279 { // One feature specified, with empty character range
280 vcl::font::FeatureParser
aParser(u
"Font name:abcd[]");
281 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
282 auto aFeatures
= aParser
.getFeatures();
284 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
285 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
286 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), aFeatures
[0].m_nStart
);
287 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures
[0].m_nEnd
);
289 { // One feature specified, with empty character range
290 vcl::font::FeatureParser
aParser(u
"Font name:abcd[:]");
291 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
292 auto aFeatures
= aParser
.getFeatures();
294 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
295 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
296 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), aFeatures
[0].m_nStart
);
297 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures
[0].m_nEnd
);
299 { // One feature specified, with start character range
300 vcl::font::FeatureParser
aParser(u
"Font name:abcd[3:]");
301 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
302 auto aFeatures
= aParser
.getFeatures();
304 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
305 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
306 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nStart
);
307 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures
[0].m_nEnd
);
309 { // One feature specified, with end character range
310 vcl::font::FeatureParser
aParser(u
"Font name:abcd[:3]");
311 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
312 auto aFeatures
= aParser
.getFeatures();
314 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
315 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
316 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), aFeatures
[0].m_nStart
);
317 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nEnd
);
319 { // One feature specified, with character range
320 vcl::font::FeatureParser
aParser(u
"Font name:abcd[3:6]");
321 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
322 auto aFeatures
= aParser
.getFeatures();
324 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
325 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
326 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nStart
);
327 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures
[0].m_nEnd
);
329 { // One feature specified, with character range
330 vcl::font::FeatureParser
aParser(u
"Font name:abcd[3]");
331 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
332 auto aFeatures
= aParser
.getFeatures();
334 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
335 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
336 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nStart
);
337 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(4), aFeatures
[0].m_nEnd
);
339 { // One feature specified, with character range and value
340 vcl::font::FeatureParser
aParser(u
"Font name:abcd[3:6]=2");
341 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
342 auto aFeatures
= aParser
.getFeatures();
344 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
345 CPPUNIT_ASSERT_EQUAL(uint32_t(2), aFeatures
[0].m_nValue
);
346 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nStart
);
347 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures
[0].m_nEnd
);
349 { // One feature specified, with character range and 0 value
350 vcl::font::FeatureParser
aParser(u
"Font name:abcd[3:6]=0");
351 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
352 auto aFeatures
= aParser
.getFeatures();
354 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
355 CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures
[0].m_nValue
);
356 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nStart
);
357 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures
[0].m_nEnd
);
359 { // One feature specified, with character range and minus prefix
360 vcl::font::FeatureParser
aParser(u
"Font name:-abcd[3:6]");
361 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
362 auto aFeatures
= aParser
.getFeatures();
364 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
365 CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures
[0].m_nValue
);
366 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures
[0].m_nStart
);
367 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures
[0].m_nEnd
);
369 { // One feature specified, with CSS on
370 vcl::font::FeatureParser
aParser(u
"Font name:\"abcd\" on");
371 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
372 auto aFeatures
= aParser
.getFeatures();
374 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
375 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
377 { // One feature specified, with CSS off
378 vcl::font::FeatureParser
aParser(u
"Font name:'abcd' off");
379 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
380 auto aFeatures
= aParser
.getFeatures();
382 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
383 CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures
[0].m_nValue
);
385 { // One feature specified, with CSS value
386 vcl::font::FeatureParser
aParser(u
"Font name:\"abcd\" 2");
387 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
388 auto aFeatures
= aParser
.getFeatures();
390 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
391 CPPUNIT_ASSERT_EQUAL(uint32_t(2), aFeatures
[0].m_nValue
);
393 { // Multiple features specified, no values
394 vcl::font::FeatureParser
aParser(u
"Font name:abcd&bcde&efgh");
395 CPPUNIT_ASSERT_EQUAL(size_t(3), aParser
.getFeatures().size());
396 auto aFeatures
= aParser
.getFeatures();
398 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
399 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
401 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("bcde"), aFeatures
[1].m_nTag
);
402 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[1].m_nValue
);
404 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("efgh"), aFeatures
[2].m_nTag
);
405 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[2].m_nValue
);
408 // Multiple features specified, explicit values
409 // Only 4 char parameter names supported - "toolong" is too long and ignored
410 vcl::font::FeatureParser
aParser(u
"Font name:abcd=1&bcde=0&toolong=1&cdef=3");
411 CPPUNIT_ASSERT_EQUAL(size_t(3), aParser
.getFeatures().size());
412 auto aFeatures
= aParser
.getFeatures();
414 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
415 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
417 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("bcde"), aFeatures
[1].m_nTag
);
418 CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures
[1].m_nValue
);
420 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("cdef"), aFeatures
[2].m_nTag
);
421 CPPUNIT_ASSERT_EQUAL(uint32_t(3), aFeatures
[2].m_nValue
);
424 // Special case - "lang" is parsed specially and access separately not as a feature.
426 vcl::font::FeatureParser
aParser(u
"Font name:abcd=1&lang=slo");
427 CPPUNIT_ASSERT_EQUAL(size_t(1), aParser
.getFeatures().size());
428 auto aFeatures
= aParser
.getFeatures();
430 CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures
[0].m_nTag
);
431 CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures
[0].m_nValue
);
433 CPPUNIT_ASSERT_EQUAL(OUString("slo"), aParser
.getLanguage());
437 CPPUNIT_TEST_SUITE_REGISTRATION(FontFeatureTest
);
439 CPPUNIT_PLUGIN_IMPLEMENT();
441 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */