void testMakeMesh()
    {
        setUpFreetype(COMPLEX_CHARACTER_INDEX);

        FTVectoriser vectoriser(face->glyph);

        vectoriser.MakeMesh(FTGL_FRONT_FACING);

        int d = 0;
        const FTMesh* mesh = vectoriser.GetMesh();
        unsigned int tesselations = mesh->TesselationCount();
        CPPUNIT_ASSERT_EQUAL(14U, tesselations);

        for(unsigned int index = 0; index < tesselations; ++index)
        {
            const FTTesselation* subMesh = mesh->Tesselation(index);

            unsigned int polyType = subMesh->PolygonType();
            CPPUNIT_ASSERT_EQUAL(testMeshPolygonTypes[index], polyType);

            unsigned int numberOfVertices = subMesh->PointCount();
            CPPUNIT_ASSERT_EQUAL(testMeshPointCount[index], numberOfVertices);

            for(unsigned int x = 0; x < numberOfVertices; ++x)
            {
                CPPUNIT_ASSERT_DOUBLES_EQUAL(*(testMesh + d),     subMesh->Point(x).X() / 64, 0.01);
                CPPUNIT_ASSERT_DOUBLES_EQUAL(*(testMesh + d + 1), subMesh->Point(x).Y() / 64, 0.01);
                d += 3;
            }
        }

        tearDownFreetype();
    }
