OpenCPN Partial API docs
Loading...
Searching...
No Matches
pi_TexFont.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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
41#ifndef __TEXFONT_H__
42#define __TEXFONT_H__
43
44/* support ascii plus degree symbol for now pack font in a single texture 16x8
45 */
46#define DEGREE_GLYPH 127
47#define MIN_GLYPH 32
48#define MAX_GLYPH 128
49
50#define NUM_GLYPHS (MAX_GLYPH - MIN_GLYPH)
51
52#define COLS_GLYPHS 16
53#define ROWS_GLYPHS ((NUM_GLYPHS / COLS_GLYPHS) + 1)
54
55#ifndef DECL_EXP
56#ifdef __WXMSW__
57#define DECL_EXP __declspec(dllexport)
58#else
59#define DECL_EXP
60#endif
61#endif
62
64 int x, y, width, height;
65 float advance;
66};
67
68class DECL_EXP TexFont {
69public:
70 TexFont();
71 ~TexFont();
72
73 void Build(wxFont &font, bool blur = false);
74 void Delete();
75
76 void GetTextExtent(const wxString &string, int *width, int *height);
77 void RenderString(const char *string, int x = 0, int y = 0);
78 void RenderString(const wxString &string, int x = 0, int y = 0);
79 bool IsBuilt() { return m_built; }
80
81private:
82 void GetTextExtent(const char *string, int *width, int *height);
83 void RenderGlyph(int c);
84
85 wxFont m_font;
86 bool m_blur;
87
88 TexGlyphInfo tgi[MAX_GLYPH];
89
90 unsigned int texobj;
91 int tex_w, tex_h;
92 int m_maxglyphw;
93 int m_maxglyphh;
94 bool m_built;
95
96 float m_dx;
97 float m_dy;
98};
99
100#endif // guard