mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibWeb: Always log debug message about failure to parse CSS fonts
It's always good to know when and why a CSS font fails to parse, so that we can file issues about missing functionality.
This commit is contained in:
parent
877ad07915
commit
c0ea8825b5
|
@ -119,8 +119,11 @@ public:
|
|||
virtual void resource_did_load() override
|
||||
{
|
||||
auto result = try_load_font();
|
||||
if (result.is_error())
|
||||
return start_loading_next_url();
|
||||
if (result.is_error()) {
|
||||
dbgln("Failed to parse font: {}", result.error());
|
||||
start_loading_next_url();
|
||||
return;
|
||||
}
|
||||
m_vector_font = result.release_value();
|
||||
m_style_computer.did_load_font(m_family_name);
|
||||
}
|
||||
|
@ -160,19 +163,15 @@ private:
|
|||
ErrorOr<NonnullRefPtr<Gfx::VectorFont>> try_load_font()
|
||||
{
|
||||
// FIXME: This could maybe use the format() provided in @font-face as well, since often the mime type is just application/octet-stream and we have to try every format
|
||||
auto mime_type = resource()->mime_type();
|
||||
auto const& mime_type = resource()->mime_type();
|
||||
if (mime_type == "font/ttf"sv || mime_type == "application/x-font-ttf"sv)
|
||||
return TRY(OpenType::Font::try_load_from_externally_owned_memory(resource()->encoded_data()));
|
||||
return 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();
|
||||
}
|
||||
return WOFF::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
if (mime_type == "font/woff2"sv || mime_type == "application/font-woff2"sv)
|
||||
return WOFF2::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
|
||||
// We don't have the luxury of knowing the MIME type, so we have to try all formats.
|
||||
auto ttf = OpenType::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
if (!ttf.is_error())
|
||||
return ttf.release_value();
|
||||
|
@ -182,7 +181,7 @@ private:
|
|||
auto woff2 = WOFF2::Font::try_load_from_externally_owned_memory(resource()->encoded_data());
|
||||
if (!woff2.is_error())
|
||||
return woff2.release_value();
|
||||
return woff2.release_error();
|
||||
return Error::from_string_literal("Automatic format detection failed");
|
||||
}
|
||||
|
||||
StyleComputer& m_style_computer;
|
||||
|
|
Loading…
Reference in a new issue