Пример #2
0
    void testPlusEquals() {
        setUpFreetype();

        FTBBox boundingBox1;
        FTBBox boundingBox2( face->glyph);

        boundingBox1 += boundingBox2;

        CPPUNIT_ASSERT_DOUBLES_EQUAL(   2, boundingBox2.lowerX, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, boundingBox2.lowerY, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(   0, boundingBox2.lowerZ, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  35, boundingBox2.upperX, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  38, boundingBox2.upperY, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(   0, boundingBox2.upperZ, 0.01);

        float advance  = 40;

        boundingBox2.Move( FTPoint( advance, 0, 0));
        boundingBox1 += boundingBox2;

        CPPUNIT_ASSERT_DOUBLES_EQUAL(  42, boundingBox2.lowerX, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, boundingBox2.lowerY, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(   0, boundingBox2.lowerZ, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  75, boundingBox2.upperX, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  38, boundingBox2.upperY, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(   0, boundingBox2.upperZ, 0.01);

        tearDownFreetype();
    }
    void testBadGlyphProcess()
    {
        setUpFreetype(NULL_CHARACTER_INDEX);

        FTVectoriser vectoriser(face->glyph);
        CPPUNIT_ASSERT_EQUAL((size_t)0, vectoriser.ContourCount());

        tearDownFreetype();
    }
    void testGetMesh()
    {
        setUpFreetype(SIMPLE_CHARACTER_INDEX);

        FTVectoriser vectoriser(face->glyph);
        CPPUNIT_ASSERT(vectoriser.GetMesh() == NULL);

        vectoriser.MakeMesh(FTGL_FRONT_FACING);

        CPPUNIT_ASSERT(vectoriser.GetMesh());
    }
    void testGetContour()
    {
        setUpFreetype(SIMPLE_CHARACTER_INDEX);

        FTVectoriser vectoriser(face->glyph);

        CPPUNIT_ASSERT(vectoriser.Contour(1));
        CPPUNIT_ASSERT(vectoriser.Contour(99) == NULL);

        tearDownFreetype();
    }
    void testComplexGlyphProcess()
    {
        setUpFreetype(COMPLEX_CHARACTER_INDEX);

        FTVectoriser vectoriser(face->glyph);

        CPPUNIT_ASSERT_EQUAL((size_t)2, vectoriser.ContourCount());
        CPPUNIT_ASSERT_EQUAL((size_t)91, vectoriser.PointCount());

        tearDownFreetype();
    }
Пример #7
0
        void testConstructor()
        {
            setUpFreetype();
            
            buildGLContext();
        
            FTPixmapGlyph* PixmapGlyph = new FTPixmapGlyph( face->glyph);            
            CPPUNIT_ASSERT( PixmapGlyph->Error() == 0);
        
            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        

            tearDownFreetype();
        }
Пример #8
0
        void testConstructor()
        {
            setUpFreetype();
            
            buildGLContext();
        
            FTExtrdGlyph* extrudedGlyph = new FTExtrdGlyph( face->glyph, 0.0f, true);
            CPPUNIT_ASSERT( extrudedGlyph->Error() == 0);
        
            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        

            tearDownFreetype();
        }
Пример #9
0
        void testRender()
        {
            setUpFreetype();
            
            buildGLContext();
        
            FTPixmapGlyph* pixmapGlyph = new FTPixmapGlyph( face->glyph);            
            CPPUNIT_ASSERT( pixmapGlyph->Error() == 0);
            pixmapGlyph->Render(FTPoint( 0, 0, 0));
            
            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        

            tearDownFreetype();
        }
Пример #10
0
    void testGlyphConstructor() {
        setUpFreetype();

        FTBBox boundingBox( face->glyph);

        CPPUNIT_ASSERT_DOUBLES_EQUAL(   2, boundingBox.lowerX, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, boundingBox.lowerY, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(   0, boundingBox.lowerZ, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  35, boundingBox.upperX, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  38, boundingBox.upperY, 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(   0, boundingBox.upperZ, 0.01);

        tearDownFreetype();
    }
Пример #11
0
        void testGoodConstructor()
        {            
            setUpFreetype( CHARACTER_CODE_A);
            TestGlyph testGlyph(face->glyph);
            
            FTPoint testPoint(47.0f, 0.0f, 0.0f);
            
            CPPUNIT_ASSERT( testPoint == testGlyph.Advance());

            CPPUNIT_ASSERT_DOUBLES_EQUAL( 51.39, testGlyph.BBox().upperY, 0.01);
        
            CPPUNIT_ASSERT( testGlyph.Error() == 0);
            
            tearDownFreetype();
        }
Пример #12
0
        void testRender()
        {
            setUpFreetype();

            buildGLContext();

            FTExtrudeGlyph* extrudedGlyph = new FTExtrudeGlyph(face->glyph,
                                                      0.0f, 0.0f, 0.0f, true);
            CPPUNIT_ASSERT(extrudedGlyph->Error() == 0);
            extrudedGlyph->Render(FTPoint(0, 0, 0), FTGL::RENDER_FRONT |
                                                    FTGL::RENDER_BACK |
                                                    FTGL::RENDER_SIDE);

            CPPUNIT_ASSERT(glGetError() == GL_NO_ERROR);

            tearDownFreetype();
        }
    void testFreetypeVersion()
    {
        setUpFreetype(NULL_CHARACTER_INDEX);

        FT_Int major;
        FT_Int minor;
        FT_Int patch;

        FT_Library_Version(library, &major, &minor, &patch);

        // If you hit these asserts then you have the wrong library version to run the tests.
        // You can still run the tests but some will fail because the hinter changed in 2.1.4
        CPPUNIT_ASSERT_EQUAL(2, major);
        CPPUNIT_ASSERT_EQUAL(1, minor);
        CPPUNIT_ASSERT(4 <= patch);

        tearDownFreetype();
    }
Пример #14
0
    void testSetCharSize()
    {
        setUpFreetype();

        FTSize size;

        CPPUNIT_ASSERT( size.CharSize( &face, FONT_POINT_SIZE, RESOLUTION, RESOLUTION));
        CPPUNIT_ASSERT( size.Error() == 0);

        CPPUNIT_ASSERT_DOUBLES_EQUAL(  72, size.CharSize(), 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(  52, size.Ascender(), 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, size.Descender(), 0.01);

        CPPUNIT_ASSERT_DOUBLES_EQUAL( 81.86, size.Height(), 0.01);
        CPPUNIT_ASSERT_DOUBLES_EQUAL( 76.32, size.Width(), 0.01);

        CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Underline(), 0.01);

        tearDownFreetype();
    }
    void testGetOutline()
    {
        setUpFreetype(COMPLEX_CHARACTER_INDEX);

        FTVectoriser vectoriser(face->glyph);

        unsigned int d = 0;
        for(size_t c = 0; c < vectoriser.ContourCount(); ++c)
        {
            const FTContour* contour = vectoriser.Contour(c);

            for(size_t p = 0; p < contour->PointCount(); ++p)
            {
                CPPUNIT_ASSERT_DOUBLES_EQUAL(*(testOutline + d),     contour->Point(p).X() / 64.0f, 0.01);
                CPPUNIT_ASSERT_DOUBLES_EQUAL(*(testOutline + d + 1), contour->Point(p).Y() / 64.0f, 0.01);
                d += 3;
            }
        }

        tearDownFreetype();
    }