TinyGPU
Loading...
Searching...
No Matches
IFont.h
Go to the documentation of this file.
1#pragma once
2#include <stddef.h>
3#include <stdint.h>
4#include "RGB565.h"
5
6namespace tinygpu {
7// Forward declaration to avoid circular dependency
8template <typename RGB_T> class ISurface;
9
10/**
11 * @brief Font rendering interface for TinyGPU-compatible framebuffers.
12 *
13 * @tparam RGB_T The pixel color type. Can be RGB565, RGB666, RGB888, etc.
14 *
15 * Implementations render text onto an ISurface target using their own glyph
16 * storage, layout, and scaling behavior.
17 */
18template <typename RGB_T = RGB565>
19class IFont {
20 public:
21 /// Destroys the font interface.
22 virtual ~IFont() = default;
23
24 /// Draws a text string onto a framebuffer target.
25 virtual void drawText(ISurface<RGB_T>& target, int16_t x, int16_t y,
26 const char* text, RGB_T foreground, RGB_T background,
27 bool opaque = false, uint8_t scale = 1,
28 uint8_t spacing = 1, uint8_t lineSpacing = 1) const = 0;
29
30 /// Returns the width of the longest text line in pixels.
31 virtual size_t measureTextWidth(const char* text, uint8_t scale = 1,
32 uint8_t spacing = 1) const = 0;
33
34 /// Returns the total text height in pixels.
35 virtual size_t measureTextHeight(const char* text, uint8_t scale = 1,
36 uint8_t lineSpacing = 1) const = 0;
37
38 /// Returns the scaled glyph height in pixels.
39 virtual size_t getHeight(uint8_t scale) const = 0;
40};
41
42} // namespace tinygpu
Font rendering interface for TinyGPU-compatible framebuffers.
Definition: IFont.h:19
virtual void drawText(ISurface< RGB_T > &target, int16_t x, int16_t y, const char *text, RGB_T foreground, RGB_T background, bool opaque=false, uint8_t scale=1, uint8_t spacing=1, uint8_t lineSpacing=1) const =0
Draws a text string onto a framebuffer target.
virtual size_t measureTextHeight(const char *text, uint8_t scale=1, uint8_t lineSpacing=1) const =0
Returns the total text height in pixels.
virtual ~IFont()=default
Destroys the font interface.
virtual size_t measureTextWidth(const char *text, uint8_t scale=1, uint8_t spacing=1) const =0
Returns the width of the longest text line in pixels.
virtual size_t getHeight(uint8_t scale) const =0
Returns the scaled glyph height in pixels.
RGB color stored in 16-bit RGB565 format.
Definition: RGB565.h:13
Definition: AVIWriter.h:9