mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +00:00
Summary: I've been experimenting with delivering a TrueType-only KaTeX build for our mobile apps. I couldn't get anything to render properly until I flipped the `format` specifier from `ttf` to `truetype`. Though I can't find a definitive source on this, all the examples I've seen online use `truetype` over `ttf`, and flipping from `ttf` to `truetype` fixed my own issues. It's unlikely that this has been much of a problem in practice, since so many browsers now support WOFF (I'm considering a TrueType-only build since it's the least common denominator across Android 4.3+ and mobile Safari). Test Plan: - To force TrueType rendering, comment out the `.use-eot`, `.use-woff2`, and `.use-woff` lines in `fonts.less`. - Run `make serve`. - Open up the demo page. - Verify that the demo text is rendered as before (only the parens are noticeably different in the demo?). Reviewers: kevinb, emily Reviewed By: emily Subscribers: benkomalo Differential Revision: https://phabricator.khanacademy.org/D29274
70 lines
2.3 KiB
Plaintext
70 lines
2.3 KiB
Plaintext
@font-folder: "fonts";
|
|
@use-eot: true;
|
|
@use-ttf: true;
|
|
@use-woff: true;
|
|
@use-woff2: true;
|
|
|
|
.use-eot(@family, @family-suffix) when (@use-eot = true) {
|
|
src: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.eot');
|
|
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.eot#iefix') format('embedded-opentype')
|
|
}
|
|
|
|
.use-woff2(@family, @family-suffix) when (@use-woff2 = true) {
|
|
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff2') format('woff2')
|
|
}
|
|
|
|
.use-woff(@family, @family-suffix) when (@use-woff = true) {
|
|
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff') format('woff')
|
|
}
|
|
|
|
.use-ttf(@family, @family-suffix) when (@use-ttf = true) {
|
|
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.ttf') format('truetype')
|
|
}
|
|
|
|
.generate-suffix(@weight, @style) when (@weight = normal) and (@style = normal) {
|
|
@suffix: 'Regular';
|
|
}
|
|
.generate-suffix(@weight, @style) when (@weight = normal) and (@style = italic) {
|
|
@suffix: 'Italic';
|
|
}
|
|
.generate-suffix(@weight, @style) when (@weight = bold) and (@style = normal) {
|
|
@suffix: 'Bold';
|
|
}
|
|
.generate-suffix(@weight, @style) when (@weight = bold) and (@style = italic) {
|
|
@suffix: 'BoldItalic';
|
|
}
|
|
|
|
.font-face(@family, @weight, @style) {
|
|
.generate-suffix(@weight, @style);
|
|
@font-face {
|
|
font-family: 'KaTeX_@{family}';
|
|
.use-eot(@family, @suffix);
|
|
.use-woff2(@family, @suffix);
|
|
.use-woff(@family, @suffix);
|
|
.use-ttf(@family, @suffix);
|
|
font-weight: @weight;
|
|
font-style: @style;
|
|
}
|
|
}
|
|
|
|
.font-face('AMS', normal, normal);
|
|
.font-face('Caligraphic', bold, normal);
|
|
.font-face('Caligraphic', normal, normal);
|
|
.font-face('Fraktur', bold, normal);
|
|
.font-face('Fraktur', normal, normal);
|
|
.font-face('Main', bold, normal);
|
|
.font-face('Main', normal, italic);
|
|
.font-face('Main', normal, normal);
|
|
// .font-face('Math', bold, italic);
|
|
.font-face('Math', normal, italic);
|
|
// .font-face('Math', normal, normal);
|
|
// .font-face('SansSerif', bold, normal);
|
|
// .font-face('SansSerif', normal, italic);
|
|
.font-face('SansSerif', normal, normal);
|
|
.font-face('Script', normal, normal);
|
|
.font-face('Size1', normal, normal);
|
|
.font-face('Size2', normal, normal);
|
|
.font-face('Size3', normal, normal);
|
|
.font-face('Size4', normal, normal);
|
|
.font-face('Typewriter', normal, normal);
|