diff options
Diffstat (limited to 'Runtime/GUI/TextGenerator.h')
-rw-r--r-- | Runtime/GUI/TextGenerator.h | 12 |
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()) |