From d638a6092bd6291c983490ba3f966162c7ca06c2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 31 Oct 2020 09:46:32 +0100 Subject: Load fonts on demand --- include/Text.hpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'include/Text.hpp') diff --git a/include/Text.hpp b/include/Text.hpp index 7ce7fa3..e471441 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -36,15 +36,21 @@ namespace QuickMedia { TEXT }; + + enum class TextType { + LATIN, + CJK, + EMOJI + }; TextElement() {} - TextElement(const StringViewUtf32 &_text, Type _type) : text(_text), type(_type), is_cjk(false) {} + TextElement(const StringViewUtf32 &_text, Type _type) : text(_text), type(_type), text_type(TextType::LATIN) {} StringViewUtf32 text; sf::Vector2f position; Type type; //bool ownLine; // Currently only used for emoji, to make emoji bigger when it's the only thing on a line - bool is_cjk; + TextType text_type; }; struct VertexRef { @@ -57,8 +63,8 @@ namespace QuickMedia class Text { public: - Text(const sf::Font *font, const sf::Font *cjk_font); - Text(sf::String str, const sf::Font *font, const sf::Font *cjk_font, unsigned int characterSize, float maxWidth); + Text(bool bold_font); + Text(sf::String str, bool bold_font, unsigned int characterSize, float maxWidth); void setString(sf::String str); const sf::String& getString() const; @@ -73,8 +79,7 @@ namespace QuickMedia void setCharacterSize(unsigned int characterSize); unsigned int getCharacterSize() const; - - const sf::Font* getFont() const; + void setFillColor(sf::Color color); void setLineSpacing(float lineSpacing); @@ -127,8 +132,7 @@ namespace QuickMedia int get_vertex_line(int index) const; private: sf::String str; // TODO: Remove this for non-editable text??? also replace with std::string? then we get more efficient editing of text - const sf::Font *font; - const sf::Font *cjk_font; + const bool bold_font; unsigned int characterSize; sf::VertexArray vertices[2]; float maxWidth; -- cgit v1.2.3