mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb/CSS: Add functions that report font format/technology support
Both `@supports` and `@font-face` need this. There may be some automatic way of querying whether our renderer supports these, but I couldn't figure it out, so here's a basic hard-coded list. I think the font-tech list has false negatives, as I don't know enough about fonts to determine what we support accurately.
This commit is contained in:
Notes:
github-actions[bot]
2025-03-17 10:01:24 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/adfe8a9dcbb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3941
@@ -398,4 +398,57 @@ GC::Ref<WebIDL::Promise> FontFace::load()
|
||||
return font_face.loaded();
|
||||
}
|
||||
|
||||
bool font_format_is_supported(FlyString const& name)
|
||||
{
|
||||
// https://drafts.csswg.org/css-fonts-4/#font-format-definitions
|
||||
// FIXME: Determine this automatically somehow?
|
||||
if (name.equals_ignoring_ascii_case("collection"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("embedded-opentype"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("opentype"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("svg"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("truetype"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("woff"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("woff2"sv))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool font_tech_is_supported(FlyString const& name)
|
||||
{
|
||||
// https://drafts.csswg.org/css-fonts-4/#font-tech-definitions
|
||||
// FIXME: Determine this automatically somehow?
|
||||
if (name.equals_ignoring_ascii_case("features-opentype"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("features-aat"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("features-graphite"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("variations"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("color-colrv0"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("color-colrv1"sv))
|
||||
return true;
|
||||
if (name.equals_ignoring_ascii_case("color-svg"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("color-sbix"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("color-cbdt"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("palettes"sv))
|
||||
return false;
|
||||
if (name.equals_ignoring_ascii_case("incremental"sv))
|
||||
return false;
|
||||
// https://drafts.csswg.org/css-fonts-5/#font-tech-definitions
|
||||
if (name.equals_ignoring_ascii_case("avar2"sv))
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user