Add new otf fonts (more formats needed), and add support for web fonts in addition to local ones

This commit is contained in:
Davide P. Cervone 2015-03-13 18:40:10 -04:00
parent 15ab276598
commit 3443bb6016
23 changed files with 42 additions and 9 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -31,8 +31,8 @@ MathJax.OutputJax.CommonHTML = MathJax.OutputJax({
directory: MathJax.OutputJax.directory + "/CommonHTML",
extensionDir: MathJax.OutputJax.extensionDir + "/CommonHTML",
autoloadDir: MathJax.OutputJax.directory + "/CommonHTML/autoload",
fontDir: MathJax.OutputJax.directory + "/CommonHTML/fonts",
webfontDir: MathJax.OutputJax.fontDir + "/HTML-CSS",
fontDir: MathJax.OutputJax.directory + "/CommonHTML/fonts", // fontname added later
webfontDir: MathJax.OutputJax.fontDir + "/CommonHTML", // fontname added later
config: {
scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor

View File

@ -1589,23 +1589,55 @@
//
(function () {
var STYLES = CHTML.config.styles, FONTS = CHTML.FONTDATA.FONTS;
var DIR = AJAX.fileURL(CHTML.webfontDir);
var faces = [];
for (var name in FONTS) {if (FONTS.hasOwnProperty(name)) {
var font = FONTS[name]; if (typeof(font) !== "string") font = font.directory;
var names = font.split(/\//);
var suffix = names[0].toLowerCase().replace(/(?:igraphic|serif|writer|tur)$/,"")
+ "-" + names[1].replace(/[^A-Z]/g,"");
var family = "MJX_TeX_"+suffix; FONTS[name].className = "MJXc-TeX-"+suffix;
STYLES[".MJXc-TeX-"+suffix] = {"font-family":family};
font = {"font-family":family}; name = name.replace(/-.*/,"");
if (names[1] === "Regular") {font.src = "local('"+name+"'), local('"+name+"-Regular')"}
else {font.src = "local('"+name+" "+names[1]+"'), local('"+name+"-"+names[1]+"')"}
var family = "MJXc_TeX_"+suffix, FAMILY = family;
FONTS[name].className = "MJXc-TeX-"+suffix;
//
// The local font, if found
//
font = {"font-family":family};
name = name.replace(/-.*/,"");
if (names[1] === "Regular") {
font.src = "local('"+name+"'), local('"+name+"-Regular')";
} else {
font.src = "local('"+name+" "+names[1]+"'), local('"+name+"-"+names[1]+"')";
}
faces.push(font);
//
// For Chrome, need to have separate font-weight and font-style versions
//
if (names[1] !== "Regular") {
font = {"font-family":family+"x", src:"local('"+name+"')"};
if (names[1].match(/Bold/)) font["font-weight"] = "bold";
if (names[1].match(/Italic/)) font["font-style"] = "italic";
FAMILY += ","+family+"x";
faces.push(font);
}
//
// The web font, if no local font found
// ### FIXME: add more formats to src
//
font = {
"font-family":family+"w",
src:"url('"+DIR+"/MathJax_"+names[0]+"-"+names[1]+".otf')"
};
faces.push(font);
//
// A class that looks for the local and web fonts
//
FAMILY += ","+family+"w";
STYLES[".MJXc-TeX-"+suffix] = {"font-family":FAMILY};
}}
if (faces.length) STYLES["@font-face"] = faces;
})();
AJAX.loadComplete(CHTML.fontDir + "/TeX/fontdata.js");
AJAX.loadComplete(CHTML.fontDir + "/fontdata.js");
})(MathJax.OutputJax.CommonHTML,MathJax.ElementJax.mml,MathJax.Ajax);

View File

@ -140,7 +140,8 @@
if (!this.require) {this.require = []}
this.SUPER(arguments).Config.call(this); var settings = this.settings;
if (settings.scale) {this.config.scale = settings.scale}
this.require.push(this.fontDir+"/TeX/fontdata.js");
this.fontDir += "/TeX"; this.webfontDir += "/TeX/otf";
this.require.push(this.fontDir+"/fontdata.js");
this.require.push(MathJax.OutputJax.extensionDir+"/MathEvents.js");
},