1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 04:17:34 +00:00

LibWeb: Hook up WOFF2 decompression in the StyleComputer

With this, we now support WOFF2 fonts on the web :^)
This commit is contained in:
Andreas Kling 2023-08-12 15:23:38 +02:00
parent 6076580a47
commit 3406d500a4

View file

@ -21,6 +21,7 @@
#include <LibGfx/Font/ScaledFont.h>
#include <LibGfx/Font/VectorFont.h>
#include <LibGfx/Font/WOFF/Font.h>
#include <LibGfx/Font/WOFF2/Font.h>
#include <LibWeb/CSS/CSSFontFaceRule.h>
#include <LibWeb/CSS/CSSImportRule.h>
#include <LibWeb/CSS/CSSStyleRule.h>
@ -158,13 +159,25 @@ private:
return TRY(OpenType::Font::try_load_from_externally_owned_memory(resource()->encoded_data()));
if (mime_type == "font/woff"sv || mime_type == "application/font-woff"sv)
return TRY(WOFF::Font::try_load_from_externally_owned_memory(resource()->encoded_data()));
if (mime_type == "font/woff2"sv || mime_type == "application/font-woff2"sv) {
auto woff2 = WOFF2::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
if (woff2.is_error()) {
dbgln("WOFF2 error: {}", woff2.error());
return woff2.release_error();
}
return woff2.release_value();
}
auto ttf = OpenType::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
if (!ttf.is_error())
return ttf.release_value();
auto woff = WOFF::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
if (!woff.is_error())
return woff.release_value();
return ttf.release_error();
auto woff2 = WOFF2::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
if (!woff2.is_error())
return woff2.release_value();
dbgln("WOFF2 error: {}", woff2.error());
return woff2.release_error();
}
StyleComputer& m_style_computer;