mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-18 06:00:27 +00:00
LibWeb: Implement FontFace.load() for url() based font sources
This commit is contained in:
parent
b7526a39b0
commit
28f728dfdb
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/ADKaster
Commit: 28f728dfdb
Pull-request: https://github.com/SerenityOS/serenity/pull/24339
4 changed files with 123 additions and 6 deletions
30
Tests/LibWeb/Text/input/css/FontFace-load-urls.html
Normal file
30
Tests/LibWeb/Text/input/css/FontFace-load-urls.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(async (done) => {
|
||||
// FIXME: Surely there's a better way to get this font URL
|
||||
let fontUrl = new URL(location.href);
|
||||
fontUrl.search = "";
|
||||
fontUrl += "/../../../../Ref/assets/HashSans.woff";
|
||||
|
||||
const hashSans = new FontFace("Hash Sans", `url(${fontUrl})`);
|
||||
println(`hashSans.family: ${hashSans.family}`);
|
||||
println(`hashSans.status: ${hashSans.status}`);
|
||||
|
||||
await hashSans.load().then(() => {
|
||||
println(`hashSans.status: ${hashSans.status}`);
|
||||
}, () => {
|
||||
println("FAILED");
|
||||
});
|
||||
|
||||
let notExistFont = new FontFace("NotExist", "url(https://example.com/not-exist.woff)");
|
||||
await notExistFont.load().then(() => {
|
||||
println("FAILED");
|
||||
}, (reason) => {
|
||||
println(`font load failed because: ${reason}`);
|
||||
println(`notExistFont.status: ${notExistFont.status}`);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue