15#include <unordered_map>
68 float maxLineLength = 0.0f;
70 bool textShapeEnabled =
false;
72 float outlineThicknessPx = 0.0f;
74 float lineSpacingScale = 1.0f;
92 void Initialize()
override;
96 void Update(
float deltaTime)
override;
100 void Draw(
const Camera2D& camera)
override;
105 virtual void SetText(std::string text);
110 void SetTextColor(glm::vec4 color);
115 void SetOutlineColor(glm::vec4 color);
120 glm::vec2 GetDimensions()
const;
174 std::vector<std::uint32_t> DecodeUtf8(
const std::string& text);
181 std::string CodepointToUtf8(std::uint32_t codePoint);
188 std::vector<ShapedGlyph> ShapeText(
const std::string& text);
191 void ConstructMeshAutoLinebreak(
const std::vector<std::uint32_t>& codePoints);
196 void ConstructMesh();
201 void ShapeTextAndConstructMesh();
217 void PushQuad(std::string meshName,
218 std::unordered_map<std::string, TextBlock2D::Mesh>& meshes,
220 float horizontalShift = 0.0f);
225 void UploadMeshes(
const std::unordered_map<std::string, TextBlock2D::Mesh>& meshes);
230 void SetOutlineThickness(
float thicknessPx);
236 template <
typename T>
237 std::unordered_map<std::string, TextBlock2D::Mesh>
PrepareMeshSlots(
const std::vector<T>& glyphs);
244 std::vector<std::string> SplitString(
const std::string& text, std::string separator);
250 bool IsTextShapingRequired(std::uint32_t codePoint)
const;
253 static std::uint64_t sNumOfTextBlocks;
254 std::string mTextBlockID;
266 float mLineSpacingScale = 1.0f;
268 float mMaxLineLength = 0.0f;
Represents a 2D camera with position, rotation, and zoom control.
2D drawable component for rendering objects in 2D space.
Base class representing a renderable scene.
2D drawable representing a block of rendered text.
const unsigned int mFontSize
static std::string sDefaultFontName
std::unordered_map< std::string, std::string > mMaterialMesh
const std::string mFontName
const bool bIsTextShapeEnabled
const TextAlign mTextAlign
const float mOutlineThicknessPx
std::shared_ptr< FontResources > mFontResources
const std::shared_ptr< TextRenderer > mTextRenderer
std::unordered_map< std::string, TextBlock2D::Mesh > PrepareMeshSlots(const std::vector< T > &glyphs)
Prepares mesh slots based on glyph usage.
TextAlign
Horizontal alignment mode for text layout.
Configuration parameters for a text block.
Opaque glyph identifier within a font.
Renderable quad representing a single glyph.
std::string fontAtlasMaterialName
CPU-side mesh data for glyph quads.
std::vector< std::uint32_t > indices
std::vector< glm::vec4 > colors
std::vector< glm::vec2 > texCoords
std::vector< glm::vec2 > positions2D
std::string fontName
Font family name.
Result of text shaping for a single glyph.