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
|
/* -*- 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 <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/wrkwin.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
class VclComplexTextTest : public test::BootstrapFixture
{
public:
VclComplexTextTest() : BootstrapFixture(true, false) {}
/// Play with font measuring etc.
void testArabic();
#if defined(_WIN32)
void testTdf95650(); // Windows-only issue
#endif
CPPUNIT_TEST_SUITE(VclComplexTextTest);
CPPUNIT_TEST(testArabic);
#if defined(_WIN32)
CPPUNIT_TEST(testTdf95650);
#endif
CPPUNIT_TEST_SUITE_END();
};
void VclComplexTextTest::testArabic()
{
const unsigned char pOneTwoThreeUTF8[] = {
0xd9, 0x88, 0xd8, 0xa7, 0xd8, 0xad, 0xd9, 0x90,
0xd8, 0xaf, 0xd9, 0x92, 0x20, 0xd8, 0xa5, 0xd8,
0xab, 0xd9, 0x8d, 0xd9, 0x86, 0xd9, 0x8a, 0xd9,
0x86, 0x20, 0xd8, 0xab, 0xd9, 0x84, 0xd8, 0xa7,
0xd8, 0xab, 0xd8, 0xa9, 0xd9, 0x8c, 0x00
};
OUString aOneTwoThree( reinterpret_cast<char const *>(pOneTwoThreeUTF8),
SAL_N_ELEMENTS( pOneTwoThreeUTF8 ) - 1,
RTL_TEXTENCODING_UTF8 );
ScopedVclPtrInstance<WorkWindow> pWin(static_cast<vcl::Window *>(nullptr));
CPPUNIT_ASSERT( pWin );
vcl::Font aFont("DejaVu Sans", "Book", Size(0, 12));
OutputDevice *pOutDev = pWin.get();
pOutDev->SetFont( aFont );
// text advance width and line height
CPPUNIT_ASSERT_EQUAL(72L, pOutDev->GetTextWidth(aOneTwoThree));
CPPUNIT_ASSERT_EQUAL(13L, pOutDev->GetTextHeight());
// exact bounding rectangle, not essentially the same as text width/height
#ifndef MACOSX
// FIXME: fails on mac, probably different rounding strategy.
Rectangle aBoundRect;
pOutDev->GetTextBoundRect(aBoundRect, aOneTwoThree);
CPPUNIT_ASSERT_EQUAL(Rectangle(0, 1, 71, 15), aBoundRect);
#endif
// normal orientation
Rectangle aInput;
Rectangle aRect = pOutDev->GetTextRect( aInput, aOneTwoThree );
// now rotate 270 degress
vcl::Font aRotated( aFont );
aRotated.SetOrientation( 2700 );
pOutDev->SetFont( aRotated );
Rectangle aRectRot = pOutDev->GetTextRect( aInput, aOneTwoThree );
// Check that we did do the rotation ...
#if 0
// FIXME: This seems to be wisthful thinking, GetTextRect() does not take
// rotation into account.
fprintf( stderr, "%ld %ld %ld %ld\n",
aRect.GetWidth(), aRect.GetHeight(),
aRectRot.GetWidth(), aRectRot.GetHeight() );
CPPUNIT_ASSERT( aRectRot.GetWidth() == aRect.GetHeight() );
CPPUNIT_ASSERT( aRectRot.GetHeight() == aRect.GetWidth() );
#else
(void)aRect; (void)aRectRot;
#endif
}
#if defined(_WIN32)
void VclComplexTextTest::testTdf95650()
{
const sal_Unicode pTxt[] = {
0x0131, 0x0302, 0x0504, 0x4E44, 0x3031, 0x3030, 0x3531, 0x2D30,
0x3037, 0x0706, 0x0908, 0x0B0A, 0x0D0C, 0x0F0E, 0x072E, 0x100A,
0x0D11, 0x1312, 0x0105, 0x020A, 0x0512, 0x1403, 0x030C, 0x1528,
0x2931, 0x632E, 0x7074, 0x0D20, 0x0E0A, 0x100A, 0xF00D, 0x0D20,
0x030A, 0x0C0B, 0x20E0, 0x0A0D
};
OUString aTxt(pTxt, SAL_N_ELEMENTS(pTxt) - 1);
ScopedVclPtrInstance<WorkWindow> pWin(static_cast<vcl::Window *>(nullptr));
CPPUNIT_ASSERT(pWin);
OutputDevice *pOutDev = pWin.get();
// Check that the following executes without failing assertion
pOutDev->ImplLayout(aTxt, 9, 1, Point(), 0, nullptr, SalLayoutFlags::BiDiRtl);
}
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(VclComplexTextTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|