mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Support loading FontFaces constructed with binary data
This commit is contained in:
parent
452ffa56dc
commit
60b3436ea3
Notes:
sideshowbarker
2024-07-18 05:01:22 +09:00
Author: https://github.com/ADKaster
Commit: 60b3436ea3
Pull-request: https://github.com/SerenityOS/serenity/pull/24319
8 changed files with 245 additions and 13 deletions
42
Tests/LibWeb/Text/input/css/FontFace-binary-data.html
Normal file
42
Tests/LibWeb/Text/input/css/FontFace-binary-data.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(async (done) => {
|
||||
const badFace = new FontFace("My Cool Font", new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]));
|
||||
|
||||
await badFace.loaded.then(() => {
|
||||
println("FAILED");
|
||||
},
|
||||
() => {
|
||||
println(`badFace.status: ${badFace.status}`); // "error"
|
||||
println(`badFace.family: ${badFace.family}`); // "My Cool Font"
|
||||
});
|
||||
|
||||
const zeroBytesFace = new FontFace("Empty Font", new ArrayBuffer(0));
|
||||
await zeroBytesFace.loaded.then(() => {
|
||||
println("FAILED");
|
||||
},
|
||||
() => {
|
||||
println(`zeroBytesFace.status: ${zeroBytesFace.status}`); // "error"
|
||||
println(`zeroBytesFace.family: ${zeroBytesFace.family}`); // "Empty Font"
|
||||
});
|
||||
|
||||
const fontData = await fetch("../../../Ref/assets/HashSans.woff").then(
|
||||
response => response.arrayBuffer(),
|
||||
(reason) => {
|
||||
println(`FAILED to fetch font from local file ${reason}`);
|
||||
return new ArrayBuffer(0);
|
||||
});
|
||||
|
||||
const hashSans = new FontFace("Hash Sans", fontData);
|
||||
await hashSans.loaded.then(() => {
|
||||
println(`face.status: ${hashSans.status}`); // "loaded"
|
||||
println(`face.family: ${hashSans.family}`); // "Hash Sans"
|
||||
},
|
||||
() => {
|
||||
println("FAILED");
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue