libGumball 0.0.1
C23-Based, libGimbal-powered UI Library
Loading...
Searching...
No Matches
gumball_font.h
Go to the documentation of this file.
1#ifndef GUM_FONT_H
2#define GUM_FONT_H
3
4// View this file's documentation online: https://libgumball.psyops.studio/gumball__font_8h.html
5
6/*! \file
7 * \ref GUM_Font "GUM_Font data structure and hierarchy graph"
8 * \ingroup types
9 *
10 * GUM_Font is the backend-agnostic font type used in libGumball
11 *
12 * \todo
13 * - Replace text alignments with flags for TOP, RIGHT, BOTTOM, LEFT, CENTER
14 *
15 * \author 2025 Agustín Bellagamba
16 * \copyright MIT License
17*/
18#include <gimbal/gimbal_meta.h>
19#include <gumball/types/gumball_vector2.h>
20#include <gumball/ifaces/gumball_iresource.h>
21
22/*! \name Type System
23 * \brief Type UUID and cast operators
24 * @{
25*/
26#define GUM_FONT_TYPE (GBL_TYPEID(GUM_Font)) //!< Returns the GUM_Font Type UUID
27#define GUM_FONT(self) (GBL_CAST(GUM_Font, self)) //!< Casts an instance of a compatible element to a GUM_Font
28#define GUM_FONT_CLASS(klass) (GBL_CLASS_CAST(GUM_Font, klass)) //!< Casts an class of a compatible element to a GUM_Font
29#define GUM_FONT_CLASSOF(self) (GBL_CLASSOF(GUM_Font, self)) //!< Casts an instance of a compatible element to a GUM_Font
30
31#define GUM_TEXT_ALIGNMENT_TYPE (GBL_TYPEID(GUM_TextAlignment)) //!< Returns the GUM_TextAlignment Type UUID
32//! @}
33
34GBL_DECLS_BEGIN
35GBL_FORWARD_DECLARE_STRUCT(GUM_Font);
36
37/*!
38 * \struct GUM_FontClass
39 * \extends GblBoxClass
40 * \implements GUM_IResource
41 * \brief GUM_Font structure
42 *
43 * GUM_FontClass derives from GblBoxClass, adding nothing new.
44 * It also implements the GUM_IResource interface
45*/
46GBL_CLASS_DERIVE_EMPTY(GUM_Font, GblBox, GUM_IResource)
47
48/*!
49 * \struct GUM_Font
50 * \extends GblBox
51 * \brief Backend agnostic font type
52*/
53GBL_INSTANCE_DERIVE_EMPTY(GUM_Font, GblBox)
54
55typedef enum GUM_TextAlignment {
56 GUM_TEXT_ALIGN_CENTER, //!< Align the text to the center of the widget
57 GUM_TEXT_ALIGN_TOP, //!< Align the text to the top of the widget
58 GUM_TEXT_ALIGN_RIGHT, //!< Align the text to the right of the widget
59 GUM_TEXT_ALIGN_BOTTOM, //!< Align the text to the bottom of the widget
60 GUM_TEXT_ALIGN_LEFT //!< Align the text to the left of the widget
61} GUM_TextAlignment;
62
63//! \cond
64GblType GUM_Font_type(void);
65GblType GUM_TextAlignment_type(void);
66//! \endcond
67
68//! Returns the size of the passed text, given the font and font size
69GBL_EXPORT GUM_Vector2 GUM_Font_measureText(GUM_Font *pFont, GblStringRef *pText, uint8_t fontSize) GBL_NOEXCEPT;
70
71GBL_DECLS_END
72
73#endif // GUM_FONT_H