layout/mathml/MathJaxFonts.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial