/
compositebitmapfont.h
84 lines (71 loc) · 2.42 KB
/
compositebitmapfont.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
/** @file compositebitmapfont.h Composite bitmap font.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>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, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef CLIENT_RESOURCE_COMPOSITEBITMAPFONT_H
#define CLIENT_RESOURCE_COMPOSITEBITMAPFONT_H
#include "abstractfont.h"
#include "def_main.h"
#include "Texture"
#include <de/Rectangle>
#include <de/String>
#include <de/Vector>
/**
* Composite bitmap font.
*
* @ingroup resource
*/
class CompositeBitmapFont : public AbstractFont
{
public:
struct Glyph
{
de::Rectanglei geometry;
patchid_t patch;
de::Texture::Variant *tex;
uint8_t border;
bool haveSourceImage;
};
public:
CompositeBitmapFont(de::FontManifest &manifest);
static CompositeBitmapFont *fromDef(de::FontManifest &manifest, ded_compositefont_t const &def);
ded_compositefont_t *definition() const;
void setDefinition(ded_compositefont_t *newDef);
/**
* Update the font according to the supplied definition. To be called after
* an engine update/reset.
*
* @param def Definition to update using.
*
* @todo Should observe engine reset.
*/
void rebuildFromDef(ded_compositefont_t const &def);
int ascent();
int descent();
int lineSpacing();
void glInit();
void glDeinit();
de::Rectanglei const &glyphPosCoords(uchar ch);
de::Rectanglei const &glyphTexCoords(uchar ch);
patchid_t glyphPatch(uchar ch);
void glyphSetPatch(uchar ch, de::String encodedPatchName);
de::Texture::Variant *glyphTexture(uchar ch);
uint glyphTextureBorder(uchar ch);
private:
DENG2_PRIVATE(d)
};
#endif // CLIENT_RESOURCE_COMPOSITEBITMAPFONT_H