Polyphase Game Engine
Loading...
Searching...
No Matches
Font.h
Go to the documentation of this file.
1#pragma once
2
3#include "Asset.h"
4#include "AssetRef.h"
5#include "Texture.h"
6
8{
9 int32_t mCodePoint = 0;
10 float mX = 0;
11 float mY = 0;
12 float mWidth = 0;
13 float mHeight = 0;
14 float mOriginX = 0;
15 float mOriginY = 0;
16 float mAdvance = 0;
17};
18
19class POLYPHASE_API Font : public Asset
20{
21public:
22
24
25 Font();
26 virtual ~Font();
27
28 virtual void LoadStream(Stream& stream, Platform platform) override;
29 virtual void SaveStream(Stream& stream, Platform platform) override;
30 virtual void Create() override;
31 virtual void Destroy() override;
32 virtual bool Import(const std::string& path, ImportOptions* options) override;
33 virtual void GatherProperties(std::vector<Property>& outProps) override;
34 virtual glm::vec4 GetTypeColor() override;
35 virtual const char* GetTypeName() override;
36 virtual const char* GetTypeImportExt() override;
37
38 int32_t GetSize() const;
39 int32_t GetWidth() const;
40 int32_t GetHeight() const;
41 float GetLineSpacing() const;
42 const std::vector<Character>& GetCharacters() const;
43 Texture* GetTexture() const;
44 bool IsBold() const;
45 bool IsItalic() const;
46
47 void SetTexture(Texture* texture);
48
49 void RebuildFont();
50
51 static bool HandlePropChange(Datum* datum, uint32_t index, const void* newValue);
52
53protected:
54
55 void ImportXml(const std::string& path, ImportOptions* options);
56
57 int32_t mSize = 32;
58 int32_t mWidth = 0;
59 int32_t mHeight = 0;
60 std::vector<Character> mCharacters;
62 float mLineSpacing = 0.0f;
63 bool mBold = false;
64 bool mItalic = false;
65 bool mTtf = true;
66
69 bool mMipmapped = true;
70
71 bool mFontDirty[MAX_FRAMES] = { };
72
73#if EDITOR
74 // Keep TTF data loaded in Editor.
75 Stream mTtfData;
76#endif
77};
Platform
Definition EngineTypes.h:31
FilterType
Definition GraphicsTypes.h:102
WrapMode
Definition GraphicsTypes.h:110
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition AssetRef.h:18
Definition Asset.h:113
virtual bool Import(const std::string &path, ImportOptions *options=nullptr)
Definition Asset.cpp:244
virtual void Create()
Definition Asset.cpp:77
virtual void SaveStream(Stream &stream, Platform platform)
Definition Asset.cpp:236
virtual glm::vec4 GetTypeColor()
Definition Asset.cpp:254
virtual const char * GetTypeImportExt()
Definition Asset.cpp:264
virtual const char * GetTypeName()
Definition Asset.cpp:259
virtual void GatherProperties(std::vector< Property > &outProps) override
Definition Asset.cpp:249
virtual void LoadStream(Stream &stream, Platform platform)
Definition Asset.cpp:222
virtual void Destroy()
Definition Asset.cpp:87
Definition Datum.h:164
Definition Font.h:20
DECLARE_ASSET(Font, Asset)
TextureRef mTexture
Definition Font.h:61
std::vector< Character > mCharacters
Definition Font.h:60
Definition Asset.h:102
Definition Stream.h:21
Definition Texture.h:10
Definition Font.h:8
float mOriginX
Definition Font.h:14
int32_t mCodePoint
Definition Font.h:9
float mOriginY
Definition Font.h:15
float mY
Definition Font.h:11
float mHeight
Definition Font.h:13
float mAdvance
Definition Font.h:16
float mWidth
Definition Font.h:12
float mX
Definition Font.h:10