2023-02-22 22:28:12 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <BAN/HashMap.h>
|
2023-03-20 13:35:54 +02:00
|
|
|
#include <BAN/Span.h>
|
2023-02-22 22:28:12 +02:00
|
|
|
#include <BAN/StringView.h>
|
|
|
|
|
|
|
|
namespace Kernel
|
|
|
|
{
|
|
|
|
|
|
|
|
class Font
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static BAN::ErrorOr<Font> load(BAN::StringView);
|
2023-02-23 01:22:50 +02:00
|
|
|
static BAN::ErrorOr<Font> prefs();
|
2023-02-22 22:28:12 +02:00
|
|
|
|
|
|
|
uint32_t width() const { return m_width; }
|
|
|
|
uint32_t height() const { return m_height; }
|
|
|
|
uint32_t pitch() const { return m_pitch; }
|
|
|
|
|
2023-03-20 14:52:42 +02:00
|
|
|
bool has_glyph(uint32_t) const;
|
|
|
|
const uint8_t* glyph(uint32_t) const;
|
2023-02-22 22:28:12 +02:00
|
|
|
|
|
|
|
private:
|
2023-03-23 14:26:03 +02:00
|
|
|
static BAN::ErrorOr<Font> parse_psf1(BAN::Span<const uint8_t>);
|
|
|
|
static BAN::ErrorOr<Font> parse_psf2(BAN::Span<const uint8_t>);
|
2023-02-22 22:28:12 +02:00
|
|
|
|
|
|
|
private:
|
2023-03-20 14:52:42 +02:00
|
|
|
BAN::HashMap<uint32_t, uint32_t> m_glyph_offsets;
|
2023-02-22 22:28:12 +02:00
|
|
|
BAN::Vector<uint8_t> m_glyph_data;
|
|
|
|
uint32_t m_width = 0;
|
|
|
|
uint32_t m_height = 0;
|
|
|
|
uint32_t m_pitch = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|