.. index:: pair: class; EE::Graphics::Text .. _doxid-class_e_e_1_1_graphics_1_1_text: class EE::Graphics::Text ======================== .. toctree:: :hidden: enum_EE_Graphics_Text_Style.rst struct_EE_Graphics_Text_VertexCoords.rst Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class Text { public: // enums enum :ref:`Style`; // structs struct :ref:`VertexCoords`; // fields static bool :target:`TextShaperEnabled`; // construction :target:`Text`(); :target:`Text`(const :ref:`String`& string, :ref:`Font`* font, unsigned int characterSize = :ref:`PixelDensity::dpToPx`(12)); :target:`Text`(:ref:`Font`* font, unsigned int characterSize = :ref:`PixelDensity::dpToPx`(12)); // methods static :ref:`Float` :target:`tabAdvance`(:ref:`Float` spaceHorizontalAdvance, :ref:`Uint32` tabLength, std::optional<:ref:`Float`> tabOffset); static std::string :target:`styleFlagToString`(const :ref:`Uint32`& flags); static :ref:`Uint32` :target:`stringToStyleFlag`(const std::string& str); static :ref:`Float` :target:`getTextWidth`( :ref:`Font`* font, const :ref:`Uint32`& fontSize, const :ref:`String`& string, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, :ref:`Uint32` textDrawHints = 0, std::optional<:ref:`Float`> tabOffset = {} ); static :ref:`Float` :target:`getTextWidth`( :ref:`Font`* font, const :ref:`Uint32`& fontSize, const :ref:`String::View`& string, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, :ref:`Uint32` textDrawHints = 0, std::optional<:ref:`Float`> tabOffset = {} ); static :ref:`Float` :target:`getTextWidth`(const :ref:`String`& string, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, :ref:`Uint32` textDrawHints = 0, std::optional<:ref:`Float`> tabOffset = {}); static :ref:`Float` :target:`getTextWidth`(const :ref:`String::View`& string, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, :ref:`Uint32` textDrawHints = 0, std::optional<:ref:`Float`> tabOffset = {}); static :ref:`Sizef` :target:`draw`( const :ref:`String`& string, const :ref:`Vector2f`& pos, :ref:`Font`* font, :ref:`Float` fontSize, const :ref:`Color`& fontColor, :ref:`Uint32` style = 0, :ref:`Float` outlineThickness = 0.f, const :ref:`Color`& outlineColor = Color::Black, const :ref:`Color`& shadowColor = Color::Black, const :ref:`Vector2f`& shadowOffset = { 1, 1 }, const :ref:`Uint32`& tabWidth = 4, :ref:`Uint32` textDrawHints = 0, const :ref:`WhitespaceDisplayConfig`& whitespaceDisplayConfig = {} ); static :ref:`Sizef` :target:`draw`(const :ref:`String`& string, const :ref:`Vector2f`& pos, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, :ref:`Uint32` textDrawHints = 0, const :ref:`WhitespaceDisplayConfig`& whitespaceDisplayConfig = {}); static :ref:`Sizef` :target:`draw`( const :ref:`String::View`& string, const :ref:`Vector2f`& pos, :ref:`Font`* font, :ref:`Float` fontSize, const :ref:`Color`& fontColor, :ref:`Uint32` style = 0, :ref:`Float` outlineThickness = 0.f, const :ref:`Color`& outlineColor = Color::Black, const :ref:`Color`& shadowColor = Color::Black, const :ref:`Vector2f`& shadowOffset = { 1, 1 }, const :ref:`Uint32`& tabWidth = 4, :ref:`Uint32` textDrawHints = 0, const :ref:`WhitespaceDisplayConfig`& whitespaceDisplayConfig = {} ); static :ref:`Sizef` :target:`draw`(const :ref:`String::View`& string, const :ref:`Vector2f`& pos, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, :ref:`Uint32` textDrawHints = 0, const :ref:`WhitespaceDisplayConfig`& whitespaceDisplayConfig = {}); static void :target:`drawUnderline`( const :ref:`Vector2f`& pos, :ref:`Float` width, :ref:`Font`* font, :ref:`Float` fontSize, const :ref:`Color`& fontColor, const :ref:`Uint32`& style, :ref:`Float` outlineThickness, const :ref:`Color`& outlineColor, const :ref:`Color`& shadowColor, const :ref:`Vector2f`& shadowOffset ); static void :target:`drawStrikeThrough`( const :ref:`Vector2f`& pos, :ref:`Float` width, :ref:`Font`* font, :ref:`Float` fontSize, const :ref:`Color`& fontColor, const :ref:`Uint32`& style, :ref:`Float` outlineThickness, const :ref:`Color`& outlineColor, const :ref:`Color`& shadowColor, const :ref:`Vector2f`& shadowOffset ); static :ref:`Int32` :target:`findCharacterFromPos`( const :ref:`Vector2i`& pos, bool returnNearest, :ref:`Font`* font, const :ref:`Uint32`& fontSize, const :ref:`String`& string, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, std::optional<:ref:`Float`> tabOffset = {} ); static :ref:`Vector2f` :target:`findCharacterPos`( std::size_t index, :ref:`Font`* font, const :ref:`Uint32`& fontSize, const :ref:`String`& string, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, std::optional<:ref:`Float`> tabOffset = {}, bool allowNewLine = true ); static std::size_t :target:`findLastCharPosWithinLength`( :ref:`Font`* font, const :ref:`Uint32`& fontSize, const :ref:`String`& string, :ref:`Float` maxWidth, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, std::optional<:ref:`Float`> tabOffset = {} ); static std::size_t :target:`findLastCharPosWithinLength`( :ref:`Font`* font, const :ref:`Uint32`& fontSize, const :ref:`String::View`& string, :ref:`Float` maxWidth, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, std::optional<:ref:`Float`> tabOffset = {} ); static std::size_t :target:`findLastCharPosWithinLength`(const :ref:`String`& string, :ref:`Float` maxWidth, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, std::optional<:ref:`Float`> tabOffset = {}); static std::size_t :target:`findLastCharPosWithinLength`(const :ref:`String::View`& string, :ref:`Float` maxWidth, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, std::optional<:ref:`Float`> tabOffset = {}); static bool :target:`wrapText`( :ref:`Font`* font, const :ref:`Uint32`& fontSize, :ref:`String`& string, const :ref:`Float`& maxWidth, const :ref:`Uint32`& style, const :ref:`Uint32`& tabWidth = 4, const :ref:`Float`& outlineThickness = 0.f, std::optional<:ref:`Float`> tabOffset = {} ); static bool :target:`wrapText`(:ref:`String`& string, const :ref:`Float`& maxWidth, const :ref:`FontStyleConfig`& config, const :ref:`Uint32`& tabWidth = 4, std::optional<:ref:`Float`> tabOffset = {}); static Text* :target:`New`(); static Text* :target:`New`(const :ref:`String`& string, :ref:`Font`* font, unsigned int characterSize = :ref:`PixelDensity::dpToPx`(12)); static Text* :target:`New`(:ref:`Font`* font, unsigned int characterSize = :ref:`PixelDensity::dpToPx`(12)); void :ref:`create`(:ref:`Graphics::Font`* font, const :ref:`String`& text = "", :ref:`Color` FontColor = :ref:`Color`(255, 255, 255, 255), :ref:`Color` FontShadowColor = :ref:`Color`(0, 0, 0, 255), :ref:`Uint32` characterSize = :ref:`PixelDensity::dpToPx`(12)); bool :target:`setString`(const :ref:`String::View`& string); bool :target:`setString`(const :ref:`String`& string); bool :target:`setString`(:ref:`String`&& string); void :target:`setFont`(:ref:`Font`* font); void :target:`setFontSize`(unsigned int size); void :target:`setStyle`(:ref:`Uint32` style); void :target:`setColor`(const :ref:`Color`& color); void :target:`setFillColor`(const :ref:`Color`& color); void :target:`setFillColor`(const :ref:`Color`& color, :ref:`Uint32` from, :ref:`Uint32` to); void :target:`setOutlineColor`(const :ref:`Color`& color); void :target:`setOutlineThickness`(:ref:`Float` thickness); void :target:`transformText`(const :ref:`TextTransform::Value`& transform); :ref:`String`& :target:`getString`(); :ref:`Font`* :target:`getFont`() const; unsigned int :target:`getCharacterSize`() const; :ref:`Uint32` :target:`getStyle`() const; void :ref:`setAlpha`(const :ref:`Uint8`& alpha); const :ref:`Color`& :target:`getFillColor`() const; const :ref:`Color`& :target:`getColor`() const; const :ref:`Color`& :target:`getOutlineColor`() const; :ref:`Float` :target:`getOutlineThickness`() const; :ref:`Vector2f` :target:`findCharacterPos`(std::size_t index) const; :ref:`Rectf` :ref:`getLocalBounds`(); :ref:`Float` :ref:`getTextWidth`(); :ref:`Float` :ref:`getTextHeight`(); :ref:`Float` :ref:`getLineSpacing`(); void :ref:`draw`( const :ref:`Float`& X, const :ref:`Float`& Y, const :ref:`Vector2f`& scale = Vector2f::One, const :ref:`Float`& rotation = 0, :ref:`BlendMode` effect = :ref:`BlendMode::Alpha`(), const :ref:`OriginPoint`& rotationCenter = OriginPoint::OriginCenter, const :ref:`OriginPoint`& scaleCenter = OriginPoint::OriginCenter ); const :ref:`Color`& :ref:`getShadowColor`() const; void :ref:`setShadowColor`(const :ref:`Color`& color); const std::vector<:ref:`Float`>& :ref:`getLinesWidth`(); void :ref:`setAlign`(const :ref:`Uint32`& align); const :ref:`Uint32`& :ref:`getAlign`() const; :ref:`Uint32` :ref:`getNumLines`(); void :target:`setStyleConfig`(const :ref:`FontStyleConfig`& styleConfig); :ref:`Int32` :ref:`findCharacterFromPos`(const :ref:`Vector2i`& pos, bool returnNearest = true) const; void :ref:`findWordFromCharacterIndex`(:ref:`Int32` characterIndex, :ref:`Int32`& initCur, :ref:`Int32`& endCur) const; void :ref:`wrapText`(const :ref:`Uint32`& maxWidth); void :ref:`invalidateColors`(); void :ref:`invalidate`(); void :ref:`setTabWidth`(const :ref:`Uint32`& tabWidth); const :ref:`Uint32`& :ref:`getTabWidth`() const; :ref:`Color` :ref:`getBackgroundColor`() const; void :ref:`setBackgroundColor`(const :ref:`Color`& backgroundColor); bool :ref:`getDisableCacheWidth`() const; void :ref:`setDisableCacheWidth`(bool newDisableCacheWidth); const :ref:`Vector2f`& :target:`getShadowOffset`() const; void :target:`setShadowOffset`(const :ref:`Vector2f`& shadowOffset); bool :target:`hasSameFontStyleConfig`(const :ref:`FontStyleConfig`& styleConfig); void :target:`setTabStops`(bool enabled); bool :target:`hasTabStops`() const; }; .. _details-class_e_e_1_1_graphics_1_1_text: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Methods ------- .. index:: pair: function; create .. _doxid-class_e_e_1_1_graphics_1_1_text_1aaa35c4949d16c835e8554a52fdae9d5e: .. ref-code-block:: cpp :class: doxyrest-title-code-block void create(:ref:`Graphics::Font`* font, const :ref:`String`& text = "", :ref:`Color` FontColor = :ref:`Color`(255, 255, 255, 255), :ref:`Color` FontShadowColor = :ref:`Color`(0, 0, 0, 255), :ref:`Uint32` characterSize = :ref:`PixelDensity::dpToPx`(12)) Create a text from a font .. index:: pair: function; setAlpha .. _doxid-class_e_e_1_1_graphics_1_1_text_1ac856a5d67f8111f55b36cd55ca13ad85: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setAlpha(const :ref:`Uint8`& alpha) .. rubric:: See also: Set the alpha of each individual character. This doesn't break any custom color per-character setted. .. index:: pair: function; getLocalBounds .. _doxid-class_e_e_1_1_graphics_1_1_text_1a27e4db66f138bf92f67bc217f76f23e9: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Rectf` getLocalBounds() .. rubric:: Returns: The current text local bounds. .. index:: pair: function; getTextWidth .. _doxid-class_e_e_1_1_graphics_1_1_text_1ab06242b58ccb65f91fb1b44576413d40: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Float` getTextWidth() .. rubric:: Returns: The cached text width .. index:: pair: function; getTextHeight .. _doxid-class_e_e_1_1_graphics_1_1_text_1a54d9596ee8a657281532995bf15c6f53: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Float` getTextHeight() .. rubric:: Returns: The cached text height .. index:: pair: function; getLineSpacing .. _doxid-class_e_e_1_1_graphics_1_1_text_1af7f745265fd8dbf51b28e47c31e108d7: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Float` getLineSpacing() .. rubric:: Returns: The line espacing .. index:: pair: function; draw .. _doxid-class_e_e_1_1_graphics_1_1_text_1a1d775801bbece3079f1fd1aa02a28472: .. ref-code-block:: cpp :class: doxyrest-title-code-block void draw( const :ref:`Float`& X, const :ref:`Float`& Y, const :ref:`Vector2f`& scale = Vector2f::One, const :ref:`Float`& rotation = 0, :ref:`BlendMode` effect = :ref:`BlendMode::Alpha`(), const :ref:`OriginPoint`& rotationCenter = OriginPoint::OriginCenter, const :ref:`OriginPoint`& scaleCenter = OriginPoint::OriginCenter ) Draw the cached text on screen .. index:: pair: function; getShadowColor .. _doxid-class_e_e_1_1_graphics_1_1_text_1a2d0c32dada22a65b8fa91049ec5d2a4b: .. ref-code-block:: cpp :class: doxyrest-title-code-block const :ref:`Color`& getShadowColor() const .. rubric:: Returns: The Shadow :ref:`Font ` Color .. index:: pair: function; setShadowColor .. _doxid-class_e_e_1_1_graphics_1_1_text_1acb07452d6e1f6950dec561cf038b0bfa: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setShadowColor(const :ref:`Color`& color) Set the shadow color of the string rendered .. index:: pair: function; getLinesWidth .. _doxid-class_e_e_1_1_graphics_1_1_text_1aa729d8d181866fc112642168deb912a4: .. ref-code-block:: cpp :class: doxyrest-title-code-block const std::vector<:ref:`Float`>& getLinesWidth() .. rubric:: Returns: Every cached text line width .. index:: pair: function; setAlign .. _doxid-class_e_e_1_1_graphics_1_1_text_1aa55f85f439489e1baf457714d585d33c: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setAlign(const :ref:`Uint32`& align) Set the text draw align .. index:: pair: function; getAlign .. _doxid-class_e_e_1_1_graphics_1_1_text_1a35aace55cf786f7d0d7a629aba667b8e: .. ref-code-block:: cpp :class: doxyrest-title-code-block const :ref:`Uint32`& getAlign() const .. rubric:: Returns: The text align .. index:: pair: function; getNumLines .. _doxid-class_e_e_1_1_graphics_1_1_text_1a6273b78cd3c0f114f19bc90665ca52d4: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getNumLines() .. rubric:: Returns: The number of lines that the cached text contains .. index:: pair: function; findCharacterFromPos .. _doxid-class_e_e_1_1_graphics_1_1_text_1a83a0907badadbac18d5bd5c0d535aa64: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Int32` findCharacterFromPos(const :ref:`Vector2i`& pos, bool returnNearest = true) const Finds the closest cursor position to the point position .. index:: pair: function; findWordFromCharacterIndex .. _doxid-class_e_e_1_1_graphics_1_1_text_1a9b3968b46de15ec69b72a4622b7a95dd: .. ref-code-block:: cpp :class: doxyrest-title-code-block void findWordFromCharacterIndex(:ref:`Int32` characterIndex, :ref:`Int32`& initCur, :ref:`Int32`& endCur) const Simulates a selection request and return the initial and end cursor position when the selection worked. Otherwise both parameters will be -1. .. index:: pair: function; wrapText .. _doxid-class_e_e_1_1_graphics_1_1_text_1a547942704f6b182ab4d6ee2db1a6f958: .. ref-code-block:: cpp :class: doxyrest-title-code-block void wrapText(const :ref:`Uint32`& maxWidth) Shrink the :ref:`String ` to a max width .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - MaxWidth - The maximum possible width .. index:: pair: function; invalidateColors .. _doxid-class_e_e_1_1_graphics_1_1_text_1a2837da74252e1ac3c6a3cb7fccc1e1fd: .. ref-code-block:: cpp :class: doxyrest-title-code-block void invalidateColors() Invalidates the color cache .. index:: pair: function; invalidate .. _doxid-class_e_e_1_1_graphics_1_1_text_1afa6fc7978360bf7030db39cbdaf383db: .. ref-code-block:: cpp :class: doxyrest-title-code-block void invalidate() Invalidates the text cache .. index:: pair: function; setTabWidth .. _doxid-class_e_e_1_1_graphics_1_1_text_1aac1f9bcb682ba091c4d152824d5ff2da: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setTabWidth(const :ref:`Uint32`& tabWidth) Sets the tab character width. .. index:: pair: function; getTabWidth .. _doxid-class_e_e_1_1_graphics_1_1_text_1acbd4a4b499ff314823ca4a576f80b66b: .. ref-code-block:: cpp :class: doxyrest-title-code-block const :ref:`Uint32`& getTabWidth() const .. rubric:: Returns: The tab character width .. index:: pair: function; getBackgroundColor .. _doxid-class_e_e_1_1_graphics_1_1_text_1a6fcd386f4b705bdf83fc3820ea5f42a0: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Color` getBackgroundColor() const .. rubric:: Returns: The text background color .. index:: pair: function; setBackgroundColor .. _doxid-class_e_e_1_1_graphics_1_1_text_1ac3b63a39e67acb7458d4af7e6eaad6b8: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setBackgroundColor(const :ref:`Color`& backgroundColor) Sets text background color. .. index:: pair: function; getDisableCacheWidth .. _doxid-class_e_e_1_1_graphics_1_1_text_1aa25237ec11a958bffaf1a7a33093f469: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool getDisableCacheWidth() const .. rubric:: Returns: True if the text width cache is disabled. .. index:: pair: function; setDisableCacheWidth .. _doxid-class_e_e_1_1_graphics_1_1_text_1a0c8aead94d1d44b1a4d88a18659582bd: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setDisableCacheWidth(bool newDisableCacheWidth) The text width is cached every time the geometry of the text is updated. It's possible to disable this to improve performance in very specific scenarios.