LibGfx: Use the woff2 library to decode WOFF2 font files

This saves us the trouble of maintaining our own implementation,
and instantly brings us to full WOFF2 feature parity with others.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
This commit is contained in:
Andreas Kling 2024-06-06 11:10:01 +02:00 committed by Andreas Kling
parent 9be5867eb2
commit 28d4e326f8
6 changed files with 63 additions and 1018 deletions

11
Meta/CMake/woff2.cmake Normal file
View File

@ -0,0 +1,11 @@
find_package(PkgConfig)
pkg_check_modules(WOFF2 REQUIRED IMPORTED_TARGET libwoff2dec)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
WOFF2
REQUIRED_VARS
WOFF2_INCLUDE_DIRS
WOFF2_LIBRARY_DIRS
WOFF2_LIBRARIES
)

View File

@ -1,3 +1,5 @@
include(woff2)
set(SOURCES
AffineTransform.cpp
AntiAliasingPainter.cpp
@ -89,6 +91,11 @@ set(SOURCES
serenity_lib(LibGfx gfx)
target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL)
# Third-party
target_include_directories(LibGfx PRIVATE ${WOFF2_INCLUDE_DIRS})
target_link_libraries(LibGfx PRIVATE ${WOFF2_LIBRARIES})
target_link_directories(LibGfx PRIVATE ${WOFF2_LIBRARY_DIRS})
set(generated_sources TIFFMetadata.h TIFFTagHandler.cpp)
list(TRANSFORM generated_sources PREPEND "ImageFormats/")

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,6 @@ class Font : public Gfx::VectorFont {
AK_MAKE_NONCOPYABLE(Font);
public:
static ErrorOr<NonnullRefPtr<Font>> try_load_from_resource(Core::Resource const&);
static ErrorOr<NonnullRefPtr<Font>> try_load_from_externally_owned_memory(SeekableStream&);
static ErrorOr<NonnullRefPtr<Font>> try_load_from_externally_owned_memory(ReadonlyBytes);
virtual Gfx::ScaledFontMetrics metrics(float x_scale, float y_scale) const override { return m_input_font->metrics(x_scale, y_scale); }

View File

@ -1,9 +1,4 @@
{
"default-registry": {
"kind": "git",
"baseline": "01f602195983451bc83e72f4214af2cbc495aa94",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",

View File

@ -1,11 +1,17 @@
{
"builtin-baseline": "01f602195983451bc83e72f4214af2cbc495aa94",
"dependencies": [
"sqlite3"
"sqlite3",
"woff2"
],
"overrides": [
{
"name": "sqlite3",
"version": "3.45.3"
},
{
"name": "woff2",
"version": "1.0.2#4"
}
]
}