forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMathJaxFonts.html
178 lines (156 loc) · 5.05 KB
/
MathJaxFonts.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!-- -*- mode: HTML; tab-width: 2; indent-tabs-mode: nil; -*- -->
<!-- vim: set tabstop=2 expandtab shiftwidth=2 textwidth=80: -->
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html>
<head>
<title>MathJax fonts</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["output/HTML-CSS"],
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/unpacked/MathJax.js">
</script>
<script type="text/javascript">
var fontList = [
"MathJax_Main",
"MathJax_Size1",
"MathJax_Size2",
"MathJax_Size3",
"MathJax_Size4",
"MathJax_AMS",
"MathJax_Main-bold"
];
var noChar = codePoint();
function codePoint(aValue, aFont)
{
var v = 0xFFFD;
if (aValue) {
v = aValue;
}
var f = "";
if (aFont) {
var i = fontList.indexOf(aFont);
if (i > 0) {
f = "@" + i;
}
}
var hexacode = Number(v).toString(16).toUpperCase();
while (hexacode.length < 4) {
hexacode = "0" + hexacode;
}
return "\\u" + hexacode + f;
}
function codePoint2(aList)
{
if (aList) {
return codePoint(aList[0], aList[1]);
} else {
return noChar;
}
}
function isSupported(aStretch)
{
for (var x in aStretch) {
var part = aStretch[x];
if (part[0] instanceof Array) {
// Composite char
return false;
} else if (part.length > 2) {
// Part has scale factor
return false;
}
}
return true;
}
MathJax.Hub.Queue(
["Require", MathJax.Ajax, "[MathJax]/jax/element/mml/jax.js"],
["Require", MathJax.Ajax, "[MathJax]/jax/output/HTML-CSS/jax.js"],
["Require", MathJax.Ajax, "[MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata-extra.js"],
function () {
var t = document.getElementById("output");
t.value = "";
var fontData = MathJax.OutputJax["HTML-CSS"].FONTDATA;
t.value += "# Content below is generated from MathJaxFonts.html. Do not edit.\n";
t.value += "\n";
// Generate the list of external fonts
for (var i = 1; i < fontList.length; i++) {
t.value += "external." + i + " = " + fontList[i] + "\n";
}
t.value += "\n";
// Generate stretchy table for delimiters
var delimiters = fontData.DELIMITERS;
for (var u in delimiters) {
var v = delimiters[u];
if (v.load) {
// These characters are already handled when we load fontdata-extra.js
continue;
}
if (v.alias) {
if (delimiters.hasOwnProperty(v.alias)) {
// use data from the char pointed by this alias
v = delimiters[v.alias];
} else {
// It is an alias to a non-stretchy char. Ignore it.
continue;
}
}
if (v.stretch && !isSupported(v.stretch)) {
// This construction is not supported.
t.value += "# " + codePoint(u) + " = [not supported]\n";
continue;
}
t.value += codePoint(u);
t.value += " = ";
if (v.stretch) {
if (v.dir == "V") {
t.value += codePoint2(v.stretch.top);
t.value += codePoint2(v.stretch.mid);
t.value += codePoint2(v.stretch.bot);
t.value += codePoint2(v.stretch.ext);
} else {
t.value += codePoint2(v.stretch.left);
t.value += codePoint2(v.stretch.mid);
t.value += codePoint2(v.stretch.right);
t.value += codePoint2(v.stretch.rep);
}
} else {
t.value += noChar + noChar + noChar + noChar;
}
for (var i in v.HW) {
t.value += codePoint(u, v.HW[i][1]);
}
t.value += "\n";
}
// Generate table for large operators
var fonts1 = fontData.FONTS[fontList[1]];
var fonts2 = fontData.FONTS[fontList[2]];
for (var u in fonts1) {
if (delimiters.hasOwnProperty(u) || // already listed above
u == "version" || u == "available" ||
u == "directory" || u == "family" || u == "testString") {
// Ignore these properties
continue;
}
t.value += codePoint(u);
t.value += " = ";
t.value += noChar + noChar + noChar + noChar;
t.value += codePoint(u, fontList[1]);
if (fonts2.hasOwnProperty(u)) {
t.value += codePoint(u, fontList[2]);
}
t.value += "\n";
}
});
</script>
</head>
<body>
<textarea id="output" cols="80" rows="20"></textarea>
</body>
</html>