mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
LibGfx: Add a helper for constructing a TTF font from temporary bytes
Once we switch from ResourceLoader to Fetch, nobody is going to be holding onto the downloaded data, so we need to make a permanent copy of it.
This commit is contained in:
parent
f76f8dcce1
commit
1967d5bc75
Notes:
github-actions[bot]
2025-05-03 11:03:27 +00:00
Author: https://github.com/AtkinsSJ
Commit: 1967d5bc75
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4536
2 changed files with 8 additions and 0 deletions
|
@ -25,6 +25,13 @@ ErrorOr<NonnullRefPtr<Typeface>> Typeface::try_load_from_font_data(NonnullOwnPtr
|
|||
return typeface;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Typeface>> Typeface::try_load_from_temporary_memory(ReadonlyBytes bytes, int ttc_index)
|
||||
{
|
||||
auto buffer = TRY(ByteBuffer::copy(bytes));
|
||||
auto font_data = FontData::create_from_byte_buffer(move(buffer));
|
||||
return try_load_from_font_data(move(font_data), ttc_index);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Typeface>> Typeface::try_load_from_externally_owned_memory(ReadonlyBytes bytes, int ttc_index)
|
||||
{
|
||||
return TypefaceSkia::load_from_buffer(bytes, ttc_index);
|
||||
|
|
|
@ -38,6 +38,7 @@ class Typeface : public RefCounted<Typeface> {
|
|||
public:
|
||||
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_resource(Core::Resource const&, int ttc_index = 0);
|
||||
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_font_data(NonnullOwnPtr<Gfx::FontData>, int ttc_index = 0);
|
||||
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_temporary_memory(ReadonlyBytes bytes, int ttc_index = 0);
|
||||
static ErrorOr<NonnullRefPtr<Typeface>> try_load_from_externally_owned_memory(ReadonlyBytes bytes, int ttc_index = 0);
|
||||
|
||||
virtual ~Typeface();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue