refactor: Moved over to more flexible font loader

This commit is contained in:
WerWolv
2023-11-28 01:55:41 +01:00
parent f6d4d5ab22
commit c02c27b63d
15 changed files with 111 additions and 120334 deletions

View File

@@ -751,4 +751,41 @@ namespace hex {
}
namespace ImHexApi::Fonts {
namespace impl {
std::vector<Font>& getFonts() {
static std::vector<Font> fonts;
return fonts;
}
}
void loadFont(const std::fs::path &path, const std::vector<GlyphRange> &glyphRanges, Offset offset) {
wolv::io::File fontFile(path, wolv::io::File::Mode::Read);
if (!fontFile.isValid()) {
log::error("Failed to load font from file '{}'", wolv::util::toUTF8String(path));
return;
}
impl::getFonts().emplace_back(Font {
wolv::util::toUTF8String(path.filename()),
fontFile.readVector(),
glyphRanges,
offset
});
}
void loadFont(const std::string &name, const std::span<const u8> &data, const std::vector<GlyphRange> &glyphRanges, Offset offset) {
impl::getFonts().emplace_back(Font {
name,
{ data.begin(), data.end() },
glyphRanges,
offset
});
}
}
}