bwidgets/inc/basic_widgets/core/font.hpp

80 lines
2.4 KiB
C++

#ifndef BWIDGETS_FONT_HPP
#define BWIDGETS_FONT_HPP
#include <memory>
#include <string>
#include <SDL2/SDL_ttf.h>
#include <basic_widgets/core/type/color.hpp>
#include <basic_widgets/core/type/opaque_struct.hpp>
#include <basic_widgets/core/type/size.hpp>
namespace bwidgets
{
class Font final : OpaqueStruct<TTF_Font>::Wrapper
{
public:
enum struct Hinting
{
LIGHT = TTF_HINTING_LIGHT,
MONO = TTF_HINTING_MONO,
NONE = TTF_HINTING_NONE,
NORMAL = TTF_HINTING_NORMAL
};
enum struct RenderMode
{
SOLID,
SHADED,
BLENDED
};
enum struct Style
{
BOLD = TTF_STYLE_BOLD,
ITALIC = TTF_STYLE_ITALIC,
NORMAL = TTF_STYLE_NORMAL,
STRIKETHROUGH = TTF_STYLE_STRIKETHROUGH,
UNDERLINE = TTF_STYLE_UNDERLINE
};
static const Color default_color_bg;
static const Color default_color_fg;
const int ascent;
const int descent;
const long faces;
const std::string family_name;
const bool fixed_width;
const int height;
const int line_skip;
const std::string style_name;
Font(TTF_Font*);
Font(const std::string&, int);
Font(const Font&) = delete;
Font(Font&&) = delete;
~Font() noexcept = default;
auto operator=(const Font&) = delete;
auto operator=(Font&&) = delete;
[[nodiscard]] auto hinting() const noexcept -> Hinting;
auto hinting(Hinting) noexcept -> Font*;
[[nodiscard]] auto kerning() const noexcept -> bool;
auto kerning(bool) noexcept -> Font*;
[[nodiscard]] auto outline() const noexcept -> int;
auto outline(int) noexcept -> Font*;
auto render(RenderMode, const std::string&, Color fg = default_color_fg,
Color bg = default_color_bg) -> SDL_Surface*;
[[nodiscard]] auto style() const noexcept -> uint8_t;
auto style(uint8_t) noexcept -> Font*;
[[nodiscard]] auto text_size(const std::string&) const noexcept -> Size;
[[nodiscard]] static auto find(const std::string&) -> std::string;
};
}
#endif