mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
LibWeb: Implement FontFaceSet.check()
This returns true if the given text can be rendered with the fonts in the set that are fully loaded.
This commit is contained in:
committed by
Sam Atkins
parent
14a0f00400
commit
657060ccc2
Notes:
github-actions[bot]
2026-03-27 15:30:12 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/657060ccc26 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8644 Reviewed-by: https://github.com/AtkinsSJ ✅
30
Tests/LibWeb/Text/input/css/FontFaceSet-check.html
Normal file
30
Tests/LibWeb/Text/input/css/FontFaceSet-check.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
promiseTest(async () => {
|
||||
const fontFaceSet = document.fonts;
|
||||
|
||||
try {
|
||||
fontFaceSet.check("invalid");
|
||||
println("Check invalid font: FAIL");
|
||||
} catch (e) {
|
||||
println(`Check invalid font: ${e.name === "SyntaxError" ? "PASS" : "FAIL"}`);
|
||||
}
|
||||
|
||||
try {
|
||||
fontFaceSet.check("revert");
|
||||
println("Check CSS keyword as font: FAIL");
|
||||
} catch (e) {
|
||||
println(`Check CSS keyword as font: ${e.name === "SyntaxError" ? "PASS" : "FAIL"}`);
|
||||
}
|
||||
|
||||
println(`Check non-existent font: ${fontFaceSet.check("10px NonExistentFont") === true ? "PASS" : "FAIL"}`);
|
||||
|
||||
const fontFace = new FontFace("Hash Sans", "url(../../../Assets/HashSans.woff)");
|
||||
fontFaceSet.add(fontFace);
|
||||
println(`Check unloaded font: ${fontFaceSet.check("1em Hash Sans") === false ? "PASS" : "FAIL"}`);
|
||||
|
||||
await fontFace.load();
|
||||
println(`Check loaded font: ${fontFaceSet.check("1em Hash Sans") === true ? "PASS" : "FAIL"}`);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user