Skip to content

Commit

Permalink
Fix handling of unknown characters in SVG output. (mathjax/MathJax#3224)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed May 3, 2024
1 parent 2185f0b commit 4945ed9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions ts/output/svg/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,21 +489,25 @@ export class SvgWrapper<N, T, D> extends CommonWrapper<
}
const C = n.toString(16).toUpperCase();
const [ , , w, data] = this.getVariantChar(variant, n);
if (data.unknown) {
this.utext += String.fromCodePoint(n);
return (buffer ? 0 : this.addUtext(x, y, parent, variant));
}
const dx = this.addUtext(x, y, parent, variant);
if ('p' in data) {
x += this.addUtext(x, y, parent, variant);
x += dx;
const path = (data.p ? 'M' + data.p + 'Z' : '');
this.place(x, y, this.adaptor.append(parent, this.charNode(variant, C, path)) as N);
} else if ('c' in data) {
x += this.addUtext(x, y, parent, variant);
return w + dx;
}
if ('c' in data) {
const g = this.adaptor.append(parent, this.svg('g', {'data-c': C})) as N;
this.place(x, y, g);
this.place(x + dx, y, g);
x = 0;
for (const n of this.unicodeChars(data.c, variant)) {
x += this.placeChar(n, x, y, g, variant);
}
} else if (data.unknown) {
this.utext += String.fromCodePoint(n);
return (buffer ? 0 : this.addUtext(x, y, parent, variant));
return x + dx;
}
return w;
}
Expand Down

0 comments on commit 4945ed9

Please sign in to comment.