Hash :
4cd99a38
Author :
Date :
2001-07-30T02:24:24
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
#include "FTFace.h"
#include "FTFont.h"
#include "FTGlyphContainer.h"
//#include "FTGL.h"
// OPSignature: FTFont:FTFont()
FTFont::FTFont()
: fontName(0),
numFaces(0),
glyphList(0)
{
pen.x = 0;
pen.y = 0;
}
// OPSignature: FTFont:~FTFont()
FTFont::~FTFont()
{
//Insert your own code here.
//End of user code.
}
// OPSignature: bool FTFont:Open( const char*:fontname )
bool FTFont::Open( const char* fontname )
{
//FIXME first check map to see if it's already open.
// FTFace face; // When we have a list of faces
if( face.Open( fontname))
{
// faceList.insert( FaceMap::value_type( string( fontname), face));
FT_Face* ftFace = face.Face();
numGlyphs = (*ftFace)->num_glyphs;
return true;
}
else
{
return false;
}
}
// OPSignature: void FTFont:Close()
void FTFont::Close()
{
face.Close();
delete glyphList;
}
// OPSignature: bool FTFont:SetFaceSize( const int:size const int:res )
bool FTFont::FaceSize( const int size, const int res )
{
charSize = face.Size( size, res);
if( glyphList)
delete glyphList;
glyphList = new FTGlyphContainer( face.Face(), numGlyphs);
MakeGlyphList();
return true;
}
bool FTFont::CharMap( CHARMAP encoding)
{
face.CharMap( encoding);
// assert( face);
//FIXME
if( glyphList)
delete glyphList;
glyphList = new FTGlyphContainer( face.Face(), numGlyphs);
MakeGlyphList();
}
//FTGlyph* FTFont::Glyph( unsigned char code )
//{}
//
//
//FTGlyph* FTFont::Glyph( unsigned char thisCode, unsigned char nextCode )
//{}
// OPSignature: int FTFont:getAscender()
int FTFont::Ascender() const
{
return charSize.Ascender();
}
// OPSignature: int FTFont:getDescender()
int FTFont::Descender() const
{
return charSize.Descender();
}
// OPSignature: void FTFont:getBBox( const char*:text int&:llx int&:lly int&:urx int&:ury )
void FTFont::BBox( const char* text, int& llx, int& lly, int& urx, int& ury ) const
{
//Insert your own code here.
//End of user code.
}
// OPSignature: bool FTFont:render( const char*:string )
bool FTFont::render( const char* string )
{
char* c = string;
FT_Vector kernAdvance;
pen.x = 0; pen.y = 0;
while( *c)
{
kernAdvance = glyphList->render( *c, *(c + 1), pen);
pen.x += kernAdvance.x;
pen.y += kernAdvance.y;
++c;
}
}