mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Handle format(woff-variations) etc in @font-face src values
"format(woff-variations)" and pals are supposed to expand like so: "format(woff) tech(variations)". However, since we don't support tech() yet, this patch just adds a small hack where we still treat "woff-variations" as "woff" so that fonts load and get used, even if we don't make use of the variations yet.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
2d064116ab
commit
59e2416b61
Notes:
github-actions[bot]
2025-05-23 14:37:58 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/59e2416b610 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4856 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/gmta ✅
@@ -3874,6 +3874,7 @@ RefPtr<StringStyleValue const> Parser::parse_opentype_tag_value(TokenStream<Comp
|
||||
return string_value;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-fonts/#font-face-src-parsing
|
||||
RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
// <font-src> = <url> [ format(<font-format>)]? [ tech( <font-tech>#)]? | local(<family-name>)
|
||||
@@ -3919,6 +3920,12 @@ RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<C
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// FIXME: Some of the formats support an optional "-variations" suffix that's really supposed to map to tech(variations).
|
||||
// Once we support tech(*), we should ensure this propagates correctly.
|
||||
if (format_name.is_one_of("woff2-variations"sv, "woff-variations"sv, "truetype-variations"sv, "opentype-variations"sv)) {
|
||||
format_name = MUST(format_name.to_string().substring_from_byte_offset(0, format_name.bytes().size() - strlen("-variations")));
|
||||
}
|
||||
|
||||
if (!font_format_is_supported(format_name)) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: font source format({}) not supported; skipping.", format_name);
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user