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

Handle to an owned font. More...

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

Public Member Functions

constexpr Font (TTF_Font *resource={})
 Constructs from the underlying resource.
 
constexpr Font (const Font &other)=delete
 
constexpr Font (Font &&other)=default
 Move constructor.
 
 ~Font ()
 Frees up resource when object goes out of scope.
 
Fontoperator= (Font other)
 Assignment operator.
 
constexpr FontRef (const FontRef &other)
 Copy constructor.
 
constexpr FontRef (FontRef &&other)
 Move constructor.
 
- Public Member Functions inherited from SDL::FontRef
constexpr FontRef (const FontRef &other)
 Copy constructor.
 
constexpr FontRef (FontRef &&other)
 Move constructor.
 
constexpr ~FontRef ()=default
 Default constructor.
 
FontRefoperator= (FontRef other)
 Assignment operator.
 
void reset (TTF_Font *newResource={})
 Dispose of a previously-created font.
 
 FontBase (StringParam file, float ptsize)
 Create a font from a file, using a specified point size.
 
 FontBase (IOStreamBase &src, float ptsize)
 Create a font from an IOStreamBase, using a specified point size.
 
 FontBase (PropertiesBase &props)
 Create a font with the specified properties.
 
- Public Member Functions inherited from SDL::FontBase
 FontBase (StringParam file, float ptsize)
 Create a font from a file, using a specified point size.
 
 FontBase (IOStreamBase &src, float ptsize)
 Create a font from an IOStreamBase, using a specified point size.
 
 FontBase (PropertiesBase &props)
 Create a font with the specified properties.
 
Font Copy () const
 Create a copy of an existing font.
 
PropertiesRef GetProperties ()
 Get the properties associated with a font.
 
Uint32 GetGeneration () const
 Get the font generation.
 
void AddFallback (FontBase &fallback)
 Add a fallback font.
 
void RemoveFallback (FontBase &fallback)
 Remove a fallback font.
 
void ClearFallbacks ()
 Remove all fallback fonts.
 
void SetSize (float ptsize)
 Set a font's size dynamically.
 
void SetSizeDPI (float ptsize, int hdpi, int vdpi)
 Set font size dynamically with target resolutions, in dots per inch.
 
float GetSize () const
 Get the size of a font.
 
void GetDPI (int *hdpi, int *vdpi) const
 Get font target resolutions, in dots per inch.
 
void SetStyle (FontStyleFlags style)
 Set a font's current style.
 
FontStyleFlags GetStyle () const
 Query a font's current style.
 
void SetOutline (int outline)
 Set a font's current outline.
 
int GetOutline () const
 Query a font's current outline.
 
void SetHinting (HintingFlags hinting)
 Set a font's current hinter setting.
 
int GetNumFaces () const
 Query the number of faces of a font.
 
HintingFlags GetHinting () const
 Query a font's current FreeType hinter setting.
 
void SetSDF (bool enabled)
 Enable Signed Distance Field rendering for a font.
 
bool GetSDF () const
 Query whether Signed Distance Field rendering is enabled for a font.
 
int GetWeight () const
 Query a font's weight, in terms of the lightness/heaviness of the strokes.
 
void SetWrapAlignment (HorizontalAlignment align)
 Set a font's current wrap alignment option.
 
HorizontalAlignment GetWrapAlignment () const
 Query a font's current wrap alignment option.
 
int GetHeight () const
 Query the total height of a font.
 
int GetAscent () const
 Query the offset from the baseline to the top of a font.
 
int GetDescent () const
 Query the offset from the baseline to the bottom of a font.
 
void SetLineSkip (int lineskip)
 Set the spacing between lines of text for a font.
 
int GetLineSkip () const
 Query the spacing between lines of text for a font.
 
void SetKerning (bool enabled)
 Set if kerning is enabled for a font.
 
bool GetKerning () const
 Query whether or not kerning is enabled for a font.
 
bool IsFixedWidth () const
 Query whether a font is fixed-width.
 
bool IsScalable () const
 Query whether a font is scalable or not.
 
const char * GetFamilyName () const
 Query a font's family name.
 
const char * GetStyleName () const
 Query a font's style name.
 
void SetDirection (Direction direction)
 Set the direction to be used for text shaping by a font.
 
Direction GetDirection () const
 Get the direction to be used for text shaping by a font.
 
void SetScript (Uint32 script)
 Set the script to be used for text shaping by a font.
 
Uint32 GetScript () const
 Get the script used for text shaping a font.
 
void SetLanguage (StringParam language_bcp47)
 Set language to be used for text shaping by a font.
 
