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

The internal structure containing font information. More...

Inheritance diagram for SDL::Font:
[legend]

Public Member Functions

constexpr Font (FontRaw resource) noexcept
 Constructs from raw Font.
constexpr Font (Font &&other) noexcept
 Move constructor.
 Font (StringParam file, float ptsize)
 Create a font from a file, using a specified point size.
 Font (IOStreamRef src, float ptsize, bool closeio=false)
 Create a font from an IOStream, using a specified point size.
 Font (PropertiesRef props)
 Create a font with the specified properties.
 ~Font ()
 Destructor.
constexpr Fontoperator= (Font &&other) noexcept
 Assignment operator.
Public Member Functions inherited from SDL::FontBase
void Close ()
 Dispose of a previously-created font.
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 (FontRef fallback)
 Add a fallback font.
void RemoveFallback (FontRef 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.
Surface GetGlyphImage (Uint32 ch, ImageType *image_type) const
 Get the pixel image for a UNICODE codepoint.
Surface GetGlyphImageForIndex (Uint32 glyph_index, ImageType *image_type) 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, ColorRaw 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, ColorRaw fg, ColorRaw 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, ColorRaw 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, ColorRaw fg, ColorRaw bg) const
 Render a single UNICODE codepoint at LCD subpixel quality to a new ARGB surface.
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< FontRaw >
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< FontRaw >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.
Static Public Member Functions inherited from SDL::FontBase
static Uint32 GetGlyphScript (Uint32 ch)
 Get the script used by a 32-bit codepoint.
Protected Member Functions inherited from SDL::ResourceBaseT< FontRaw >
constexpr ~ResourceBaseT ()=default
 Destructor.
constexpr ResourceBaseToperator= (const ResourceBaseT &)=default
 Assignment operator.

Detailed Description

The internal structure containing font information.

Opaque data!

Category:
Resource

Constructor & Destructor Documentation

◆ Font()

SDL::Font::Font ( FontRaw resource)
inlineexplicitconstexprnoexcept

Constructs from raw Font.

Parameters
resourcea FontRaw 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: