23 #include FT_FREETYPE_H 27 Font::GlyphData::GlyphData(
int offsetX, FT_GlyphSlot ft_glyphSlot):
28 advanceX(ft_glyphSlot->advance.x),
29 advanceY(ft_glyphSlot->advance.y),
30 bitmapWidth(ft_glyphSlot->bitmap.width),
31 bitmapHeight(ft_glyphSlot->bitmap.rows),
32 bitmapLeft(ft_glyphSlot->bitmap_left),
33 bitmapTop(ft_glyphSlot->bitmap_top),
39 checkInvalidCharacter(character);
40 return glyphs[character-32];
43 void Font::checkInvalidCharacter(
unsigned char character) {
44 if(character < 32 || character >= 128) {
45 throw std::invalid_argument(
"The font only support characters with" 46 " ascii value from 32 inclusive to 128 exclusive.");
50 void Font::addGlyph(FT_GlyphSlot glyph,
int offsetX,
unsigned char character) {
51 checkInvalidCharacter(character);
52 glyphs[character-32] = GlyphData(offsetX,glyph);
55 int Font::getPixelSize() {
59 Font::Font(
int pixelSize) : pixelSize(pixelSize) {