00001 #include "FTPolyGlyph.h"
00002 #include "FTVectoriser.h"
00003
00004
00005 FTPolyGlyph::FTPolyGlyph( 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 if(( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
00017 {
00018 return;
00019 }
00020
00021 vectoriser.MakeMesh( 1.0);
00022
00023 glList = glGenLists( 1);
00024 glNewList( glList, GL_COMPILE);
00025
00026 const FTMesh* mesh = vectoriser.GetMesh();
00027 for( unsigned int index = 0; index < mesh->TesselationCount(); ++index)
00028 {
00029 const FTTesselation* subMesh = mesh->Tesselation( index);
00030 unsigned int polyonType = subMesh->PolygonType();
00031
00032 glBegin( polyonType);
00033 for( unsigned int x = 0; x < subMesh->PointCount(); ++x)
00034 {
00035 glVertex3f( subMesh->Point(x).x / 64.0f,
00036 subMesh->Point(x).y / 64.0f,
00037 0.0f);
00038 }
00039 glEnd();
00040 }
00041 glEndList();
00042
00043 FT_Done_Glyph( glyph);
00044 }
00045
00046
00047 FTPolyGlyph::~FTPolyGlyph()
00048 {
00049 glDeleteLists( glList, 1);
00050 }
00051
00052
00053 float FTPolyGlyph::Render( const FTPoint& pen)
00054 {
00055 if( glList)
00056 {
00057 glTranslatef( pen.x, pen.y, 0);
00058 glCallList( glList);
00059 glTranslatef( -pen.x, -pen.y, 0);
00060 }
00061
00062 return advance;
00063 }