mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibGfx: Add a MappedFile
variant of BitmapFont::try_load_from_file
Let's make it possible to create a BitmapFont directly from a MappedFile instead of a file path.
This commit is contained in:
parent
74d34134ff
commit
0d2ca125b3
Notes:
sideshowbarker
2024-07-17 09:49:33 +09:00
Author: https://github.com/caoimhebyrne
Commit: 0d2ca125b3
Pull-request: https://github.com/SerenityOS/serenity/pull/18029
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/LucasChollet
Reviewed-by: https://github.com/thankyouverycool
2 changed files with 9 additions and 3 deletions
|
@ -233,9 +233,14 @@ RefPtr<BitmapFont> BitmapFont::load_from_file(DeprecatedString const& path)
|
|||
|
||||
ErrorOr<NonnullRefPtr<BitmapFont>> BitmapFont::try_load_from_file(DeprecatedString const& path)
|
||||
{
|
||||
auto file = TRY(Core::MappedFile::map(path));
|
||||
auto font = TRY(load_from_memory((u8 const*)file->data()));
|
||||
font->m_mapped_file = file;
|
||||
auto mapped_file = TRY(Core::MappedFile::map(path));
|
||||
return try_load_from_mapped_file(move(mapped_file));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<BitmapFont>> BitmapFont::try_load_from_mapped_file(RefPtr<Core::MappedFile> const& mapped_file)
|
||||
{
|
||||
auto font = TRY(load_from_memory((u8 const*)mapped_file->data()));
|
||||
font->m_mapped_file = mapped_file;
|
||||
return font;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue