mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:37:35 +00:00
LibTTF: Add option to load font from a byte buffer
This commit is contained in:
parent
84c2be604a
commit
ad243ef3aa
2 changed files with 7 additions and 1 deletions
|
@ -208,6 +208,11 @@ RefPtr<Font> Font::load_from_file(const StringView& path, unsigned index)
|
|||
return nullptr;
|
||||
}
|
||||
auto buffer = file->read_all();
|
||||
return load_from_memory(buffer, index);
|
||||
}
|
||||
|
||||
RefPtr<Font> Font::load_from_memory(ByteBuffer& buffer, unsigned index)
|
||||
{
|
||||
if (buffer.size() < 4) {
|
||||
dbg() << "Font file too small";
|
||||
return nullptr;
|
||||
|
@ -227,7 +232,7 @@ RefPtr<Font> Font::load_from_file(const StringView& path, unsigned index)
|
|||
return nullptr;
|
||||
}
|
||||
if (tag != 0x00010000) {
|
||||
dbg() << "Not a valid font";
|
||||
dbg() << "Not a valid font";
|
||||
return nullptr;
|
||||
}
|
||||
return load_from_offset(move(buffer), 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue