SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::Text Struct Reference

Text created with CreateText(). More...

Inheritance diagram for SDL::Text:
[legend]

Public Member Functions

constexpr Text (TextRaw resource) noexcept
 Constructs from raw Text.
constexpr Text (Text &&other) noexcept
 Move constructor.
 Text (TextEngineRef engine, FontRef font, std::string_view text)
 Create a text object from UTF-8 text and a text engine.
 ~Text ()
 Destructor.
constexpr Textoperator= (Text &&other) noexcept
 Assignment operator.
Public Member Functions inherited from SDL::TextBase
constexpr operator TextConstRef () const noexcept
 Converts to TextConstRef.
void Destroy ()
 Destroy a text object created by a text engine.
void DrawSurface (Point p, SurfaceRef surface) const
 Draw text to an SDL surface.
void DrawRenderer (FPoint p) const
 Draw text to an SDL renderer.
GPUAtlasDrawSequenceGetGPUDrawData () const
 Get the geometry data needed for drawing the text.
PropertiesRef GetProperties () const
 Get the properties associated with a text object.
void SetEngine (TextEngineRef engine)
 Set the text engine used by a text object.
TextEngineRef GetEngine () const
 Get the text engine used by a text object.
bool SetFont (FontRef font)
 Set the font used by a text object.
FontRef GetFont () const
 Get the font used by a text object.
void SetDirection (Direction direction)
 Set the direction to be used for text shaping a text object.
Direction GetDirection () const
 Get the direction to be used for text shaping a text object.
void SetScript (Uint32 script)
 Set the script to be used for text shaping a text object.
Uint32 GetScript () const
 Get the script used for text shaping a text object.
void SetColor (Color c)
 Set the color of a text object.
void SetColorFloat (FColor c)
 Set the color of a text object.
void GetColor (Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
 Get the color of a text object.
Color GetColor () const
 Get the color of a text object.
void GetColorFloat (float *r, float *g, float *b, float *a) const
 Get the color of a text object.
FColor GetColorFloat () const
 Get the color of a text object.
void SetPosition (const PointRaw &p)
 Set the position of a text object.
void GetPosition (int *x, int *y) const
 Get the position of a text object.
Point GetPosition () const
 Get the position of a text object.
void SetWrapWidth (int wrap_width)
 Set whether wrapping is enabled on a text object.
int GetWrapWidth () const
 Get whether wrapping is enabled on a text object.
void SetWrapWhitespaceVisible (bool visible)
 Set whether whitespace should be visible when wrapping a text object.
bool IsWrapWhitespaceVisible () const
 Return whether whitespace is shown when wrapping a text object.
void SetString (std::string_view string)
 Set the UTF-8 text used by a text object.
void InsertString (int offset, std::string_view string)
 Insert UTF-8 text into a text object.
void AppendString (std::string_view string)
 Append UTF-8 text to a text object.
void DeleteString (int offset, int length)
 Delete UTF-8 text from a text object.
void GetSize (int *w, int *h) const
 Get the size of a text object.
Point GetSize () const
 Get the size of a text object.
void GetSubString (int offset, SubString *substring) const
 Get the substring of a text object that surrounds a text offset.
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.
void GetSubStringForLine (int line, SubString *substring) const
 Get the substring of a text object that contains the given line.
OwnArray< SubString * > GetSubStrings () const
 Get all substrings of a text object.
OwnArray< SubString * > GetSubStringsForRange (int offset, int length=-1) const
 Get the substrings of a text object that contain a range of text.
SubStringIterator GetSubStringForPoint (Point p) const
 Get the portion of a text string that is closest to a point.
void GetSubStringForPoint (Point p, SubString *substring) const
 Get the portion of a text string that is closest to a point.
void GetPreviousSubString (const SubString &substring, SubString *previous) const
 Get the previous substring in a text object.
void GetNextSubString (const SubString &substring, SubString *next) const
 Get the next substring in a text object.
void Update ()
 Update the layout of a text object.
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.
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr ResourceBaseT (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBaseT (std::nullptr_t)
 Constructs null/invalid.
constexpr ResourceBaseT (const ResourceBaseT &)=default
 Copy constructor.
constexpr ResourceBaseT (ResourceBaseT &&) noexcept=default
 Move constructor.
Public Member Functions inherited from SDL::ResourceBaseT< TextRaw, TextRawConst >
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr operator bool () const
 Converts to bool.
constexpr auto operator<=> (const ResourceBaseT &other) const=default
 Comparison.
constexpr RawConstPointer operator-> () const noexcept
 member access to underlying resource pointer.
constexpr RawPointer get () const noexcept
 Retrieves underlying resource pointer.
constexpr RawPointer release () noexcept
 Retrieves underlying resource pointer and clear this.

Additional Inherited Members

Public Types inherited from SDL::ResourceBaseT< TextRaw, TextRawConst >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.
Protected Member Functions inherited from SDL::ResourceBaseT< TextRaw, TextRawConst >
constexpr ~ResourceBaseT ()=default
 Destructor.
constexpr ResourceBaseToperator= (const ResourceBaseT &)=default
 Assignment operator.

Detailed Description

Text created with CreateText().

Since
This struct is available since SDL_ttf 3.0.0.
See also
CreateText
GetTextProperties
DestroyText
Category:
Resource

Constructor & Destructor Documentation

◆ Text()

SDL::Text::Text ( TextRaw resource)
inlineexplicitconstexprnoexcept

Constructs from raw Text.

Parameters
resourcea TextRaw to be wrapped.

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


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