SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members

Text created with Text.Text() More...

Inheritance diagram for SDL::Text:
Inheritance graph
[legend]

Public Member Functions

constexpr Text ()=default
 Default ctor.
 
constexpr Text (const TextRaw resource)
 Constructs from TextParam. More...
 
constexpr Text (const Text &other)=delete
 Copy constructor.
 
constexpr Text (Text &&other)
 Move constructor.
 
constexpr Text (const TextRef &other)=delete
 
constexpr Text (TextRef &&other)=delete
 
 Text (TextEngineParam engine, FontParam font, std::string_view text)
 Create a text object from UTF-8 text and a text engine. More...
 
 ~Text ()
 Destructor.
 
Textoperator= (Text other)
 Assignment operator.
 
constexpr TextRaw get () const
 Retrieves underlying TextRaw.
 
constexpr TextRaw release ()
 Retrieves underlying TextRaw and clear this.
 
constexpr auto operator<=> (const Text &other) const =default
 Comparison.
 
constexpr bool operator== (std::nullptr_t _) const
 Comparison.
 
constexpr operator bool () const
 converts to bool
 
constexpr operator TextParam () const
 Converts to TextParam.
 
void Destroy ()
 Destroy a text object created by a text engine. More...
 
void DrawSurface (Point p, SurfaceParam surface) const
 Draw text to an SDL surface. More...
 
void DrawRenderer (FPoint p) const
 Draw text to an SDL renderer. More...
 
GPUAtlasDrawSequenceGetGPUDrawData () const
 Get the geometry data needed for drawing the text. More...
 
PropertiesRef GetProperties () const
 Get the properties associated with a text object. More...
 
void SetEngine (TextEngineParam engine)
 Set the text engine used by a text object. More...
 
TextEngineParam GetEngine () const
 Get the text engine used by a text object. More...
 
bool SetFont (FontParam font)
 Set the font used by a text object. More...
 
FontRef GetFont () const
 Get the font used by a text object. More...
 
void SetDirection (Direction direction)
 Set the direction to be used for text shaping a text object. More...
 
Direction GetDirection () const
 Get the direction to be used for text shaping a text object. More...
 
void SetScript (Uint32 script)
 Set the script to be used for text shaping a text object. More...
 
Uint32 GetScript () const
 Get the script used for text shaping a text object. More...
 
void SetColor (Color c)
 Set the color of a text object. More...
 
void SetColorFloat (FColor c)
 Set the color of a text object. More...
 
void GetColor (Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
 Get the color of a text object. More...
 
Color GetColor () const
 Get the color of a text object. More...
 
void GetColorFloat (float *r, float *g, float *b, float *a) const
 Get the color of a text object. More...
 
FColor GetColorFloat () const
 Get the color of a text object. More...
 
bool SetPosition (Point p)
 Set the position of a text object. More...
 
bool GetPosition (int *x, int *y) const
 Get the position of a text object. More...
 
Point GetPosition () const
 Get the position of a text object. More...
 
void SetWrapWidth (int wrap_width)
 Set whether wrapping is enabled on a text object. More...
 
int GetWrapWidth () const
 Get whether wrapping is enabled on a text object. More...
 
void SetWrapWhitespaceVisible (bool visible)
 Set whether whitespace should be visible when wrapping a text object. More...
 
bool IsWrapWhitespaceVisible () const
 Return whether whitespace is shown when wrapping a text object. More...
 
void SetString (std::string_view string)
 Set the UTF-8 text used by a text object. More...
 
void InsertString (int offset, std::string_view string)
 Insert UTF-8 text into a text object. More...
 
void AppendString (std::string_view string)
 Append UTF-8 text to a text object. More...
 
void DeleteString (int offset, int length)
 Delete UTF-8 text from a text object. More...
 
void GetSize (int *w, int *h) const
 Get the size of a text object. More...
 
Point GetSize () const
 Get the size of a text object. More...
 
void GetSubString (int offset, SubString *substring) const
 Get the substring of a text object that surrounds a text offset. More...
 
SubStringIterator begin () const
 Get iterator to first substring.
 
SubStringIterator end () const
 Get iterator to one past last substring.
 
SubStringIterator GetSubStringForLine (int line) const
 Get iterator to substring of a text object that contains the given line. More...
 
void GetSubStringForLine (int line, SubString *substring) const
 Get the substring of a text object that contains the given line. More...
 
OwnArray< SubString * > GetSubStrings () const
 Get all substrings of a text object. More...
 
OwnArray< SubString * > GetSubStringsForRange (int offset, int length=-1) const
 Get the substrings of a text object that contain a range of text. More...
 
SubStringIterator GetSubStringForPoint (Point p) const
 Get the portion of a text string that is closest to a point. More...
 
void GetSubStringForPoint (Point p, SubString *substring) const
 Get the portion of a text string that is closest to a point. More...
 
void GetPreviousSubString (const SubString &substring, SubString *previous) const
 Get the previous substring in a text object. More...
 
void GetNextSubString (const SubString &substring, SubString *next) const
 Get the next substring in a text object. More...
 
void Update ()
 Update the layout of a text object. More...
 
const char * GetText () const
 A copy of the UTF-8 string that this text object represents, useful for layout, debugging and retrieving substring text.
 
int GetNumLines () const
 The number of lines in the text, 0 if it's empty.
 

Detailed Description

Since
This struct is available since SDL_ttf 3.0.0.
See also
Text.Text
Text.GetProperties
Text.Destroy
Category:
Resource

Constructor & Destructor Documentation

◆ Text() [1/2]

constexpr SDL::Text::Text ( const TextRaw  resource)
inlineexplicitconstexpr
Parameters
resourcea TextRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ Text() [2/2]

SDL::Text::Text ( TextEngineParam  engine,
FontParam  font,
std::string_view  text 
)
inline
Parameters
enginethe text engine to use when creating the text object, may be nullptr.
fontthe font to render with.
textthe text to use, in UTF-8 encoding.
Postcondition
a Text object or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the font and text engine.
Since
This function is available since SDL_ttf 3.0.0.
See also
Text.Destroy

Member Function Documentation

◆ GetSubStringForLine()

SubStringIterator SDL::Text::GetSubStringForLine ( int  line) const

If line is greater than or equal to text->num_lines this will return an iterator equal to end().

Parameters
linea zero-based line index, in the range [0 .. text->num_lines-1].
Returns
iterator on success or false on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the text.
Since
This function is available since SDL_ttf 3.0.0.

◆ GetSubStringForPoint()

SubStringIterator SDL::Text::GetSubStringForPoint ( Point  p) const

This will return the closest substring of text to the given point.

Parameters
pthe coordinates relative to the top-left side of the text, may be outside the bounds of the text area.
Returns
the iterator on success or false on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the text.
Since
This function is available since SDL_ttf 3.0.0.

◆ GetSubStrings()

OwnArray< SubString * > SDL::Text::GetSubStrings ( ) const
inline
Returns
a nullptr terminated array of substring pointers or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the text.
Since
This function is available since SDL_ttf 3.0.0.

The documentation for this class was generated from the following file: