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

feat(mathml): always load MathML font, update Polyfill, use latest woff2 font #7620

Merged
merged 6 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"*": "prettier --ignore-unknown --write",
"*.{js,jsx,tsx}": "eslint --fix",
"*.{css,scss}": "stylelint --fix"
"*.{css,scss}": "stylelint --fix --allow-empty-input"
}
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions client/src/document/mathml-polyfill/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import "./mathml-font.scss";

const MathMLPolyfill = React.lazy(() => import("./polyfill"));

// This component gets rendered if the document has MathML in it.
Expand Down
10 changes: 10 additions & 0 deletions client/src/document/mathml-polyfill/mathml-font.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@font-face {
font-family: "STIXTwoMath-Regular";
font-weight: normal;
src: local("STIXTwoMath-Regular") url("./font/STIXTwoMath-Regular.woff2")
format("woff2");
}

math {
font-family: "STIXTwoMath-Regular";
}
57 changes: 45 additions & 12 deletions client/src/document/mathml-polyfill/mathml.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* Adding the following based on https://developer.mozilla.org/en-US/docs/Web/MathML/Fonts */
@font-face {
font-family: "STIXRegular";
src: url("./font/STIXTwoMath-Regular.otf") format("opentype");
font-weight: normal;
}

/* See https://github.com/fred-wang/mathml.css */

@namespace "http://www.w3.org/1998/Math/MathML";

/* math */
math {
display: inline;
font-family: "STIXRegular";
text-indent: 0;
}
math[display="block"] {
math[display="block"],
math[mode="display"] {
display: block;
text-align: center;
}
Expand Down Expand Up @@ -97,7 +90,8 @@ mroot {
border-top: solid thin;
}
msqrt:before,
mroot:before {
mroot:before,
menclose[notation="radical"]:before {
margin-left: -0.5em;
content: "\221A";
}
Expand Down Expand Up @@ -141,24 +135,58 @@ menclose[notation*="roundedbox"] {
menclose[notation*="circle"] {
border-radius: 50%;
}
menclose[notation*="horizontalstrike"] {
menclose[notation*="strike"] {
text-decoration: line-through;
}
menclose[notation="radical"],
menclose[notation*="longdiv"] {
border-top: solid thin;
margin-left: 0.5em;
}
menclose[notation*="longdiv"]::before {
margin-left: -0.6em;
content: "\27CC"; /* in unicode fonts only */
}
menclose[notation*="phasorangle"] {
border-bottom: solid thin;
margin-left: 0.2em;
}

menclose[notation*="phasorangle"]::before {
margin-left: -0.5em;
position: relative;
top: 0.45em;
content: "\2220"; /* in unicode fonts only */
}

/* table */
mtable {
display: inline-table !important;
vertical-align: middle;
text-align: center;
}
mtr {
mtr,
mlabeledtr {
display: table-row !important;
}
mlabeledtr > mtd:first-child {
display: none;
} /* fallback since won't display this as label correctly */
mtd {
display: table-cell !important;
padding: 0 0.5ex;
}

mtable[frame="solid"] {
border-style: solid;
}
mtable[frame="dashed"] {
border-style: dashed;
}
mtable[frame="none"] {
border-style: none;
}

/* token elements */
mspace {
margin: 0.2em;
Expand Down Expand Up @@ -239,3 +267,8 @@ math:active > semantics > *:first-child {
math:active annotation:first-of-type {
display: inline !important;
}

/* fix */
mfrac {
text-align: center; /* was done previously (above) */
}