Fission FSN
Loading...
Searching...
No Matches
fsCFont.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: fsCFont.h
4*
5* Purpose: bgfx font implementation. Bakes a glyph atlas with
6* stb_truetype into a bgfx texture at load time.
7*
8*********************************************************************/
9
10#ifndef fsCFonthdr
11#define fsCFonthdr
12
13#include <map>
14#include <memory>
15
16#include <bgfx/bgfx.h>
17
18#include "../../fsIFont.h"
19
20
21class fsCFont : public fsIFont
22{
23
24 friend class fsIFont;
25 friend class fsCRenderer;
26 friend class fsCNativeTextSprite;
27
28public:
29
30 virtual ~fsCFont();
31
32protected:
33
34 void initialiseDo(const fsSFontParams& pParams) override;
35
37
38private:
39
40 struct fsSGlyph
41 {
42 // atlas rect in texels
43 fsF32 mX0 = 0;
44 fsF32 mY0 = 0;
45 fsF32 mX1 = 0;
46 fsF32 mY1 = 0;
47 // layout offsets relative to the baseline pen position
48 fsF32 mXOff = 0;
49 fsF32 mYOff = 0;
50 fsF32 mXAdvance = 0;
51 };
52
53 const fsSGlyph* glyphGet(fsS32 pCodepoint) const;
54
55 std::map<fsS32, fsSGlyph> mGlyphs;
56 bgfx::TextureHandle mTexture = BGFX_INVALID_HANDLE;
57 fsS32 mAtlasWidth = 0;
58 fsS32 mAtlasHeight = 0;
59 fsF32 mPointSize = 0;
60 fsF32 mAscent = 0;
61 fsF32 mLineHeight = 0;
62
63};
64
65#endif
Definition fsCFont.h:24
friend class fsCRenderer
Definition fsCFont.h:27
void initialiseDo(const fsSFontParams &pParams) override
friend class fsIFont
Definition fsCFont.h:26
friend class fsCNativeTextSprite
Definition fsCFont.h:29
virtual ~fsCFont()
Definition fsIFont.h:34
int fsS32
Definition fsBaseTypes.h:20
float fsF32
Definition fsBaseTypes.h:28
Definition fsIFont.h:20