[Tex/LaTex] Using TeX fonts in HTML documents

fontshtml

If I want to use TeX fonts (such as cmr10, cmbx10, cmtt10, and so forth) in my HTML documents, what are the recommended ways to do that?

As a thought experiment and proof-of-concept, this afternoon I re-encoded the 140 fonts from the bakoma-fonts package as web fonts and made a font waterfall demonstration page:

The results are encouraging, but I don't know if this is the best way to achieve this. I still need to organize the various sizes and shapes into font families in the CSS style sheet and add CSS classes for invoking the various weights, shapes, and sizes.

I hope I'm not reinventing the wheel here, but I started down this path today because I was unsuccessful in finding any other resources about this topic anywhere. It seems that lots of people want to use fancy TrueType fonts in TeX documents, but I seem to be the only one who wants to use native TeX fonts in my web pages. Is this a road to Hell paved with good intentions and nothing but insanity at the end of the rainbow? I know that ligatures are going to be difficult and that obviously hyphenation is going to work differently, but I still think it would be really fun to use Computer Modern Roman and friends in some of my HTML documents, and the challenge of getting there is so tempting.

Best Answer

If you specifically want the Computer Modern fonts on your webpage, your best bet is to use the Latin Modern CM clone, since it is available in OTF format. These could then be used e.g. with @font-face (Fontsquirrel has a good generator).

If you're asking a more general question, e.g. "How do I use any T1 font on my webpage", the answer is a bit more depressing. In that case, your only option would be to generate an OTF font based on the T1 representations. This is nontrivial and presumably time-consuming, but it should be possible using FontForge or similar tools.

tl;dr: Find an OTF alternative if possible, otherwise create an OTF font based on the T1 fonts.

Related Question