Hash :
7c358859
Author :
Date :
2008-04-04T12:43:38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#include "config.h"
#include "FTPolyGlyph.h"
#include "FTVectoriser.h"
FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph, bool useDisplayList)
: FTGlyph( glyph),
glList(0)
{
if( ft_glyph_format_outline != glyph->format)
{
err = 0x14; // Invalid_Outline
return;
}
FTVectoriser vectoriser( glyph);
if(( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
{
return;
}
unsigned int horizontalTextureScale = glyph->face->size->metrics.x_ppem * 64;
unsigned int verticalTextureScale = glyph->face->size->metrics.y_ppem * 64;
vectoriser.MakeMesh( 1.0);
if( useDisplayList)
{
glList = glGenLists( 1);
glNewList( glList, GL_COMPILE);
}
const FTMesh* mesh = vectoriser.GetMesh();
for( unsigned int index = 0; index < mesh->TesselationCount(); ++index)
{
const FTTesselation* subMesh = mesh->Tesselation( index);
unsigned int polyonType = subMesh->PolygonType();
glBegin( polyonType);
for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
{
FTPoint point = subMesh->Point(pointIndex);
glTexCoord2f( point.X() / horizontalTextureScale,
point.Y() / verticalTextureScale);
glVertex3f( point.X() / 64.0f,
point.Y() / 64.0f,
0.0f);
}
glEnd();
}
if(useDisplayList)
{
glEndList();
}
}
FTPolyGlyph::~FTPolyGlyph()
{
glDeleteLists( glList, 1);
}
const FTPoint& FTPolyGlyph::Render( const FTPoint& pen)
{
glTranslatef( pen.X(), pen.Y(), 0.0f);
if( glList)
{
glCallList( glList);
}
return advance;
}