-
Notifications
You must be signed in to change notification settings - Fork 0
/
font.h
35 lines (25 loc) · 1.11 KB
/
font.h
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
#ifndef _BPJ_BYTEIMAGE_FONT_H
#define _BPJ_BYTEIMAGE_FONT_H
#include "byteimage.h"
#include <ft2build.h>
#include FT_FREETYPE_H
namespace byteimage {
class TextRenderer {
protected:
static FT_Library library;
FT_Face face;
void drawGlyph(int pen_y, int pen_x, ByteImage& target, int r, int c, Byte rgb[3]) const;
public:
static int dpi;//72 by default
TextRenderer(const char* name, int size = 12, int index = 0);
virtual ~TextRenderer();
void drawUnkerned(ByteImage& target, const char* str, int r, int c, Byte v = 255) const;
void drawUnkerned(ByteImage& target, const char* str, int r, int c, Byte R, Byte G, Byte B) const;
void draw(ByteImage& target, const char* str, int r, int c, Byte v = 255) const;
void draw(ByteImage& target, const char* str, int r, int c, Byte R, Byte G, Byte B) const;
void drawCentered(ByteImage& target, const char* str, int r, int c, Byte v = 255) const;
void drawCentered(ByteImage& target, const char* str, int r, int c, Byte R, Byte G, Byte B) const;
void getBox(const char* str, int& x, int& y, int& w, int& h) const;
};
}
#endif