Edit

kc3-lang/ftgl/src/FTVectorGlyph.cpp

Branch :

  • Show log

    Commit

  • Author : henry
    Date : 2001-08-02 21:49:25
    Hash : f2926cee
    Message : Changed the cord data from floats to doubles...trying to debug the glutess stuff in FTPolyGlyph!!

  • src/FTVectorGlyph.cpp
  • #include	"gl.h"
    
    #include	"FTVectorGlyph.h"
    #include	"FTVectoriser.h"
    #include	"FTGL.h"
    
    
    
    FTVectorGlyph::FTVectorGlyph( FT_Glyph glyph, int gi)
    :	FTGlyph(gi),
    	vectoriser(0),
    	numPoints(0),
    	numContours(0),
    	contourLength(0),
    	data(0)
    {
    	if( glyph->format == ft_glyph_format_outline)
    	{
    		vectoriser = new FTVectoriser( glyph);
    		
    		if( vectoriser->Ingest())
    		{
    			numContours = vectoriser->contours();
    			
    			contourLength = new int[ numContours];
    			
    			for( int c = 0; c < numContours; ++c)
    			{
    				contourLength[c] = vectoriser->contourSize( c);
    			}
    			
    			numPoints = vectoriser->points();
    			data = new double[ numPoints * 3];
    			vectoriser->Output( data);
    			
    			advance = glyph->advance.x >> 16; // this is 6 in the freetype docs!!!!!!
    		}
    	
    		delete vectoriser;
    		
    	    if ( ( numContours < 1) || ( numPoints < 1))
    			return;
    			
     		glList = glGenLists(1);
     		int d = 0;
     
     		glNewList( glList, GL_COMPILE);
     			for( int c = 0; c < numContours; ++c)
     			{
     				glBegin( GL_LINE_LOOP);
     				for( int p = 0; p < ( contourLength[c]); ++p)
     				{
     					glVertex2dv( data + d);
     					d += 3;
     				}
     				glEnd();
     			}
     		glEndList();
    	
    	}
    }
    
    
    FTVectorGlyph::~FTVectorGlyph()
    {
    	delete [] data;
    }
    
    
    float FTVectorGlyph::Render( FT_Vector& pen)
    {
    	glTranslatef( pen.x, pen.y, 0);
    		glCallList( glList);
    	glTranslatef( -pen.x, -pen.y, 0);
    	
    	return advance;
    }