mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 17:25:50 +03:00
fix lint
This commit is contained in:
parent
4ae652e5c3
commit
30912dec17
1 changed files with 21 additions and 18 deletions
|
@ -29,31 +29,35 @@ async function isColrFontSupported() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
let context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
let img = new Image();
|
const img = new Image();
|
||||||
let fontCOLR = 'd09GRgABAAAAAAKAAAwAAAAAAowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDT0xSAAACVAAAABYAAAAYAAIAJUNQQUwAAAJsAAAAEgAAABLJAAAQT1MvMgAAAYAAAAA6AAAAYBfxJ0pjbWFwAAABxAAAACcAAAAsAAzpM2dseWYAAAH0AAAAGgAAABoNIh0kaGVhZAAAARwAAAAvAAAANgxLumdoaGVhAAABTAAAABUAAAAkCAEEAmhtdHgAAAG8AAAABgAAAAYEAAAAbG9jYQAAAewAAAAGAAAABgANAABtYXhwAAABZAAAABsAAAAgAg4AHW5hbWUAAAIQAAAAOAAAAD4C5wsecG9zdAAAAkgAAAAMAAAAIAADAAB4AWNgZGAAYQ5+qdB4fpuvDNIsDCBwaQGTAIi+VlscBaJZGMDiHAxMIAoAtjIF/QB4AWNgZGBgYQACOAkUQQWMAAGRABAAAAB4AWNgZGBgYGJgAdMMUJILJMQgAWICAAH3AC4AeAFjYGFhYJzAwMrAwDST6QwDA0M/hGZ8zWDMyMmAChgFkDgKQMBw4CXDSwYWEBdIYgAFBgYA/8sIdAAABAAAAAAAAAB4AWNgYGBkYAZiBgYeBhYGBSDNAoRA/kuG//8hpDgjWJ4BAFVMBiYAAAAAAAANAAAAAQAAAAAEAAQAAAMAABEhESEEAPwABAD8AAAAeAEtxgUNgAAAAMHHIQTShTlOAty9/4bf7AARCwlBNhBw4L/43qXjYGUmf19TMuLcj/BJL3XfBg54AWNgZsALAAB9AAR4AWNgYGAEYj4gFgGygGwICQACOwAoAAAAAAABAAEAAQAAAA4AAAAAyP8AAA==';
|
// eslint-disable-next-line
|
||||||
let svg = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="100" style="background:#fff;fill:#000;">' +
|
const fontCOLR = 'd09GRgABAAAAAAKAAAwAAAAAAowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDT0xSAAACVAAAABYAAAAYAAIAJUNQQUwAAAJsAAAAEgAAABLJAAAQT1MvMgAAAYAAAAA6AAAAYBfxJ0pjbWFwAAABxAAAACcAAAAsAAzpM2dseWYAAAH0AAAAGgAAABoNIh0kaGVhZAAAARwAAAAvAAAANgxLumdoaGVhAAABTAAAABUAAAAkCAEEAmhtdHgAAAG8AAAABgAAAAYEAAAAbG9jYQAAAewAAAAGAAAABgANAABtYXhwAAABZAAAABsAAAAgAg4AHW5hbWUAAAIQAAAAOAAAAD4C5wsecG9zdAAAAkgAAAAMAAAAIAADAAB4AWNgZGAAYQ5+qdB4fpuvDNIsDCBwaQGTAIi+VlscBaJZGMDiHAxMIAoAtjIF/QB4AWNgZGBgYQACOAkUQQWMAAGRABAAAAB4AWNgZGBgYGJgAdMMUJILJMQgAWICAAH3AC4AeAFjYGFhYJzAwMrAwDST6QwDA0M/hGZ8zWDMyMmAChgFkDgKQMBw4CXDSwYWEBdIYgAFBgYA/8sIdAAABAAAAAAAAAB4AWNgYGBkYAZiBgYeBhYGBSDNAoRA/kuG//8hpDgjWJ4BAFVMBiYAAAAAAAANAAAAAQAAAAAEAAQAAAMAABEhESEEAPwABAD8AAAAeAEtxgUNgAAAAMHHIQTShTlOAty9/4bf7AARCwlBNhBw4L/43qXjYGUmf19TMuLcj/BJL3XfBg54AWNgZsALAAB9AAR4AWNgYGAEYj4gFgGygGwICQACOwAoAAAAAAABAAEAAQAAAA4AAAAAyP8AAA==';
|
||||||
'<style type="text/css">'+
|
const svg = `
|
||||||
'@font-face{font-family:"chromacheck-colr";src:url(data:application/x-font-woff;base64,'+fontCOLR+') format("woff");}'+
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="100" style="background:#fff;fill:#000;">
|
||||||
'</style>'+
|
<style type="text/css">
|
||||||
'<text x="0" y="0" font-size="20">' +
|
@font-face {
|
||||||
'<tspan font-family="chromacheck-colr" x="0" dy="20"></tspan>' + // COLR
|
font-family: "chromacheck-colr";
|
||||||
'</text>' +
|
src: url(data:application/x-font-woff;base64,${fontCOLR}) format("woff");
|
||||||
'</svg>';
|
}
|
||||||
canvas.width = 20;
|
</style>
|
||||||
|
<text x="0" y="0" font-size="20">
|
||||||
|
<tspan font-family="chromacheck-colr" x="0" dy="20"></tspan>
|
||||||
|
</text>
|
||||||
|
</svg>`;
|
||||||
|
canvas.width = 20;
|
||||||
canvas.height = 100;
|
canvas.height = 100;
|
||||||
|
|
||||||
img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
|
img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
|
||||||
|
|
||||||
// FIXME wait for safari load our colr font
|
// FIXME wait for safari load our colr font
|
||||||
const wait = ms => new Promise((r, j)=>setTimeout(r, ms))
|
const wait = ms => new Promise((r, j)=>setTimeout(r, ms));
|
||||||
await wait(500);
|
await wait(500);
|
||||||
|
|
||||||
context.drawImage(img, 0, 0);
|
context.drawImage(img, 0, 0);
|
||||||
colrFontSupported = (context.getImageData(10, 10, 1, 1).data[0] === 200);
|
colrFontSupported = (context.getImageData(10, 10, 1, 1).data[0] === 200);
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
console.error("Couldn't load colr font", e);
|
console.error("Couldn't load colr font", e);
|
||||||
colrFontSupported = false;
|
colrFontSupported = false;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +73,7 @@ export async function fixupColorFonts() {
|
||||||
let font;
|
let font;
|
||||||
if (await isColrFontSupported()) {
|
if (await isColrFontSupported()) {
|
||||||
font = new FontFace("Twemoji", "url('../../fonts/Twemoji_Mozilla/TwemojiMozilla-colr.woff2')", {});
|
font = new FontFace("Twemoji", "url('../../fonts/Twemoji_Mozilla/TwemojiMozilla-colr.woff2')", {});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
font = new FontFace("Twemoji", "url('../../fonts/Twemoji_Mozilla/TwemojiMozilla-sbix.woff2')", {});
|
font = new FontFace("Twemoji", "url('../../fonts/Twemoji_Mozilla/TwemojiMozilla-sbix.woff2')", {});
|
||||||
}
|
}
|
||||||
document.fonts.add(font);
|
document.fonts.add(font);
|
||||||
|
|
Loading…
Reference in a new issue