1
#include "cppunit/extensions/HelperMacros.h"
2
#include "cppunit/TestCaller.h"
3
#include "cppunit/TestCase.h"
4
#include "cppunit/TestSuite.h"
10
class FTFaceTest : public CppUnit::TestCase
12
CPPUNIT_TEST_SUITE( FTFaceTest);
13
CPPUNIT_TEST( testOpenFace);
14
CPPUNIT_TEST( testOpenFaceFromMemory);
15
CPPUNIT_TEST( testAttachFile);
16
CPPUNIT_TEST( testAttachMemoryData);
17
CPPUNIT_TEST( testGlyphCount);
18
CPPUNIT_TEST( testSetFontSize);
19
CPPUNIT_TEST( testGetCharmapList);
20
CPPUNIT_TEST( testUnitPerEMSquare);
21
CPPUNIT_TEST( testKerning);
22
CPPUNIT_TEST_SUITE_END();
25
FTFaceTest() : CppUnit::TestCase( "FTFace test") {};
26
FTFaceTest( const std::string& name) : CppUnit::TestCase(name) {};
31
FTFace face1( BAD_FONT_FILE);
32
CPPUNIT_ASSERT( face1.Error() == 0x06);
34
FTFace face2( GOOD_FONT_FILE);
35
CPPUNIT_ASSERT( face2.Error() == 0);
39
void testOpenFaceFromMemory()
41
FTFace face1( (unsigned char*)100, 0);
42
CPPUNIT_ASSERT( face1.Error() == 0x02);
44
FTFace face2( HPGCalc_pfb.dataBytes, HPGCalc_pfb.numBytes);
45
CPPUNIT_ASSERT( face2.Error() == 0);
51
CPPUNIT_ASSERT( !testFace->Attach( TYPE1_AFM_FILE));
52
CPPUNIT_ASSERT( testFace->Error() == 0x07);
54
FTFace test( TYPE1_FONT_FILE);
55
CPPUNIT_ASSERT( test.Error() == 0);
57
CPPUNIT_ASSERT( test.Attach( TYPE1_AFM_FILE));
58
CPPUNIT_ASSERT( test.Error() == 0);
62
void testAttachMemoryData()
64
CPPUNIT_ASSERT( !testFace->Attach((unsigned char*)100, 0));
65
CPPUNIT_ASSERT( testFace->Error() == 0x07);
67
FTFace test( TYPE1_FONT_FILE);
68
CPPUNIT_ASSERT( test.Error() == 0);
70
CPPUNIT_ASSERT( test.Attach( HPGCalc_afm.dataBytes, HPGCalc_afm.numBytes));
71
CPPUNIT_ASSERT( test.Error() == 0);
77
CPPUNIT_ASSERT( testFace->GlyphCount() == 14099);
81
void testSetFontSize()
83
FTSize size = testFace->Size( FONT_POINT_SIZE, RESOLUTION);
84
CPPUNIT_ASSERT( testFace->Error() == 0);
88
void testGetCharmapList()
90
CPPUNIT_ASSERT( testFace->CharMapCount() == 2);
92
FT_Encoding* charmapList = testFace->CharMapList();
94
CPPUNIT_ASSERT( charmapList[0] == ft_encoding_unicode);
95
CPPUNIT_ASSERT( charmapList[1] == ft_encoding_adobe_standard);
99
void testUnitPerEMSquare()
101
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1000, testFace->UnitsPerEM(), 0);
107
FTPoint kerningVector = testFace->KernAdvance( 'A', 'W');
108
CPPUNIT_ASSERT( kerningVector.x == 0);
109
CPPUNIT_ASSERT( kerningVector.y == 0);
110
CPPUNIT_ASSERT( kerningVector.z == 0);
112
kerningVector = testFace->KernAdvance( 0x6FB3, 0x9580);
113
CPPUNIT_ASSERT( kerningVector.x == 0);
114
CPPUNIT_ASSERT( kerningVector.y == 0);
115
CPPUNIT_ASSERT( kerningVector.z == 0);
121
testFace = new FTFace( GOOD_FONT_FILE);
135
CPPUNIT_TEST_SUITE_REGISTRATION( FTFaceTest);