-
Notifications
You must be signed in to change notification settings - Fork 4
/
font-selection.js
61 lines (58 loc) · 2.11 KB
/
font-selection.js
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
51
52
53
54
55
56
57
58
59
60
61
let mathfont_list = {
"Default": "Default fonts (local only)",
"Asana": "Asana",
"Cambria": "Cambria (local only)",
"DejaVu": "DejaVu",
"FiraMath": "FiraMath",
"Garamond": "Garamond",
"GFS_NeoHellenic": "GFS NeoHellenic",
"LatinModern": "Latin Modern",
"Libertinus": "Libertinus",
"LucidaBright": "Lucida Bright (local only)",
"Minion": "Minion (local only)",
"STIX": "STIX",
"TeXGyreBonum": "TeX Gyre Bonum",
"TeXGyrePagella": "TeX Gyre Pagella",
"TeXGyreSchola": "TeX Gyre Schola",
"TeXGyreTermes": "TeX Gyre Termes",
"XITS": "XITS",
};
document.addEventListener("DOMContentLoaded", () => {
let mathfont_link = document.createElement("link");
mathfont_link.setAttribute("rel", "stylesheet");
mathfont_link.setAttribute("type", "text/css");
document.head.appendChild(mathfont_link);
let mathfont_select = document.querySelector("select.mathfont");
if (mathfont_select) {
function updateMathFont()
{
let mathfont = mathfont_select.value;
if (mathfont == "Default")
mathfont_link.removeAttribute("href");
else
mathfont_link.setAttribute("href",
`/MathFonts/${mathfont}/mathfonts.css`);
}
for (let value in mathfont_list) {
let option = document.createElement("option");
option.setAttribute("value", value);
option.innerText = mathfont_list[value];
mathfont_select.appendChild(option);
}
updateMathFont();
mathfont_select.addEventListener("change", updateMathFont);
}
let mathmlonly_checkbox =
document.querySelector("input[type='checkbox'].mathmlonly")
if (mathmlonly_checkbox) {
function updateCheckBox()
{
if (mathmlonly_checkbox.checked)
document.body.removeAttribute("class");
else
document.body.setAttribute("class", "htmlmathparagraph");
}
updateCheckBox();
mathmlonly_checkbox.addEventListener("change", updateCheckBox);
}
});