Example #1
0
        void testRender()
        {
            buildGLContext();
            
            FTGLPixmapFont* pixmapFont = new FTGLPixmapFont( FONT_FILE);            

            pixmapFont->Render(GOOD_ASCII_TEST_STRING);
            CPPUNIT_ASSERT( pixmapFont->Error() == 0x97);   // Invalid pixels per em       
            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        

            pixmapFont->FaceSize(18);
            pixmapFont->Render(GOOD_ASCII_TEST_STRING);

            CPPUNIT_ASSERT( pixmapFont->Error() == 0);        
            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
        }
Example #2
0
// Wczytuje czcionkê
void setFont(char * name)
{
    if(font == NULL)                                                              // Jeœli czcionka nie zosta³a jeszcze wczytana
    {
        fontName = name;                                                           // Zmienaiam nazwê czcionki
        return;
    }

    FTGLPixmapFont * newfont = new FTGLPixmapFont(name);                           // Wczytuje now¹ czcionkê

    if(newfont->Error())                                                           // Sprawdzam czy siê uda³o
    {
        delete newfont;                                                              // Jeœli nie to usuwam zadeklarowan¹ pamiêæ
        MsgBox("FTGL nie móg³ za³adowaæ nowej czcionki ","ERROR");
        return;
    }

    newfont->FaceSize(fontSize);                                                   // WielkoϾ czcionki

    newfont->UseDisplayList(true);                                                 // U¿ywam list wyœwietlania

    delete font;                                                                   // Usuwam star¹ czcionkê

    font = newfont;                                                                // Podmieniam wskaŸnik na now¹
}
Example #3
0
 void testConstructor()
 {
     buildGLContext();
 
     FTGLPixmapFont* pixmapFont = new FTGLPixmapFont( FONT_FILE);            
     CPPUNIT_ASSERT( pixmapFont->Error() == 0);
 
     CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
 }
// Load FtglPixmapFont
void FtglPixmapFont::loadFont()
{
    if (isLoaded()) return;

    // Check for required parameters

    if( filename() == nullptr ) {
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "No ttf file" << std::endl;
        }
        return;
    }

    // Generate filename
    const size_t FONTPATHNAME_LENGTH = 256;
    char fontPathname[FONTPATHNAME_LENGTH];
    if (fontDirectory() != nullptr) lcStrcpy(fontPathname, FONTPATHNAME_LENGTH, fontDirectory());
    else lcStrcpy(fontPathname, FONTPATHNAME_LENGTH, "./");
    lcStrcat(fontPathname, FONTPATHNAME_LENGTH, filename());

    FTGLPixmapFont* ftglFont = new FTGLPixmapFont(fontPathname);
    if (ftglFont != nullptr && !ftglFont->Error()) {
        // set the face size and return the pointer, then tell our base class that we have a loaded font
        ftglFont->FaceSize(getFaceSize());
        ftgl(ftglFont);
        setFontLoaded();
    }
    else {
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "FtglPixmapFont::loadFont() - font did not load correctly: file: \"";
            std::cerr << fontPathname << "\"";
            std::cerr << std::endl;
        }
        std::exit(1);
    }
}