-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirrtum.h
91 lines (70 loc) · 2.44 KB
/
irrtum.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
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
/*
Irrtum
Copyright (C) 2011-2015 kahrl <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef IRRTUM_HEADER
#define IRRTUM_HEADER
#include "common.h"
#include "graybitmap.h"
#include "intervallist.h"
#include "rect.h"
class Irrtum
{
public:
Irrtum();
~Irrtum();
std::string getLastError() const;
bool initLibpng();
bool initFreetype();
std::string getLibpngVersion() const;
std::string getFreetypeVersion() const;
void setColor(u32 color);
void setCharacterRanges(const IntervalList& cranges);
// stage 1: loading the font face
bool loadFace(string filename, float size, float dpi);
// stage 2: building the layout
bool layout(s32 outwidth, s32 outheight);
s32 getLayoutWidth() const;
s32 getLayoutHeight() const;
// stage 3: drawing a grayscale bitmap
bool drawGrayscaleBitmap();
// stage 4: converting to ARGB and writing the PNG file
string getOutputFilename(string filename) const;
bool outputPNG(string outputFilename);
private:
Irrtum(const Irrtum&);
Irrtum& operator=(const Irrtum&);
bool getCharBitmapSize(s32 ch, s32& width, s32& height);
bool getTotalBitmapSize(s32& area);
bool tryLayout(s32 outwidth, s32 outheight, bool& tooLarge);
void setRGBAPixel(s32 width, s32 height, u8* data, s32 x, s32 y, u32 color) const;
void freetypeError(FT_Error error);
// fields
std::string m_error;
FT_Library m_ftlibrary;
bool m_ftinited;
u8 m_color_red;
u8 m_color_green;
u8 m_color_blue;
IntervalList m_cranges;
// stage 1 fields: loading the font face
FT_Face m_face;
// stage 2 fields: building the layout
s32 m_layoutwidth;
s32 m_layoutheight;
vector<Rect> m_layoutrects;
// stage 3 fields: drawing a grayscale bitmap
GrayBitmap* m_graybitmap;
};
#endif