Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
font.h
Go to the documentation of this file.
1
43#ifndef _FONT_H_
44#define _FONT_H_
45
46#include <stdint.h>
47#include <stdbool.h>
48
49#include "palette.h"
50
55typedef struct
56{
57 uint8_t width;
58 uint8_t* bitmap;
59} font_ch_t;
60
65typedef struct
66{
67 uint8_t height;
68 font_ch_t chars['~' - ' ' + 2];
69} font_t;
70
71void drawChar(paletteColor_t color, int h, const font_ch_t* ch, int16_t xOff, int16_t yOff);
72int16_t drawText(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff);
73void drawCharBounds(paletteColor_t color, int h, const font_ch_t* ch, int16_t xOff, int16_t yOff, int16_t xMin,
74 int16_t yMin, int16_t xMax, int16_t yMax);
75int16_t drawTextBounds(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff,
76 int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax);
77
78const char* drawTextWordWrap(const font_t* font, paletteColor_t color, const char* text, int16_t* xOff, int16_t* yOff,
79 int16_t xMax, int16_t yMax);
80const char* drawTextWordWrapFixed(const font_t* font, paletteColor_t color, const char* text, int16_t xStart,
81 int16_t yStart, int16_t* xOff, int16_t* yOff, int16_t xMax, int16_t yMax);
82uint16_t textWidth(const font_t* font, const char* text);
83uint16_t textWordWrapHeight(const font_t* font, const char* text, int16_t width, int16_t maxHeight);
84
85void makeOutlineFont(font_t* srcFont, font_t* dstFont, bool spiRam);
86int16_t drawTextMarquee(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff,
87 int16_t xMax, int32_t* timer);
88bool drawTextEllipsize(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff,
89 int16_t maxW, bool center);
90
91int16_t drawTextMulticolored(const font_t* font, const char* text, int16_t xOff, int16_t yOff,
92 const paletteColor_t* colors, uint32_t colorCount, uint32_t segmentCount);
93
94#endif
uint8_t width
The width of this character.
Definition font.h:57
uint8_t * bitmap
This character's bitmap data.
Definition font.h:58
int16_t drawText(const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff)
Draw text to a display with the given color and font.
Definition font.c:214
int16_t drawTextMarquee(const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff, int16_t xMax, int32_t *timer)
Draw text to the display with a marquee effect.
Definition font.c:523
void drawChar(paletteColor_t color, int h, const font_ch_t *ch, int16_t xOff, int16_t yOff)
Draw a single character from a font to a display.
Definition font.c:160
uint16_t textWordWrapHeight(const font_t *font, const char *text, int16_t width, int16_t maxHeight)
Return the height of a block of word wrapped text.
Definition font.c:398
void drawCharBounds(paletteColor_t color, int h, const font_ch_t *ch, int16_t xOff, int16_t yOff, int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax)
Draw a single character from a font to a display.
Definition font.c:47
const char * drawTextWordWrap(const font_t *font, paletteColor_t color, const char *text, int16_t *xOff, int16_t *yOff, int16_t xMax, int16_t yMax)
Draws text, breaking on word boundaries, until the given bounds are filled or all text is drawn.
Definition font.c:377
bool drawTextEllipsize(const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff, int16_t maxW, bool center)
Draw text to the display that fits within a given length, replacing any overflowing text with "....
Definition font.c:563
void makeOutlineFont(font_t *srcFont, font_t *dstFont, bool spiRam)
Create the outline of a font as a separate font.
Definition font.c:459
const char * drawTextWordWrapFixed(const font_t *font, paletteColor_t color, const char *text, int16_t xStart, int16_t yStart, int16_t *xOff, int16_t *yOff, int16_t xMax, int16_t yMax)
Definition font.c:383
uint8_t height
The height of this font. All chars have the same height.
Definition font.h:67
uint16_t textWidth(const font_t *font, const char *text)
Return the pixel width of some text in a given font.
Definition font.c:226
int16_t drawTextBounds(const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff, int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax)
Draw text to a display with the given color and font.
Definition font.c:179
int16_t drawTextMulticolored(const font_t *font, const char *text, int16_t xOff, int16_t yOff, const paletteColor_t *colors, uint32_t colorCount, uint32_t segmentCount)
Draws text divided into any number of colored segments.
Definition font.c:608
A character used in a font_t. Each character is a bitmap with the same height as the other characters...
Definition font.h:56
A font is a collection of font_ch_t for all ASCII characters. Each character has the same height and ...
Definition font.h:66
paletteColor_t
All 216 possible colors, named like cRGB.
Definition palette.h:23