diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp index bb02007192..3ac9c04ff4 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp @@ -156,14 +156,18 @@ ErrorOr> Font::try_load_from_resource(Core::Resource const& return font; } -ErrorOr> Font::try_load_from_externally_owned_memory(ReadonlyBytes buffer, Options options) +static ErrorOr read_tag(ReadonlyBytes buffer) { FixedMemoryStream stream { buffer }; + return stream.read_value(); +} - auto tag = TRY(stream.read_value()); +ErrorOr> Font::try_load_from_externally_owned_memory(ReadonlyBytes buffer, Options options) +{ + auto tag = TRY(read_tag(buffer)); if (tag == Tag("ttcf")) { // It's a font collection - TRY(stream.seek(0, SeekMode::SetPosition)); + FixedMemoryStream stream { buffer }; auto ttc_header_v1 = TRY(stream.read_in_place()); // FIXME: Check for major_version == 2.