Skip to content

Commit 730a405

Browse files
committed
Prevent a disappearing stretchy arrow in CHTML. (mathjax/MathJax#3457)
1 parent 27c47f3 commit 730a405

File tree

1 file changed

+55
-44
lines changed
  • ts/output/common/Wrappers

1 file changed

+55
-44
lines changed

ts/output/common/Wrappers/mo.ts

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -359,53 +359,64 @@ export function CommonMoMixin<
359359
* @override
360360
*/
361361
public getStretchedVariant(WH: number[], exact: boolean = false) {
362-
if (this.stretch.dir !== DIRECTION.None) {
363-
let D = this.getWH(WH);
364-
const min = this.getSize('minsize', 0);
365-
const max = this.getSize('maxsize', Infinity);
366-
const mathaccent = this.node.getProperty('mathaccent');
367-
//
368-
// Clamp the dimension to the max and min
369-
// then get the target size via TeX rules
370-
//
371-
D = Math.max(min, Math.min(max, D));
372-
const df = this.font.params.delimiterfactor / 1000;
373-
const ds = this.font.params.delimitershortfall;
374-
const m =
375-
min || exact
376-
? D
377-
: mathaccent
378-
? Math.min(D / df, D + ds)
379-
: Math.max(D * df, D - ds);
380-
//
381-
// Look through the delimiter sizes for one that matches
382-
//
383-
const delim = this.stretch;
384-
const c = delim.c || this.getText().codePointAt(0);
385-
let i = 0;
386-
if (delim.sizes) {
387-
for (const d of delim.sizes) {
388-
if (d >= m) {
389-
if (mathaccent && i) {
390-
i--;
391-
}
392-
this.setDelimSize(c, i);
393-
return;
362+
if (this.stretch.dir === DIRECTION.None) {
363+
return;
364+
}
365+
let D = this.getWH(WH);
366+
const min = this.getSize('minsize', 0);
367+
const max = this.getSize('maxsize', Infinity);
368+
const mathaccent = this.node.getProperty('mathaccent');
369+
//
370+
// Clamp the dimension to the max and min
371+
// then get the target size via TeX rules
372+
//
373+
D = Math.max(min, Math.min(max, D));
374+
const df = this.font.params.delimiterfactor / 1000;
375+
const ds = this.font.params.delimitershortfall;
376+
const m =
377+
min || exact
378+
? D
379+
: mathaccent
380+
? Math.min(D / df, D + ds)
381+
: Math.max(D * df, D - ds);
382+
//
383+
// Get the delimiter character, and look up the
384+
// delimiter data again if we have already stretched it
385+
// (in case a fixed size set the delim.c). See #3457.
386+
//
387+
const C = this.getText().codePointAt(0);
388+
let delim = this.stretch;
389+
if (this.size) {
390+
this.stretch = delim = this.font.getDelimiter(C) as DD;
391+
this.size = null;
392+
}
393+
const c = delim.c || C;
394+
//
395+
// Look through the delimiter sizes for one that matches
396+
//
397+
let i = 0;
398+
if (delim.sizes) {
399+
for (const d of delim.sizes) {
400+
if (d >= m) {
401+
if (mathaccent && i) {
402+
i--;
394403
}
395-
i++;
404+
this.setDelimSize(c, i);
405+
return;
396406
}
407+
i++;
397408
}
398-
//
399-
// No size matches, so if we can make multi-character delimiters,
400-
// record the data for that, otherwise, use the largest fixed size.
401-
//
402-
if (delim.stretch) {
403-
this.size = -1;
404-
this.invalidateBBox();
405-
this.getStretchBBox(WH, this.checkExtendedHeight(D, delim), delim);
406-
} else {
407-
this.setDelimSize(c, i - 1);
408-
}
409+
}
410+
//
411+
// No size matches, so if we can make multi-character delimiters,
412+
// record the data for that, otherwise, use the largest fixed size.
413+
//
414+
if (delim.stretch) {
415+
this.size = -1;
416+
this.invalidateBBox();
417+
this.getStretchBBox(WH, this.checkExtendedHeight(D, delim), delim);
418+
} else {
419+
this.setDelimSize(c, i - 1);
409420
}
410421
}
411422

0 commit comments

Comments
 (0)