Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locally installed web-fonts are not detected #711

Closed
dpvc opened this issue Jan 8, 2014 · 14 comments

Comments

Projects
None yet
3 participants
@dpvc
Copy link
Member

commented Jan 8, 2014

The new web fonts are not detected and used if they are locally installed. The names in the font-test array were not changed when the font names where changed to include "MathJax".

@ghost ghost assigned dpvc Jan 8, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Jan 13, 2014

Davide P. Cervone
Fix font names in font-test data so that local versions of the web fo…
…nts can be detected. This still has to be tested on Windows and Linux. Issue mathjax#711.

@dpvc dpvc added Ready for Review and removed In Development labels Feb 5, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Feb 12, 2014

@dpvc

This comment has been minimized.

Copy link
Member Author

commented Feb 12, 2014

=> Merged.

@dpvc dpvc closed this Feb 12, 2014

@dpvc dpvc removed their assignment Feb 12, 2014

@pkra

This comment has been minimized.

Copy link
Member

commented Feb 12, 2014

On the flip side, do we want to support the regular STIX as webfonts? E.g., https://groups.google.com/d/msg/mathjax-users/lF2xQwKZz1M/2wc6NNEARkEJ

@dpvc

This comment has been minimized.

Copy link
Member Author

commented Feb 13, 2014

Do we want to support the regular STIX as webfonts?

I don't think we want to encourage that, especially now that we have the web versions of STIX fonts ourselves. The page you link to says how to do it if you want to.

@pkra

This comment has been minimized.

Copy link
Member

commented Feb 17, 2014

I don't quite understand why this is something we want to discourage. It seems like a natural option to me.

@dpvc

This comment has been minimized.

Copy link
Member Author

commented Feb 17, 2014

The STIX fonts re too big to use as web fonts, in general. That's why we broke them down into smaller pieces for our own web fonts. Now that we have the STIX-web fonts, I see little reason for someone to use the original STIX fonts as web fonts. The original STIX fonts don't include the test characters that we need to test for their presence reliably, so it would be fragile to use them as web fonts. The post that you linked to already documents a means of doing this for those who really want to do so.

The STIXGeneral font in regular. italics, and bold (which is pretty much a minimum that people would need to downloaded, and that doesn't include stretched characters, etc.) is over 800KB. The corresponding MathJax web fonts are just over 100KB (and the STIX-web fonts around 150KB). I think it is a mistake to encourage people to use the regular STIX fonts as web fonts.

@pkra

This comment has been minimized.

Copy link
Member

commented Feb 17, 2014

I'm not insisting herer but I thought I'd explain myself for completeness.

The STIX fonts re too big to use as web fonts, in general.

Well, we did package them as woff file at the request of STIpub and it is the dominating download on the STIX project since they released them (which arguably doesn't mean as much since it's the version linked to from their homepage and the default file on sourceforge)

Now that we have the STIX-web fonts, I see little reason for someone to use the original STIX fonts as web fonts.

Because people want to use them for their main text and STIX-mathjax isn't a very practical webfont to load.

The original STIX fonts don't include the test characters that we need to test for their presence reliably, so it would be fragile to use them as web fonts.

We contributed our test character to the STIX fonts and they should be included in the STIX-web version. (If they aren't, we should actually fix that -- it's what STIpub wanted.)

The post that you linked to already documents a means of doing this for those who really want to do so.

I may misunderstand things, but that post looks like a hack to me.

The STIXGeneral font in regular. italics, and bold (which is pretty much a minimum that people would need to downloaded, and that doesn't include stretched characters, etc.) is over 800KB.

In STIX-web I get about ~480KB. Sure, that's a lot but I don't think it matters if it's 800KB. We're offering a slim version with STIX-mathjax for those who want something slim. I don't see how offering the other option is a bad thing. Some users prefer larger loads like that (e.g. wikipedia, stackexchange).

Again, I'm not saying we should support this right now or pursue this. I just don't find this to be something we need to discourage -- rather, it seems a logical consequence of having produced STIX-web and having our test characters as part of STIX. I'm more than happy to leave this until we get more user request. But could you say if there are any technical difficulties with this?

@dpvc

This comment has been minimized.

Copy link
Member Author

commented Feb 17, 2014

Well, we did package them as woff file at the request of STIpub and it is the dominating download on the STIX project since they released them (which arguably doesn't mean as much since it's the version linked to from their homepage and the default file on sourceforge)

I just checked what they are distributing, and didn't realize they had repackaged STIXGeneral with the test characters and as woff fonts. That does improve the possibilities. I also was thinking of STIX-web as our versions of the fonts (what they call STIX-MathJax), so we may have been talking at cross purposes. I see their modified STIXGeneral fonts are called "stix-web".

I don't see how offering the other option is a bad thing.

So are you suggesting that we host stix-web (the STIXGeneral fonts in WOFF format) on the MathJax CDN as well as the STIX-MathJax fonts? This would be the easiest way to handle allowing it. Otherwise, the code would have to be rewritten to allow loading of the font data from the CDN but the fonts themselves from somewhere else, and that is not currently supported.

Some users prefer larger loads like that (e.g. wikipedia, stackexchange).

But I doubt they want to load large downloads where most of the download is never used, which will be the case for STIXGeneral. It includes all the dingbats, the enclosed alphanumerics, the box drawing characters, and the geometric shapes, in addition to all the accented latin characters, all the math characters, and all the math alphabets. For use in regular text, that is not very efficient. It would seem to me that using STIXMathJax_Main would work well for English text, and STIXMathJax_Main,STIXMathJax_Latin would do for European languages if you want STIX for the main font.

Could you say if there are any technical difficulties with this?

Since the test characters are in the fonts, things are better than I realized. The main problem would be if the fonts were coming from one site and the data from another. Technical solutions would be to have the font data stored at the non-CDN location along with the fonts (not great), or modifying MathJax to provide for this (source of potential mismatch of data and fonts). The other issue is a possible conflict between the @font-face directives used by the page author to obtain the fonts for the main page and the ones used by MathJax to get its fonts. MathJax currently tries to use the font name as the identifier for the font (so that if theHTML is copied and pasted, the fonts are named properly for locally installed versions of the fonts); that is, it uses STIXGeneral for that font. So if the page author uses STIXGeneral as well, one of MathJax or the page author will overwrite the other's CSS declarations, and they may not be completely compatible. I guess MathJax could use names with an MJX- prefix or something to help avoid that.

@PaulTopping

This comment has been minimized.

Copy link

commented Feb 17, 2014

Perhaps this has already been discussed. If so, I apologize.

Does the webfont technology allow for a locally installed font to substitute for a like-named webfont? Or are they always treated as different by browsers? It would be nice if a locally installed full STIX font could eliminate the need to download and use STIX webfonts, thereby giving a little performance bump. If that mechanism exists, doesn't the division of STIX into smaller webfonts break that mechanism?

I'm partly curious and partly wondering what we should fight for in future webfont and browser standards.

Paul

@pkra

This comment has been minimized.

Copy link
Member

commented Feb 17, 2014

Does the webfont technology allow for a locally installed font to substitute for a like-named webfont?

Yes, see e.g. https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face.

It would be nice if a locally installed full STIX font could eliminate the need to download and use STIX webfonts, thereby giving a little performance bump.

MathJax will prefer locally installed copies of all of its webfonts and also the STIX-General font. However, there are many variants of the STIX fonts and not all can be used by MathJax (most notoriously the STIX-Word fonts).

If that mechanism exists, doesn't the division of STIX into smaller webfonts break that mechanism?

Not really. While the STIX-mathjax webfonts are specifically designed for MathJax (smaller chunks for faster downloads), local copies of the STIX-General and STIX-mathjax fonts will still be preferred.

@PaulTopping

This comment has been minimized.

Copy link

commented Feb 17, 2014

Thanks, Peter. What you say here implies that the mechanism is implemented in MathJax, not in the browser's web fonts mechanism. In other words, JavaScript code must test for the presence of local fonts in order to use them over the web fonts. Or is it done using CSS?

Paul

@pkra

This comment has been minimized.

Copy link
Member

commented Feb 17, 2014

Or is it done using CSS?

Davide will correct me but checking for local fonts is simply done by CSS (at least on modern browsers).

@dpvc

This comment has been minimized.

Copy link
Member Author

commented Feb 17, 2014

@PaulTopping, the CSS @font-face directive can specify local fonts as well as web fonts, so you can arrange for the page font (for example) to use a local STIX font if present and a remote web font if not.

Because web fonts arrive asynchronously (and can change the font in use well after the DOM has been initially set by MathJax), MathJax has to wait for web fonts to arrive before it lays out the math. That way, it knows that the sizes it is measuring represent the true size of the math, not the size of intermediate fonts that will change later. So MathJax has to be particularly careful to distinguish between web and local fonts. The main page need not worry about that, since the browser will reflow the page when web fonts arrive, but the math would need to be re-typeset by MathJax in that case, and there is no Browser API to allow that to happen. (At least not yet, but Peter has a pointer to a new web font API that would help in this respect.)

So the upshot is that both are true. CSS can allow for either local or web fonts, but MathJax is more particular about what fonts it uses, and needs to knows the difference between the two, in general, and does treat them differently.

@PaulTopping

This comment has been minimized.

Copy link

commented Feb 17, 2014

Thanks, Davide.

I would think MathJax has enough clout now to perhaps have impact on future web fonts and CSS standards and their implementations. I have been following the rise of CSS over XSL-FO for so-called "paged media". There were two papers on this subject in the recent XML Prague conference. Since math is often in ebooks and paged HTML, it will be interesting to see if any accommodations needed for math can be introduced. Do you guys have a list of requests for helpful enhancements or problem areas in Web Platform standards? Or is it largely the case that we just need to wait for browsers' implementations to catch up?

Paul

dpvc pushed a commit to mathjax/MathJax-test that referenced this issue Apr 22, 2014

@dpvc

This comment has been minimized.

Copy link
Member Author

commented Apr 22, 2014

=> In Test Suite.

Configuration/issue711.html

@dpvc dpvc added v2.4 and removed Merged labels Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.