mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
refactor: Moved over to more flexible font loader
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user