mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00: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:
parent
2d064116ab
commit
59e2416b61
Notes:
github-actions[bot]
2025-05-23 14:37:58 +00:00
Author: https://github.com/awesomekling
Commit: 59e2416b61
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4856
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta ✅
2 changed files with 12 additions and 6 deletions
|
@ -3874,6 +3874,7 @@ RefPtr<StringStyleValue const> Parser::parse_opentype_tag_value(TokenStream<Comp
|
||||||
return string_value;
|
return string_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-fonts/#font-face-src-parsing
|
||||||
RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<ComponentValue>& tokens)
|
RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
// <font-src> = <url> [ format(<font-format>)]? [ tech( <font-tech>#)]? | local(<family-name>)
|
// <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;
|
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)) {
|
if (!font_format_is_supported(format_name)) {
|
||||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: font source format({}) not supported; skipping.", format_name);
|
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: font source format({}) not supported; skipping.", format_name);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -2,16 +2,15 @@ Harness status: OK
|
||||||
|
|
||||||
Found 48 tests
|
Found 48 tests
|
||||||
|
|
||||||
44 Pass
|
48 Pass
|
||||||
4 Fail
|
|
||||||
Pass Load Ahem with format woff
|
Pass Load Ahem with format woff
|
||||||
Pass Load Ahem with format truetype
|
Pass Load Ahem with format truetype
|
||||||
Pass Load Ahem with format opentype
|
Pass Load Ahem with format opentype
|
||||||
Pass Load Ahem with format woff2
|
Pass Load Ahem with format woff2
|
||||||
Fail Load Ahem with format woff-variations
|
Pass Load Ahem with format woff-variations
|
||||||
Fail Load Ahem with format truetype-variations
|
Pass Load Ahem with format truetype-variations
|
||||||
Fail Load Ahem with format opentype-variations
|
Pass Load Ahem with format opentype-variations
|
||||||
Fail Load Ahem with format woff2-variations
|
Pass Load Ahem with format woff2-variations
|
||||||
Pass Do not load Ahem with format xyzwoff
|
Pass Do not load Ahem with format xyzwoff
|
||||||
Pass Do not load Ahem with format xyztruetype
|
Pass Do not load Ahem with format xyztruetype
|
||||||
Pass Do not load Ahem with format xyzopentype
|
Pass Do not load Ahem with format xyzopentype
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue