ladybird/Libraries/LibWeb/CSS/FontLoading.h
Andreas Kling e1d35d7da9 LibWeb+LibGfx: Decompress WOFF2 fonts off the main thread
Add an off-thread preparation step for downloaded vector fonts so
WOFF2 resources can be decompressed before LibWeb tries to create a
typeface from them. This avoids doing the conversion work on the main
thread during @font-face loading.

Expose raw WOFF2-to-TTF conversion from LibGfx's WOFF2 loader and use
that from the new preparation path. Keeping the libwoff2 integration
in LibGfx preserves the layering between LibWeb and the third-party
decoder while still letting LibWeb schedule the work off-thread.
2026-04-18 23:46:20 +02:00

26 lines
795 B
C++

/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/Optional.h>
#include <LibGfx/Font/Typeface.h>
namespace Web::CSS {
struct PreparedVectorFontData {
ByteBuffer data;
Optional<ByteString> mime_type_essence;
};
bool requires_off_thread_vector_font_preparation(ByteBuffer const&, Optional<ByteString> const& mime_type_essence = {});
ErrorOr<NonnullRefPtr<Gfx::Typeface const>> try_load_vector_font(ByteBuffer const&, Optional<ByteString> const& mime_type_essence = {});
void prepare_vector_font_data_off_thread(ByteBuffer, Function<void(ErrorOr<PreparedVectorFontData>)>&&, Optional<ByteString> mime_type_essence = {});
}