mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibGfx/OpenType: Extract read_tag() function
This commit is contained in:
parent
93038f6f24
commit
86203974f5
1 changed files with 7 additions and 3 deletions
|
@ -156,14 +156,18 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_resource(Core::Resource const&
|
|||
return font;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_externally_owned_memory(ReadonlyBytes buffer, Options options)
|
||||
static ErrorOr<Tag> read_tag(ReadonlyBytes buffer)
|
||||
{
|
||||
FixedMemoryStream stream { buffer };
|
||||
return stream.read_value<Tag>();
|
||||
}
|
||||
|
||||
auto tag = TRY(stream.read_value<Tag>());
|
||||
ErrorOr<NonnullRefPtr<Font>> 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<TTCHeaderV1>());
|
||||
// FIXME: Check for major_version == 2.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue