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
42
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);
73int16_t drawShinyText(const font_t* font, paletteColor_t outerColor, paletteColor_t middleColor,
74 paletteColor_t innerColor, const char* text, int16_t xOff, int16_t yOff);
75void drawCharBounds(paletteColor_t color, int h, const font_ch_t* ch, int16_t xOff, int16_t yOff, int16_t xMin,
76 int16_t yMin, int16_t xMax, int16_t yMax);
77void drawShinyCharBounds(paletteColor_t outerColor, paletteColor_t middleColor, paletteColor_t innerColor, int h,
78 const font_ch_t* ch, int16_t xOff, int16_t yOff, int16_t xMin, int16_t yMin, int16_t xMax,
79 int16_t yMax);
80int16_t drawTextBounds(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff,
81 int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax);
82int16_t drawShinyTextBounds(const font_t* font, paletteColor_t outerColor, paletteColor_t middleColor,
83 paletteColor_t innerColor, const char* text, int16_t xOff, int16_t yOff, int16_t xMin,
84 int16_t yMin, int16_t xMax, int16_t yMax);
85int16_t drawTextShadow(const font_t* font, paletteColor_t color, paletteColor_t shadowColor, const char* text,
86 int16_t xOff, int16_t yOff);
87
88const char* drawTextWordWrap(const font_t* font, paletteColor_t color, const char* text, int16_t* xOff, int16_t* yOff,
89 int16_t xMax, int16_t yMax);
90const char* drawTextWordWrapFixed(const font_t* font, paletteColor_t color, const char* text, int16_t xStart,
91 int16_t yStart, int16_t* xOff, int16_t* yOff, int16_t xMax, int16_t yMax);
92const char* drawTextWordWrapCentered(const font_t* font, paletteColor_t color, const char* text, int16_t* xOff,
93 int16_t* yOff, int16_t xMax, int16_t yMax);
94uint16_t textWidth(const font_t* font, const char* text);
95uint16_t textWordWrapHeight(const font_t* font, const char* text, int16_t width, int16_t maxHeight);
96
97void makeOutlineFont(font_t* srcFont, font_t* dstFont, bool spiRam);
98int16_t drawTextMarquee(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff,
99 int16_t xMax, int32_t* timer);
100bool drawTextEllipsize(const font_t* font, paletteColor_t color, const char* text, int16_t xOff, int16_t yOff,
101 int16_t maxW, bool center);
102
103int16_t drawTextMulticolored(const font_t* font, const char* text, int16_t xOff, int16_t yOff,
104 const paletteColor_t* colors, uint32_t colorCount, uint32_t segmentCount);
105void setGlobalCharSpacing(int32_t spacing);
106
107#endif
uint8_t width
The width of this character.
Definition font.h:57
font_ch_t chars['~' - ' '+2]
An array of characters, enough space for all printed ASCII chars, and pi.
Definition font.h:68
int16_t drawTextShadow(const font_t *font, paletteColor_t color, paletteColor_t shadowColor, const char *text, int16_t xOff, int16_t yOff)
Draw text to a display with the given color, 1px offset drop shadow, and font.
Definition font.c:195
uint8_t * bitmap
This character's bitmap data.
Definition font.h:58
void drawShinyCharBounds(paletteColor_t outerColor, paletteColor_t middleColor, paletteColor_t innerColor, 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 with a horizontal gradient through the center from a font to a display.
Definition font.c:80
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:213
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:701
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:96
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:576
const char * drawTextWordWrapCentered(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:555
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:59
int16_t drawShinyText(const font_t *font, paletteColor_t outerColor, paletteColor_t middleColor, paletteColor_t innerColor, const char *text, int16_t xOff, int16_t yOff)
Draw text to a display with the given color and font.
Definition font.c:230
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:530
int16_t drawShinyTextBounds(const font_t *font, paletteColor_t outerColor, paletteColor_t middleColor, paletteColor_t innerColor, 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:157
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:739
void makeOutlineFont(font_t *srcFont, font_t *dstFont, bool spiRam)
Create the outline of a font as a separate font.
Definition font.c:637
void setGlobalCharSpacing(int32_t spacing)
Adjust the spacing between characters when drawing words.
Definition font.c:808
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:561
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:244
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:115
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:784
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