diff --git a/contrib/render-a11y-string/render-a11y-string.js b/contrib/render-a11y-string/render-a11y-string.js index 0ce6370e15..463b2d1d7a 100644 --- a/contrib/render-a11y-string/render-a11y-string.js +++ b/contrib/render-a11y-string/render-a11y-string.js @@ -392,6 +392,11 @@ const handleObject = ( break; } + case "pmb": { + a11yStrings.push("bold"); + break; + } + case "phantom": { a11yStrings.push("empty space"); break; diff --git a/src/domTree.js b/src/domTree.js index 8847504576..6b4e5f1605 100644 --- a/src/domTree.js +++ b/src/domTree.js @@ -153,6 +153,7 @@ export type CssStyle = $Shape<{ minWidth: string, paddingLeft: string, position: string, + textShadow: string, top: string, width: string, verticalAlign: string, diff --git a/src/functions.js b/src/functions.js index edcb9bf1f9..8e14cbae40 100644 --- a/src/functions.js +++ b/src/functions.js @@ -10,6 +10,7 @@ export default functions; import "./functions/accent"; import "./functions/accentunder"; import "./functions/arrow"; +import "./functions/pmb"; import "./environments/cd"; import "./functions/char"; import "./functions/color"; diff --git a/src/functions/pmb.js b/src/functions/pmb.js new file mode 100644 index 0000000000..2be1985283 --- /dev/null +++ b/src/functions/pmb.js @@ -0,0 +1,44 @@ +// @flow +import defineFunction, {ordargument} from "../defineFunction"; +import buildCommon from "../buildCommon"; +import mathMLTree from "../mathMLTree"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {binrelClass} from "./mclass"; + +import type {ParseNode} from "../parseNode"; + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. + +defineFunction({ + type: "pmb", + names: ["\\pmb"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler({parser}, args) { + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]), + }; + }, + htmlBuilder(group: ParseNode<"pmb">, options) { + const elements = html.buildExpression(group.body, options, true); + const node = buildCommon.makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group: ParseNode<"pmb">, style) { + const inner = mml.buildExpression(group.body, style); + // Wrap with an element. + const node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + }, +}); diff --git a/src/macros.js b/src/macros.js index 1fe36b0aff..feb7400b8f 100644 --- a/src/macros.js +++ b/src/macros.js @@ -597,14 +597,6 @@ defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); -// \pmb -- A simulation of bold. -// The version in ambsy.sty works by typesetting three copies of the argument -// with small offsets. We use two copies. We omit the vertical offset because -// of rendering problems that makeVList encounters in Safari. -defineMacro("\\pmb", "\\html@mathml{" + - "\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" + - "{\\mathbf{#1}}"); - ////////////////////////////////////////////////////////////////////// // LaTeX source2e diff --git a/src/parseNode.js b/src/parseNode.js index 839134b395..72ce209b2b 100644 --- a/src/parseNode.js +++ b/src/parseNode.js @@ -414,6 +414,13 @@ type ParseNodeTypes = { loc?: ?SourceLocation, body: AnyParseNode, |}, + "pmb": {| + type: "pmb", + mode: Mode, + loc?: ?SourceLocation, + mclass: string, + body: AnyParseNode[], + |}, "raisebox": {| type: "raisebox", mode: Mode, diff --git a/test/screenshotter/images/Pmb-chrome.png b/test/screenshotter/images/Pmb-chrome.png index 7272df16a2..370a5812fb 100644 Binary files a/test/screenshotter/images/Pmb-chrome.png and b/test/screenshotter/images/Pmb-chrome.png differ diff --git a/test/screenshotter/images/Pmb-firefox.png b/test/screenshotter/images/Pmb-firefox.png index 93f403b68f..7ddf985fdf 100644 Binary files a/test/screenshotter/images/Pmb-firefox.png and b/test/screenshotter/images/Pmb-firefox.png differ diff --git a/test/screenshotter/images/Pmb-safari.png b/test/screenshotter/images/Pmb-safari.png index 6bc58fd08c..46eafea2ce 100644 Binary files a/test/screenshotter/images/Pmb-safari.png and b/test/screenshotter/images/Pmb-safari.png differ