2022-03-29 15:13:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
2023-03-10 20:36:21 +00:00
|
|
|
#include <string_view>
|
2022-03-29 15:13:14 +01:00
|
|
|
#include <cstdint>
|
2022-04-01 15:21:08 +01:00
|
|
|
#include "common/unicode_sorta.hpp"
|
2022-03-29 15:13:14 +01:00
|
|
|
|
|
|
|
namespace bitmap {
|
2022-04-01 15:21:08 +01:00
|
|
|
const int base_chars = 96; // 96 printable ASCII chars
|
|
|
|
const int extra_chars = 9; // Extra chars we've rempped that aren't just an ASCII char plus an accent
|
|
|
|
|
2022-03-29 15:13:14 +01:00
|
|
|
struct font_t {
|
|
|
|
const uint8_t height;
|
|
|
|
const uint8_t max_width;
|
2022-04-01 15:21:08 +01:00
|
|
|
const uint8_t widths[base_chars + extra_chars];
|
2022-03-29 15:13:14 +01:00
|
|
|
const uint8_t data[];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::function<void(int32_t x, int32_t y, int32_t w, int32_t h)> rect_func;
|
|
|
|
|
2023-05-15 10:17:44 +01:00
|
|
|
int32_t measure_character(const font_t *font, const char c, const uint8_t scale, unicode_sorta::codepage_t codepage = unicode_sorta::PAGE_195, bool fixed_width = false);
|
|
|
|
int32_t measure_text(const font_t *font, const std::string_view &t, const uint8_t scale = 2, const uint8_t letter_spacing = 1, bool fixed_width = false);
|
2022-03-29 17:34:42 +01:00
|
|
|
|
2023-07-31 17:21:44 +01:00
|
|
|
void character(const font_t *font, rect_func rectangle, const char c, const int32_t x, const int32_t y, const uint8_t scale = 2, int32_t rotation = 0, unicode_sorta::codepage_t codepage = unicode_sorta::PAGE_195);
|
|
|
|
void text(const font_t *font, rect_func rectangle, const std::string_view &t, const int32_t x, const int32_t y, const int32_t wrap, const uint8_t scale = 2, const uint8_t letter_spacing = 1, bool fixed_width = false, int32_t rotation = 0);
|
2022-03-29 15:13:14 +01:00
|
|
|
}
|