summaryrefslogtreecommitdiff
path: root/Runtime/GUI/TextGenerator.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-31 14:27:26 +0800
committerchai <chaifix@163.com>2021-10-31 14:27:26 +0800
commit601442f94fc0dcfdc5a117c5f87d90b156d53045 (patch)
treeb006bcd6a28a965a900c64f4716007fcb45eee98 /Runtime/GUI/TextGenerator.h
parent26f05c6e3dcac9995345fb5a2b031be7e3ea79e9 (diff)
+static initiator
Diffstat (limited to 'Runtime/GUI/TextGenerator.h')
-rw-r--r--Runtime/GUI/TextGenerator.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/Runtime/GUI/TextGenerator.h b/Runtime/GUI/TextGenerator.h
index 1065acf..ef78eb6 100644
--- a/Runtime/GUI/TextGenerator.h
+++ b/Runtime/GUI/TextGenerator.h
@@ -51,6 +51,7 @@ struct GlyphAtals
int index;
Texture* altas; // 贴图
int width, height; // 尺寸
+
Internal::Vector2 cursor; // 游标,从左上角(0,0)开始
int rowHeight; // 当前行的高度
};
@@ -67,9 +68,12 @@ class TextGenerator : public Singleton<TextGenerator>
public:
void Setup(TextGeneratingSettings settings);
- Character GetCharacter(character::Codepoint codepoint, int pixelSize);
+ const Character* GetCharacter(character::Codepoint codepoint, int pixelSize);
+ const GlyphAtals* GetGlyphAtlas(int index);
+
+ // pre-bake
void RenderCharacter(character::Codepoint codepoint, int pixelSize);
- GlyphAtals* GetGlyphAtlas(int index);
+ void RenderCharacters(character::Codepoint* codepoint, int n, int pixelSize);
private:
@@ -79,6 +83,8 @@ private:
Internal::Rect GetRenderChartAndMove(GlyphAtals* atlas, Internal::Vector2 preferSize);
bool HasEnoughSpace(GlyphAtals* atlas, Internal::Vector2 preferSize);
+ character::Hash GetHash(character::Codepoint Codepoint, int pixelSize);
+
std::unordered_map<character::Hash, Character> m_Characters; // 渲染完的文字
std::vector<GlyphAtals> m_Atlases; // 当前所有的atlas
@@ -91,8 +97,6 @@ private:
FT_Library m_FTLibrary;
FT_Face m_FTFace;
- character::Hash GetHash(character::Codepoint Codepoint, int pixelSize);
-
};
#define g_TextGenerator (*TextGenerator::Instance())