bool HasGlyph (Uint32 ch) const
 Check whether a glyph is provided by the font for a UNICODE codepoint.
 
SurfaceRef GetGlyphImage (Uint32 ch, ImageType *image_type=nullptr) const
 Get the pixel image for a UNICODE codepoint.
 
SurfaceRef GetGlyphImageForIndex (Uint32 glyph_index, ImageType *image_type=nullptr) const
 Get the pixel image for a character index.
 
void GetGlyphMetrics (Uint32 ch, int *minx, int *maxx, int *miny, int *maxy, int *advance) const
 Query the metrics (dimensions) of a font's glyph for a UNICODE codepoint.
 
int GetGlyphKerning (Uint32 previous_ch, Uint32 ch) const
 Query the kerning size between the glyphs of two UNICODE codepoints.
 
Point GetStringSize (std::string_view text) const
 Calculate the dimensions of a rendered string of UTF-8 text.
 
void GetStringSize (std::string_view text, int *w, int *h) const
 Calculate the dimensions of a rendered string of UTF-8 text.
 
Point GetStringSizeWrapped (std::string_view text, int wrap_width) const
 Calculate the dimensions of a rendered string of UTF-8 text.
 
void GetStringSizeWrapped (std::string_view text, int wrap_width, int *w, int *h) const
 Calculate the dimensions of a rendered string of UTF-8 text.
 
void MeasureString (std::string_view text, int max_width, int *measured_width, size_t *measured_length) const
 Calculate how much of a UTF-8 string will fit in a given width.
 
Surface RenderText_Solid (std::string_view text, Color fg) const
 Render UTF-8 text at fast quality to a new 8-bit surface.
 
Surface RenderText_Solid_Wrapped (std::string_view text, Color fg, int wrapLength) const
 Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface.
 
Surface RenderGlyph_Solid (Uint32 ch, Color fg) const
 Render a single 32-bit glyph at fast quality to a new 8-bit surface.
 
Surface RenderText_Shaded (std::string_view text, Color fg, Color bg) const
 Render UTF-8 text at high quality to a new 8-bit surface.
 
Surface RenderText_Shaded_Wrapped (std::string_view text, Color fg, Color bg, int wrap_width) const
 Render word-wrapped UTF-8 text at high quality to a new 8-bit surface.
 
Surface RenderGlyph_Shaded (Uint32 ch, Color fg, Color bg) const
 Render a single UNICODE codepoint at high quality to a new 8-bit surface.
 
Surface RenderText_Blended (std::string_view text, Color fg) const
 Render UTF-8 text at high quality to a new ARGB surface.
 
Surface RenderText_Blended_Wrapped (std::string_view text, Color fg, int wrap_width) const
 Render word-wrapped UTF-8 text at high quality to a new ARGB surface.
 
Surface RenderGlyph_Blended (Uint32 ch, Color fg) const
 Render a single UNICODE codepoint at high quality to a new ARGB surface.
 
Surface RenderText_LCD (std::string_view text, Color fg, Color bg) const
 Render UTF-8 text at LCD subpixel quality to a new ARGB surface.
 
Surface RenderText_LCD_Wrapped (std::string_view text, Color fg, Color bg, int wrap_width) const
 Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB surface.
 
Surface RenderGlyph_LCD (Uint32 ch, Color fg, Color bg) const
 Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface.
 
constexpr Resource (T resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
- Public Member Functions inherited from SDL::Resource< TTF_Font * >
constexpr Resource (TTF_Font * resource={})
 Constructs the underlying resource.
 
constexpr Resource (std::nullptr_t)
 Equivalent to default ctor.
 
constexpr Resource (std::nullopt_t)
 Equivalent to default ctor.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other)=delete
 
Resourceoperator= (const Resource &other)=delete
 
Resourceoperator= (Resource &&other)=delete
 
constexpr operator bool () const
 True if contains a valid resource.
 
constexpr bool operator== (const Resource &other) const=default
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr TTF_Font * get () const
 Return contained resource;.
 
constexpr TTF_Font * release (TTF_Font * newResource={})
 Return contained resource and empties or replace value.
 
constexpr const TTF_Font * operator-> () const
 Access to fields.
 
constexpr TTF_Font * operator-> ()
 Access to fields.
 

Additional Inherited Members

- Static Public Member Functions inherited from SDL::FontBase
static Uint32 GetGlyphScript (Uint32 ch)
 Get the script used by a 32-bit codepoint.
 

Detailed Description

Category:
Resource
See also
FontBase
FontRef

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