From 43f465756674bcb1958d66b24c0cbd4bde853c8e Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 20 Mar 2023 13:35:54 +0200 Subject: [PATCH] Kernel: Font parsing uses Spans now --- kernel/include/kernel/Font.h | 5 +++-- kernel/kernel/Font.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/kernel/include/kernel/Font.h b/kernel/include/kernel/Font.h index 1a3ab962..89470c77 100644 --- a/kernel/include/kernel/Font.h +++ b/kernel/include/kernel/Font.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include namespace Kernel @@ -20,8 +21,8 @@ namespace Kernel const uint8_t* glyph(uint16_t) const; private: - static BAN::ErrorOr parse_psf1(const BAN::Vector&); - static BAN::ErrorOr parse_psf2(const BAN::Vector&); + static BAN::ErrorOr parse_psf1(const BAN::Span); + static BAN::ErrorOr parse_psf2(const BAN::Span); private: BAN::HashMap m_glyph_offsets; diff --git a/kernel/kernel/Font.cpp b/kernel/kernel/Font.cpp index 88074e29..9f79cea5 100644 --- a/kernel/kernel/Font.cpp +++ b/kernel/kernel/Font.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include @@ -23,7 +23,7 @@ namespace Kernel BAN::Vector font_data; TRY(font_data.resize(font_data_size)); memcpy(font_data.data(), &_binary_font_prefs_psf_start, font_data_size); - return parse_psf1(font_data); + return parse_psf1(font_data.span()); } BAN::ErrorOr Font::load(BAN::StringView path) @@ -40,16 +40,16 @@ namespace Kernel return BAN::Error::from_c_string("Font file is too small"); if (file_data[0] == 0x36 && file_data[1] == 0x04) - return TRY(parse_psf1(file_data)); + return TRY(parse_psf1(file_data.span())); if (file_data[0] == 0x72 && file_data[1] == 0xB5 && file_data[2] == 0x4A && file_data[3] == 0x86) - return TRY(parse_psf2(file_data)); + return TRY(parse_psf2(file_data.span())); return BAN::Error::from_c_string("Unsupported font format"); } - BAN::ErrorOr Font::parse_psf1(const BAN::Vector& font_data) + BAN::ErrorOr Font::parse_psf1(const BAN::Span font_data) { if (font_data.size() < 4) return BAN::Error::from_c_string("Font file is too small"); @@ -135,7 +135,7 @@ namespace Kernel return result; } - BAN::ErrorOr Font::parse_psf2(const BAN::Vector& font_data) + BAN::ErrorOr Font::parse_psf2(const BAN::Span font_data) { struct PSF2Header {