Work-around for problem with STIX fonts on OS X Lion

134 views
Skip to first unread message

Davide P. Cervone

unread,
Jan 18, 2012, 3:59:20 PM1/18/12
to mathja...@googlegroups.com
OK, I've finally had the chance to come up with a work-around to the
STIX font problem on OS X Lion. It turns out that WebKit seems to be
replacing the font of "font-family:STIXGeneral" with the equivalent of
"font-family:STIXGeneral; font-style:italic" whenever the italic font
includes the corresponding character, and replacing "font-
family:STIXGeneral; font-style:italic" by an extra italic version of
STIXGeneral (algorithmically generated). All of this is unrelated to
MathJax, as it occurs in a page with just text and CSS to change the
fonts. (It also adversely affects the native MathML in WebKit.)

Fortunately, it is still possible to access the STIXGeneral font via
"font-family:STIXGeneral-Regular" and the italic version by "font-
family:STIXGeneral-Italic" (without the "font-style:italic"). It is
also possible to tell MathJax to set up its references that way. To
do so, include the following before loading MathJax.js:

<script type="text/x-mathjax-config">
MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/HTML-CSS/fonts/
STIX/fontdata.js", function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];

MathJax.Hub.Browser.Select({
Safari: function (browser) {
browser.STIXfontBug = browser.versionAtLeast("5.1") &&
browser.isMac;
},
Chrome: function (browser) {
var match = navigator.appVersion.match(/AppleWebKit\/(\d+)/);
if (match && parseInt(match[1]) > 534) {browser.STIXfontBug =
true}
}
});
if (MathJax.Hub.Browser.STIXfontBug) {
HTMLCSS.FONTDATA.FONTS["STIXGeneral"].family = "STIXGeneral-
Regular";
HTMLCSS.FONTDATA.FONTS["STIXGeneral-italic"].family =
"STIXGeneral-Italic";
delete HTMLCSS.FONTDATA.FONTS["STIXGeneral-italic"].style;
}
});
</script>

This will be included in MathJax v2.0. This should allow the STIX
fonts to be used correctly with MathJax, without having your users
disable STIX, or disabling STIX fonts for non-WebKit browsers.

Hope that helps.

Davide

Victor Ivrii

unread,
Jan 18, 2012, 4:52:27 PM1/18/12
to mathja...@googlegroups.com
On Wed, Jan 18, 2012 at 3:59 PM, Davide P. Cervone <dp...@union.edu> wrote:
> OK, I've finally had the chance to come up with a work-around to the STIX
> font problem on OS X Lion.  It turns out that WebKit seems to be replacing
> the font of "font-family:STIXGeneral" with the equivalent of
> "font-family:STIXGeneral; font-style:italic" whenever the italic font
> includes the corresponding character, and replacing
> "font-family:STIXGeneral; font-style:italic" by an extra italic version of

> STIXGeneral (algorithmically generated).  All of this is unrelated to
> MathJax, as it occurs in a page with just text and CSS to change the fonts.
>   (It also adversely affects the native MathML in WebKit.)
>
> Fortunately, it is still possible to access the STIXGeneral font via
> "font-family:STIXGeneral-Regular" and the italic version by
> "font-family:STIXGeneral-Italic" (without the "font-style:italic").  It is

> also possible to tell MathJax to set up its references that way.  To do so,
> include the following before loading MathJax.js:
>
>        <script type="text/x-mathjax-config">
>
>  MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/HTML-CSS/fonts/STIX/fontdata.js",


Would be it possible to achieve the same effect by changing default.js

(presuming that MJ is loaded from the web server, not from cloud)?


Victor
--
========================
Victor Ivrii, Professor, Department of Mathematics, University of Toronto
http://www.math.toronto.edu/ivrii

Davide P. Cervone

unread,
Jan 18, 2012, 5:07:27 PM1/18/12
to mathja...@googlegroups.com
Yes, you can add it at the bottom of the default.js file (before the
loadComplete() call).

Davide

Victor Ivrii

unread,
Jan 18, 2012, 5:13:48 PM1/18/12
to mathja...@googlegroups.com
On Wed, Jan 18, 2012 at 5:07 PM, Davide P. Cervone <dp...@union.edu> wrote:
> Yes, you can add it at the bottom of the default.js file (before the
> loadComplete() call).
>

Thanks -- it works !

leathrum

unread,
Jan 19, 2012, 10:42:03 AM1/19/12
to MathJax Users
Any chance of getting this into the CDN default.js for version 1.1
soon, as an interim measure while we wait for version 2.0 to be
released? I'm afraid the Lion users are already pretty frustrated, so
the sooner we can address their concerns, the better for MathJax.

On Jan 18, 4:13 pm, Victor Ivrii <viv...@gmail.com> wrote:

Davide P. Cervone

unread,
Jan 20, 2012, 9:17:43 AM1/20/12
to mathja...@googlegroups.com
I hope to be able to release v2.0 in about 2 weeks, so I'm not sure it
makes sense to do another point release before then. The process is
described at

https://sites.google.com/site/mathjaxproject/development-process/hotfix-release-process

and involves several days of lead time. This is one of the things
that Robert was handling, and I don't have access to all the pieces
necessary to carry out the process. I will have to work it out for
the v2.0 release, but don't really think it is necessary to do it
before then. If it looks like 2.0 will be longer than two weeks, I
would reconsider, but things seem to be on schedule for that at the
moment.

Davide

leathrum

unread,
Jan 20, 2012, 4:07:13 PM1/20/12
to MathJax Users
Fair enough. I knew that the 2.0 release was imminent, but I didn't
realize it was that quite close.

On Jan 20, 8:17 am, "Davide P. Cervone" <d...@union.edu> wrote:
> I hope to be able to release v2.0 in about 2 weeks, so I'm not sure it
> makes sense to do another point release before then.  The process is
> described at
>
>        https://sites.google.com/site/mathjaxproject/development-process/hotf...

Philippe Strauss

unread,
Feb 6, 2012, 5:44:01 AM2/6/12
to MathJax Users
Duh it breaks on safari 5.1.2 / OSX 10.6.8, and is even worse on
Safari 5.1.3 / OSX 10.7.3 and chrome 16.0.912.77

chrome seems to use regular text font (no maths symbol at all), safari
find math approximative math symbols i dunno in which font.

on 10.6.8, looks the same than without the workaround on 10.7.3 !

at least on my laptops.

regards.

Davide Cervone

unread,
Feb 8, 2012, 3:16:11 PM2/8/12
to MathJax Users
I recently found that the STIX NonUnicode fonts also need special
treatment (in addition to the STIXGeneral fonts). The updated code is

<script type="text/x-mathjax-config">
MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/HTML-CSS/fonts/
STIX/fontdata.js", function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];

MathJax.Hub.Browser.Select({
Safari: function (browser) {
browser.STIXfontBug = browser.versionAtLeast("5.1") &&
browser.isMac;
},
Chrome: function (browser) {
var match = navigator.appVersion.match(/AppleWebKit\/(\d
+)/);
if (match && parseInt(match[1]) > 534) {browser.STIXfontBug
= true}
}
});
if (MathJax.Hub.Browser.STIXfontBug) {
HTMLCSS.FONTDATA.FONTS["STIXGeneral"].family = "STIXGeneral-
Regular";
HTMLCSS.FONTDATA.FONTS["STIXGeneral-italic"].family =
"STIXGeneral-Italic";
delete HTMLCSS.FONTDATA.FONTS["STIXGeneral-italic"].style;
HTMLCSS.FONTDATA.FONTS["STIXNonUnicode"].family =
"STIXNonUnicode-Regular";
HTMLCSS.FONTDATA.FONTS["STIXNonUnicode-italic"].family =
"STIXNonUnicode-Italic";
delete HTMLCSS.FONTDATA.FONTS["STIXNonUnicode-italic"].style;
}
});
</script>

This will be included in v2.0, but you can use this code for now until
that is released.

Davide
Reply all
Reply to author
Forward
0 new messages