libui: Document ui::Font
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
2ddec76061
commit
2ffdc6f539
@ -8,29 +8,85 @@
|
|||||||
|
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief A class holding PSF font data, used for direct rendering of glyphs into a canvas.
|
||||||
|
*/
|
||||||
class Font : public Shareable
|
class Font : public Shareable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief An enum used to select a font weight when loading a font.
|
||||||
|
*/
|
||||||
enum FontWeight
|
enum FontWeight
|
||||||
{
|
{
|
||||||
Regular,
|
Regular,
|
||||||
Bold,
|
Bold,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Load a Font object from a font file.
|
||||||
|
*
|
||||||
|
* @param path The full path to the font file.
|
||||||
|
* @return Result<SharedPtr<Font>> An error, or the loaded Font object.
|
||||||
|
*/
|
||||||
static Result<SharedPtr<Font>> load(const os::Path& path);
|
static Result<SharedPtr<Font>> load(const os::Path& path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Load a system font by name.
|
||||||
|
*
|
||||||
|
* @param name The name of the font to load (the default system font is "Tamsyn").
|
||||||
|
* @param weight The weight of the font (regular or bold).
|
||||||
|
* @return Result<SharedPtr<Font>> An error, or the loaded Font object.
|
||||||
|
*/
|
||||||
static Result<SharedPtr<Font>> load_builtin(StringView name, FontWeight weight);
|
static Result<SharedPtr<Font>> load_builtin(StringView name, FontWeight weight);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a pointer to the system's default font.
|
||||||
|
*
|
||||||
|
* @return SharedPtr<Font> The default font.
|
||||||
|
*/
|
||||||
static SharedPtr<Font> default_font();
|
static SharedPtr<Font> default_font();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a pointer to the system's default bold font.
|
||||||
|
*
|
||||||
|
* @return SharedPtr<Font> The default bold font.
|
||||||
|
*/
|
||||||
static SharedPtr<Font> default_bold_font();
|
static SharedPtr<Font> default_bold_font();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Render a single Unicode code point into a canvas, using this font's glyphs.
|
||||||
|
*
|
||||||
|
* @param codepoint The code point to render.
|
||||||
|
* @param color The color to draw the code point in.
|
||||||
|
* @param canvas The canvas to use.
|
||||||
|
*/
|
||||||
void render(wchar_t codepoint, ui::Color color, ui::Canvas& canvas);
|
void render(wchar_t codepoint, ui::Color color, ui::Canvas& canvas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Render a Unicode text string into a canvas, using this font's glyphs.
|
||||||
|
*
|
||||||
|
* @param text The string to render (must be null-terminated).
|
||||||
|
* @param color The color to draw the code point in.
|
||||||
|
* @param canvas The canvas to use.
|
||||||
|
*/
|
||||||
void render(const wchar_t* text, ui::Color color, ui::Canvas& canvas);
|
void render(const wchar_t* text, ui::Color color, ui::Canvas& canvas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the width of this font's glyphs.
|
||||||
|
*
|
||||||
|
* @return int The width.
|
||||||
|
*/
|
||||||
int width() const
|
int width() const
|
||||||
{
|
{
|
||||||
return m_psf_header.width;
|
return m_psf_header.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the height of this font's glyphs.
|
||||||
|
*
|
||||||
|
* @return int The height.
|
||||||
|
*/
|
||||||
int height() const
|
int height() const
|
||||||
{
|
{
|
||||||
return m_psf_header.height;
|
return m_psf_header.height;
|
||||||
|
Loading…
Reference in New Issue
Block a user