4
#include FT_TRUETYPE_TABLES_H
6
FTFace::FTFace( const char* filename)
11
const FT_Long DEFAULT_FACE_INDEX = 0;
14
err = FT_New_Face( *FTLibrary::Instance().GetLibrary(), filename, DEFAULT_FACE_INDEX, ftFace);
23
numGlyphs = (*ftFace)->num_glyphs;
28
FTFace::FTFace( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
32
const FT_Long DEFAULT_FACE_INDEX = 0;
35
err = FT_New_Memory_Face( *FTLibrary::Instance().GetLibrary(), (FT_Byte *)pBufferBytes, bufferSizeInBytes, DEFAULT_FACE_INDEX, ftFace);
44
numGlyphs = (*ftFace)->num_glyphs;
55
bool FTFace::Attach( const char* filename)
57
err = FT_Attach_File( *ftFace, filename);
62
bool FTFace::Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
66
open.flags = FT_OPEN_MEMORY;
67
open.memory_base = (FT_Byte *)pBufferBytes;
68
open.memory_size = bufferSizeInBytes;
70
err = FT_Attach_Stream( *ftFace, &open);
79
FT_Done_Face( *ftFace);
86
const FTSize& FTFace::Size( const unsigned int size, const unsigned int res)
88
charSize.CharSize( ftFace, size, res, res);
89
err = charSize.Error();
95
unsigned int FTFace::CharMapCount()
97
return (*ftFace)->num_charmaps;
101
FT_Encoding* FTFace::CharMapList()
103
if( 0 == fontEncodingList)
105
fontEncodingList = new FT_Encoding[CharMapCount()];
106
for( size_t encodingIndex = 0; encodingIndex < CharMapCount(); ++encodingIndex)
108
fontEncodingList[encodingIndex] = (*ftFace)->charmaps[encodingIndex]->encoding;
112
return fontEncodingList;
116
unsigned int FTFace::UnitsPerEM() const
118
return (*ftFace)->units_per_EM;
122
FTPoint FTFace::KernAdvance( unsigned int index1, unsigned int index2)
127
if( FT_HAS_KERNING((*ftFace)) && index1 && index2)
129
FT_Vector kernAdvance;
130
kernAdvance.x = kernAdvance.y = 0;
132
err = FT_Get_Kerning( *ftFace, index1, index2, ft_kerning_unfitted, &kernAdvance);
135
x = static_cast<float>( kernAdvance.x) / 64.0f;
136
y = static_cast<float>( kernAdvance.y) / 64.0f;
140
return FTPoint( x, y, 0.0);
144
FT_GlyphSlot FTFace::Glyph( unsigned int index, FT_Int load_flags)
146
err = FT_Load_Glyph( *ftFace, index, load_flags);
152
return (*ftFace)->glyph;