summaryrefslogtreecommitdiffstats
path: root/vcl/qa/cppunit/FontFeatureTest.cxx
blob: 9d47ceb17063b3177b4195c923eca9920e39786b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <test/bootstrapfixture.hxx>
#include <config_features.h>
#include <config_fonts.h>
#include <cppunit/TestAssert.h>

#include <vcl/font/Feature.hxx>
#include <vcl/font/FeatureParser.hxx>
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>

class FontFeatureTest : public test::BootstrapFixture
{
public:
    FontFeatureTest()
        : BootstrapFixture(true, false)
    {
    }

    void testGetFontFeaturesGraphite();
    void testGetFontFeaturesOpenType();
    void testGetFontFeaturesOpenTypeEnum();
    void testParseFeature();

    CPPUNIT_TEST_SUITE(FontFeatureTest);
    CPPUNIT_TEST(testGetFontFeaturesGraphite);
    CPPUNIT_TEST(testGetFontFeaturesOpenType);
    CPPUNIT_TEST(testGetFontFeaturesOpenTypeEnum);
    CPPUNIT_TEST(testParseFeature);
    CPPUNIT_TEST_SUITE_END();
};

void FontFeatureTest::testGetFontFeaturesGraphite()
{
#if HAVE_MORE_FONTS
    ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(),
                                              DeviceFormat::WITH_ALPHA);
    aVDev->SetOutputSizePixel(Size(10, 10));

    OUString aFontName("Linux Libertine G");
    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(53), rFontFeatures.size());

    CPPUNIT_ASSERT_EQUAL(OUString("c2sc case dlig fina frac hlig liga lnum "
                                  "locl onum pnum sa01 sa02 sa03 sa04 sa05 "
                                  "sa06 sa07 sa08 salt sinf smcp ss01 ss02 "
                                  "ss03 sups tnum zero ingl cpsp lith litt "
                                  "itlc para algn arti circ dash dbls foot "
                                  "frsp grkn hang lng minu nfsp name quot "
                                  "texm thou vari caps ligc "),
                         aFeaturesString);

    // Check C2SC feature
    {
        vcl::font::Feature& rFeature = rFontFeatures[0];
        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("c2sc"), rFeature.m_nCode);

        vcl::font::FeatureDefinition& rFracFeatureDefinition = rFeature.m_aDefinition;
        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("c2sc"), rFracFeatureDefinition.getCode());
        CPPUNIT_ASSERT(!rFracFeatureDefinition.getDescription().isEmpty());
        CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::BOOL,
                             rFracFeatureDefinition.getType());

        CPPUNIT_ASSERT_EQUAL(size_t(0), rFracFeatureDefinition.getEnumParameters().size());
    }

    // Check FRAC feature
    {
        vcl::font::Feature& rFeature = rFontFeatures[4];
        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("frac"), rFeature.m_nCode);

        vcl::font::FeatureDefinition& rFracFeatureDefinition = rFeature.m_aDefinition;
        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("frac"), rFracFeatureDefinition.getCode());
        CPPUNIT_ASSERT(!rFracFeatureDefinition.getDescription().isEmpty());
        CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::ENUM,
                             rFracFeatureDefinition.getType());

        CPPUNIT_ASSERT_EQUAL(size_t(3), rFracFeatureDefinition.getEnumParameters().size());

        vcl::font::FeatureParameter const& rParameter1
            = rFracFeatureDefinition.getEnumParameters()[0];
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), rParameter1.getCode());
        CPPUNIT_ASSERT(!rParameter1.getDescription().isEmpty());

        vcl::font::FeatureParameter const& rParameter2
            = rFracFeatureDefinition.getEnumParameters()[1];
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), rParameter2.getCode());
        CPPUNIT_ASSERT(!rParameter2.getDescription().isEmpty());

        vcl::font::FeatureParameter const& rParameter3
            = rFracFeatureDefinition.getEnumParameters()[2];
        CPPUNIT_ASSERT_EQUAL(uint32_t(2), rParameter3.getCode());
        CPPUNIT_ASSERT(!rParameter2.getDescription().isEmpty());
    }

    aVDev.disposeAndClear();
#endif // HAVE_MORE_FONTS
}

