fs2port/port/include/font.h
2026-05-14 10:03:23 -05:00

25 lines
862 B
C

// 5x7 ASCII bitmap font for HUD text. Only the printable subset
// $20..$5F is encoded; lower-case letters fall back to upper-case.
#ifndef FONT_H
#define FONT_H
#include <stdint.h>
#include "framebuffer.h"
#include "palette.h"
#define FONT_WIDTH 5
#define FONT_HEIGHT 7
// Draw a single character at (x, y). Top-left of glyph at (x, y).
// Returns the X advance (FONT_WIDTH + 1).
int16_t fontDrawChar(FramebufferT *fb, int16_t x, int16_t y, char ch, ColorE color);
// Draw a NUL-terminated string. Returns the X advance.
int16_t fontDrawString(FramebufferT *fb, int16_t x, int16_t y, const char *s, ColorE color);
// Draw `s` horizontally centred around screen column `cx`, with the
// top-left of the glyph row at `y`. Returns the X advance.
int16_t fontDrawStringCentered(FramebufferT *fb, int16_t cx, int16_t y, const char *s, ColorE color);
#endif