Main Page | File List | File Members

FTOutlineGlyph.cpp

Go to the documentation of this file.
00001 #include    "FTOutlineGlyph.h"
00002 #include    "FTVectoriser.h"
00003 
00004 
00005 FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
00006 :   FTGlyph( glyph),
00007     glList(0)
00008 {
00009     if( ft_glyph_format_outline != glyph->format)
00010     {
00011         return;
00012     }
00013 
00014     FTVectoriser vectoriser( glyph);
00015 
00016     size_t numContours = vectoriser.ContourCount();
00017     if ( ( numContours < 1) || ( vectoriser.PointCount() < 3))
00018     {
00019         return;
00020     }
00021 
00022     glList = glGenLists(1);
00023     glNewList( glList, GL_COMPILE);
00024         for( unsigned int c = 0; c < numContours; ++c)
00025         {
00026             const FTContour* contour = vectoriser.Contour(c);
00027             
00028             glBegin( GL_LINE_LOOP);
00029                 for( unsigned int p = 0; p < contour->PointCount(); ++p)
00030                 {
00031                     glVertex2f( contour->Point(p).x / 64.0f, contour->Point(p).y / 64.0f);
00032                 }
00033             glEnd();
00034         }
00035     glEndList();
00036 
00037 
00038     // discard glyph image (bitmap or not)
00039     FT_Done_Glyph( glyph); // Why does this have to be HERE
00040 }
00041 
00042 
00043 FTOutlineGlyph::~FTOutlineGlyph()
00044 {
00045     glDeleteLists( glList, 1);
00046 }
00047 
00048 
00049 float FTOutlineGlyph::Render( const FTPoint& pen)
00050 {
00051     if( glList)
00052     {
00053         glTranslatef( pen.x, pen.y, 0);
00054             glCallList( glList);
00055         glTranslatef( -pen.x, -pen.y, 0);
00056     }
00057     
00058     return advance;
00059 }
00060 

Generated on Mon Mar 8 18:45:41 2004 for FTGL by doxygen 1.3.5