Kernel: Make some basic bitmap font parsing code

This commit is contained in:
Bananymous
2023-02-22 22:28:12 +02:00
parent a3e9e7d125
commit 0e668738dc
2 changed files with 271 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#pragma once
#include <BAN/HashMap.h>
#include <BAN/StringView.h>
namespace Kernel
{
class Font
{
public:
static BAN::ErrorOr<Font> load(BAN::StringView);
uint32_t width() const { return m_width; }
uint32_t height() const { return m_height; }
uint32_t pitch() const { return m_pitch; }
bool has_glyph(uint16_t) const;
const uint8_t* glyph(uint16_t) const;
private:
static BAN::ErrorOr<Font> parse_psf1(const BAN::Vector<uint8_t>&);
static BAN::ErrorOr<Font> parse_psf2(const BAN::Vector<uint8_t>&);
private:
BAN::HashMap<uint16_t, uint32_t> m_glyph_offsets;
BAN::Vector<uint8_t> m_glyph_data;
uint32_t m_width = 0;
uint32_t m_height = 0;
uint32_t m_pitch = 0;
};
}