layout/mathml/MathJaxFonts.html

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

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

mercurial