OpenCPN Partial API docs
Loading...
Searching...
No Matches
pi_tex_font.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2014 Sean D'Epagnier *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
42#ifndef TExfoNT_H_
43#define TExfoNT_H_
44
45/* support ascii plus degree symbol for now pack font in a single texture 16x8
46 */
47#define DEGREE_GLYPH 127
48#define MIN_GLYPH 32
49#define MAX_GLYPH 128
50
51#define NUM_GLYPHS (MAX_GLYPH - MIN_GLYPH)
52
53#define COLS_GLYPHS 16
54#define ROWS_GLYPHS ((NUM_GLYPHS / COLS_GLYPHS) + 1)
55
56#ifndef DECL_EXP
57#ifdef __WXMSW__
58#define DECL_EXP __declspec(dllexport)
59#else
60#define DECL_EXP
61#endif
62#endif
63
65 int x, y, width, height;
66 float advance;
67};
68
69class DECL_EXP TexFont {
70public:
71 TexFont();
72 ~TexFont();
73
74 void Build(wxFont &font, bool blur = false);
75 void Delete();
76
77 void GetTextExtent(const wxString &string, int *width, int *height);
78 void RenderString(const char *string, int x = 0, int y = 0);
79 void RenderString(const wxString &string, int x = 0, int y = 0);
80 bool IsBuilt() const { return m_built; }
81
82private:
83 void GetTextExtent(const char *string, int *width, int *height);
84 void RenderGlyph(int c);
85
86 wxFont m_font;
87 bool m_blur;
88
89 TexGlyphInfo tgi[MAX_GLYPH];
90
91 unsigned int texobj;
92 int tex_w, tex_h;
93 int m_maxglyphw;
94 int m_maxglyphh;
95 bool m_built;
96
97 float m_dx;
98 float m_dy;
99};
100
101#endif // TExfoNT_H_