Skip to content

Commit 240d5ae

Browse files
ronkokedemaine
andauthored
feat: Support bold Fraktur (#3777)
* feat: Support bold Fraktur * Evade wideCharacterFont() when inapplicable * Avoid creating array when uneccesary --------- Co-authored-by: Erik Demaine <[email protected]>
1 parent 4f1d916 commit 240d5ae

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

docs/supported.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ Math-mode Unicode (sub|super)script characters will render as if you had written
205205
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
206206
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
207207
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
208-
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
208+
| Fractur | $\text{𝔄-ℨ}\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
209+
| Bold Fractur | $\text{𝕬-𝖅}\text{𝖆-𝖟}$ | |
209210

210211
</div>
211212
<div class="katex-hopscotch">

src/buildCommon.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
165165
// Math mode or Old font (i.e. \rm)
166166
const isFont = mode === "math" || (mode === "text" && options.font);
167167
const fontOrFamily = isFont ? options.font : options.fontFamily;
168+
let wideFontName = "";
169+
let wideFontClass = "";
168170
if (text.charCodeAt(0) === 0xD835) {
171+
[wideFontName, wideFontClass] = wideCharacterFont(text, mode);
172+
}
173+
if (wideFontName.length > 0) {
169174
// surrogate pairs get special treatment
170-
const [wideFontName, wideFontClass] = wideCharacterFont(text, mode);
171175
return makeSymbol(text, wideFontName, mode, options,
172176
classes.concat(wideFontClass));
173177
} else if (fontOrFamily) {

src/katex.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@
129129
font-family: KaTeX_Fraktur;
130130
}
131131

132+
.mathboldfrak,
133+
.textboldfrak {
134+
font-family: KaTeX_Fraktur;
135+
font-weight: bold;
136+
}
137+
132138
.mathtt {
133139
font-family: KaTeX_Typewriter;
134140
}

src/symbols.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ for (let i = 0; i < letters.length; i++) {
816816
defineSymbol(math, main, mathord, ch, wideChar);
817817
defineSymbol(text, main, textord, ch, wideChar);
818818

819+
wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fractur
820+
defineSymbol(math, main, mathord, ch, wideChar);
821+
defineSymbol(text, main, textord, ch, wideChar);
822+
819823
wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif
820824
defineSymbol(math, main, mathord, ch, wideChar);
821825
defineSymbol(text, main, textord, ch, wideChar);

src/wide-character.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ const wideLatinLetterData: Array<[string, string, string]> = [
4545
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
4646
["mathbb", "textbb", "AMS-Regular"], // k double-struck
4747

48-
["", "", ""], // A-Z bold Fraktur No font metrics
49-
["", "", ""], // a-z bold Fraktur. No font.
48+
// Note that we are using a bold font, but font metrics for regular Fraktur.
49+
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur
50+
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur
5051

5152
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
5253
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif

test/katex-spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3919,6 +3919,7 @@ describe("Unicode", function() {
39193919
wideCharStr += String.fromCharCode(0xD835, 0xDC00); // bold A
39203920
wideCharStr += String.fromCharCode(0xD835, 0xDC68); // bold italic A
39213921
wideCharStr += String.fromCharCode(0xD835, 0xDD04); // Fraktur A
3922+
wideCharStr += String.fromCharCode(0xD835, 0xDD6C); // bold Fraktur A
39223923
wideCharStr += String.fromCharCode(0xD835, 0xDD38); // double-struck
39233924
wideCharStr += String.fromCharCode(0xD835, 0xDC9C); // script A
39243925
wideCharStr += String.fromCharCode(0xD835, 0xDDA0); // sans serif A
@@ -3935,6 +3936,7 @@ describe("Unicode", function() {
39353936
wideCharText += String.fromCharCode(0xD835, 0xDC00); // bold A
39363937
wideCharText += String.fromCharCode(0xD835, 0xDC68); // bold italic A
39373938
wideCharText += String.fromCharCode(0xD835, 0xDD04); // Fraktur A
3939+
wideCharStr += String.fromCharCode(0xD835, 0xDD6C); // bold Fraktur A
39383940
wideCharText += String.fromCharCode(0xD835, 0xDD38); // double-struck
39393941
wideCharText += String.fromCharCode(0xD835, 0xDC9C); // script A
39403942
wideCharText += String.fromCharCode(0xD835, 0xDDA0); // sans serif A

0 commit comments

Comments
 (0)