-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfont.html
More file actions
50 lines (50 loc) · 1.87 KB
/
font.html
File metadata and controls
50 lines (50 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="material.css" />
<link rel="stylesheet" href="style.css" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,wght,ROND@6..144,1..1000,100&display=swap"
/>
<meta name="color-scheme" content="light dark" />
</head>
<body data-theme="green">
<div id="fontSelector">
<button class="btn" id="fontBtn">Systeemlettertypes laden</button>
</div>
<script>
if ("queryLocalFonts" in window) {
document.getElementById("fontBtn").style = "display: block";
}
document.getElementById("fontBtn").addEventListener("click", () => {
getFonts();
});
async function getFonts() {
try {
const availableFonts = await window.queryLocalFonts();
document.getElementById("fontSelector").innerHTML =
'<strong class="date">Systeemlettertypes</strong><section><div class="material-textfield"></div></section>';
const fontDiv = document.querySelector("#fontSelector div");
const select = document.createElement("select");
select.name = "fontSelect";
select.id = "fontSelect";
for (const fontData of availableFonts) {
const option = document.createElement("option");
option.innerText = fontData.fullName;
option.value = fontData.fullName;
console.log(fontData.fullName);
select.appendChild(option);
}
fontDiv.appendChild(select);
fontDiv.innerHTML += '<label for="fontSelect">Lettertypes</label>';
} catch (err) {
console.error(err.name, err.message);
}
}
</script>
</body>
</html>