diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp index 6c011d4df4..c24c1eb2db 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp @@ -233,9 +233,14 @@ RefPtr BitmapFont::load_from_file(DeprecatedString const& path) ErrorOr> 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> BitmapFont::try_load_from_mapped_file(RefPtr const& mapped_file) +{ + auto font = TRY(load_from_memory((u8 const*)mapped_file->data())); + font->m_mapped_file = mapped_file; return font; } diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.h b/Userland/Libraries/LibGfx/Font/BitmapFont.h index 514b358a7e..e6fd644cf5 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.h +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.h @@ -32,6 +32,7 @@ public: static RefPtr load_from_file(DeprecatedString const& path); static ErrorOr> try_load_from_file(DeprecatedString const& path); + static ErrorOr> try_load_from_mapped_file(RefPtr const&); ErrorOr write_to_file(DeprecatedString const& path); ~BitmapFont();