mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-08 06:48:56 -04:00
Implement all font rendering functions
This commit is contained in:
parent
8a7d5cab0e
commit
9a3f3339ef
@ -67,6 +67,27 @@ Surface Font::RenderText_Solid(const std::string& text, SDL_Color fg) {
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderUTF8_Solid(const std::string& text, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderUTF8_Solid(font_, text.c_str(), fg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderUTF8_Solid failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderUNICODE_Solid(const Uint16* text, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderUNICODE_Solid(font_, text, fg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderUNICODE_Solid failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderGlyph_Solid(Uint16 ch, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderGlyph_Solid(font_, ch, fg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderGlyph_Solid failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderText_Shaded(const std::string& text, SDL_Color fg, SDL_Color bg) {
|
||||
SDL_Surface* surface = TTF_RenderText_Shaded(font_, text.c_str(), fg, bg);
|
||||
if (surface == nullptr)
|
||||
@ -74,6 +95,27 @@ Surface Font::RenderText_Shaded(const std::string& text, SDL_Color fg, SDL_Color
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderUTF8_Shaded(const std::string& text, SDL_Color fg, SDL_Color bg) {
|
||||
SDL_Surface* surface = TTF_RenderUTF8_Shaded(font_, text.c_str(), fg, bg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderUTF8_Shaded failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderUNICODE_Shaded(const Uint16* text, SDL_Color fg, SDL_Color bg) {
|
||||
SDL_Surface* surface = TTF_RenderUNICODE_Shaded(font_, text, fg, bg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderUNICODE_Shaded failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderGlyph_Shaded(Uint16 ch, SDL_Color fg, SDL_Color bg) {
|
||||
SDL_Surface* surface = TTF_RenderGlyph_Shaded(font_, ch, fg, bg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderGlyph_Shaded failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderText_Blended(const std::string& text, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderText_Blended(font_, text.c_str(), fg);
|
||||
if (surface == nullptr)
|
||||
@ -81,4 +123,25 @@ Surface Font::RenderText_Blended(const std::string& text, SDL_Color fg) {
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderUTF8_Blended(const std::string& text, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderUTF8_Blended(font_, text.c_str(), fg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderUTF8_Blended failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderUNICODE_Blended(const Uint16* text, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderUNICODE_Blended(font_, text, fg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderUNICODE_Blended failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
Surface Font::RenderGlyph_Blended(Uint16 ch, SDL_Color fg) {
|
||||
SDL_Surface* surface = TTF_RenderGlyph_Blended(font_, ch, fg);
|
||||
if (surface == nullptr)
|
||||
throw Exception("TTF_RenderGlyph_Blended failed");
|
||||
return Surface(surface);
|
||||
}
|
||||
|
||||
}
|
||||
|
140
SDL2pp/Font.hh
140
SDL2pp/Font.hh
@ -33,7 +33,7 @@ namespace SDL2pp {
|
||||
class RWops;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Loaded font
|
||||
/// \brief Holder of a loaded font
|
||||
///
|
||||
/// \ingroup ttf
|
||||
///
|
||||
@ -130,6 +130,51 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderText_Solid(const std::string& text, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render UTF8 text using solid mode
|
||||
///
|
||||
/// \param text UTF8 string to render
|
||||
/// \param fg Color to render the text in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC44
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderUTF8_Solid(const std::string& text, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render UNICODE encoded text using solid mode
|
||||
///
|
||||
/// \param text UNICODE encoded string to render
|
||||
/// \param fg Color to render the text in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC45
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderUNICODE_Solid(const Uint16* text, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render the glyph for UNICODE character using solid mode
|
||||
///
|
||||
/// \param ch UNICODE character to render
|
||||
/// \param fg Color to render the glyph in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC46
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderGlyph_Solid(Uint16 ch, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render LATIN1 text using shaded mode
|
||||
///
|
||||
@ -146,6 +191,54 @@ public:
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderText_Shaded(const std::string& text, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render UTF8 text using shaded mode
|
||||
///
|
||||
/// \param text UTF8 string to render
|
||||
/// \param fg Color to render the text in
|
||||
/// \param bg Color to render the background box in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC48
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderUTF8_Shaded(const std::string& text, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render UNICODE encoded text using shaded mode
|
||||
///
|
||||
/// \param text UNICODE encoded string to render
|
||||
/// \param fg Color to render the text in
|
||||
/// \param bg Color to render the background box in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC49
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderUNICODE_Shaded(const Uint16* text, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render the glyph for UNICODE character using shaded mode
|
||||
///
|
||||
/// \param ch UNICODE character to render
|
||||
/// \param fg Color to render the glyph in
|
||||
/// \param bg Color to render the background box in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC50
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderGlyph_Shaded(Uint16 ch, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render LATIN1 text using blended mode
|
||||
///
|
||||
@ -160,6 +253,51 @@ public:
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderText_Blended(const std::string& text, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render UTF8 text using blended mode
|
||||
///
|
||||
/// \param text UTF8 string to render
|
||||
/// \param fg Color to render the text in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC48
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderUTF8_Blended(const std::string& text, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render UNICODE encoded text using blended mode
|
||||
///
|
||||
/// \param text UNICODE encoded string to render
|
||||
/// \param fg Color to render the text in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC49
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderUNICODE_Blended(const Uint16* text, SDL_Color fg);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render the glyph for UNICODE character using blended mode
|
||||
///
|
||||
/// \param ch UNICODE character to render
|
||||
/// \param fg Color to render the glyph in
|
||||
///
|
||||
/// \returns Surface containing rendered text
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC50
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface RenderGlyph_Blended(Uint16 ch, SDL_Color fg);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user