void FontFeatureTest::testGetFontFeaturesOpenType()
{
#if HAVE_MORE_FONTS
    ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(),
                                              DeviceFormat::WITH_ALPHA);
    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::testGetFontFeaturesOpenTypeEnum()
{
#if HAVE_MORE_FONTS
    ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(),
                                              DeviceFormat::WITH_ALPHA);
    aVDev->SetOutputSizePixel(Size(10, 10));

    OUString aFontName("Reem Kufi");
    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(10), rFontFeatures.size());

    CPPUNIT_ASSERT_EQUAL(OUString("aalt case cv01 cv02 cv03 frac ordn sups "
                                  "zero kern "),
                         aFeaturesString);

    // Check aalt feature
    {
        vcl::font::Feature& rFeature = rFontFeatures[0];
        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("aalt"), rFeature.m_nCode);

        vcl::font::FeatureDefinition& rFeatureDefinition = rFeature.m_aDefinition;
        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("aalt"), rFeatureDefinition.getCode());
        CPPUNIT_ASSERT(!rFeatureDefinition.getDescription().isEmpty());
        CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::ENUM, rFeatureDefinition.getType());

        CPPUNIT_ASSERT_EQUAL(size_t(3), rFeatureDefinition.getEnumParameters().size());

        vcl::font::FeatureParameter const& rParameter1 = rFeatureDefinition.getEnumParameters()[0];
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), rParameter1.getCode());
        CPPUNIT_ASSERT(!rParameter1.getDescription().isEmpty());

        vcl::font::FeatureParameter const& rParameter2 = rFeatureDefinition.getEnumParameters()[1];
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), rParameter2.getCode());
        CPPUNIT_ASSERT(!rParameter2.getDescription().isEmpty());

        vcl::font::FeatureParameter const& rParameter3 = rFeatureDefinition.getEnumParameters()[2];
        CPPUNIT_ASSERT_EQUAL(uint32_t(2), rParameter3.getCode());
        CPPUNIT_ASSERT(!rParameter2.getDescription().isEmpty());
    }

    aVDev.disposeAndClear();
#endif // HAVE_MORE_FONTS
}

void FontFeatureTest::testParseFeature()
{
    { // No font features specified
        vcl::font::FeatureParser aParser(u"Font name with no features");
        CPPUNIT_ASSERT_EQUAL(size_t(0), aParser.getFeatures().size());
    }
    { // One feature specified, no value
        vcl::font::FeatureParser aParser(u"Font name:abcd");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
    }
    { // One feature specified, explicit value
        vcl::font::FeatureParser aParser(u"Font name:abcd=5");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(5), aFeatures[0].m_nValue);
    }
    { // One feature specified, explicit zero value
        vcl::font::FeatureParser aParser(u"Font name:abcd=0");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue);
    }
    { // One feature specified, using plus prefix
        vcl::font::FeatureParser aParser(u"Font name:+abcd");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
    }
    { // One feature specified, using minus prefix
        vcl::font::FeatureParser aParser(u"Font name:-abcd");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue);
    }
    { // One feature specified, with empty character range
        vcl::font::FeatureParser aParser(u"Font name:abcd[]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with empty character range
        vcl::font::FeatureParser aParser(u"Font name:abcd[:]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with start character range
        vcl::font::FeatureParser aParser(u"Font name:abcd[3:]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with end character range
        vcl::font::FeatureParser aParser(u"Font name:abcd[:3]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with character range
        vcl::font::FeatureParser aParser(u"Font name:abcd[3:6]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with character range
        vcl::font::FeatureParser aParser(u"Font name:abcd[3]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(4), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with character range and value
        vcl::font::FeatureParser aParser(u"Font name:abcd[3:6]=2");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(2), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with character range and 0 value
        vcl::font::FeatureParser aParser(u"Font name:abcd[3:6]=0");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with character range and minus prefix
        vcl::font::FeatureParser aParser(u"Font name:-abcd[3:6]");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd);
    }
    { // One feature specified, with CSS on
        vcl::font::FeatureParser aParser(u"Font name:\"abcd\" on");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);
    }
    { // One feature specified, with CSS off
        vcl::font::FeatureParser aParser(u"Font name:'abcd' off");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue);
    }
    { // One feature specified, with CSS value
        vcl::font::FeatureParser aParser(u"Font name:\"abcd\" 2");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(2), aFeatures[0].m_nValue);
    }
    { // Multiple features specified, no values
        vcl::font::FeatureParser aParser(u"Font name:abcd&bcde&efgh");
        CPPUNIT_ASSERT_EQUAL(size_t(3), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("bcde"), aFeatures[1].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[1].m_nValue);

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("efgh"), aFeatures[2].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[2].m_nValue);
    }
    {
        // Multiple features specified, explicit values
        // Only 4 char parameter names supported - "toolong" is too long and ignored
        vcl::font::FeatureParser aParser(u"Font name:abcd=1&bcde=0&toolong=1&cdef=3");
        CPPUNIT_ASSERT_EQUAL(size_t(3), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("bcde"), aFeatures[1].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[1].m_nValue);

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("cdef"), aFeatures[2].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(3), aFeatures[2].m_nValue);
    }
    {
        // Special case - "lang" is parsed specially and access separately not as a feature.

        vcl::font::FeatureParser aParser(u"Font name:abcd=1&lang=slo");
        CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size());
        auto aFeatures = aParser.getFeatures();

        CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("abcd"), aFeatures[0].m_nTag);
        CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue);

        CPPUNIT_ASSERT_EQUAL(OUString("slo"), aParser.getLanguage());
    }
}

CPPUNIT_TEST_SUITE_REGISTRATION(FontFeatureTest);

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */