mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-20 10:08:44 +00:00
feat: Support bold Fraktur (#3777)
* feat: Support bold Fraktur * Evade wideCharacterFont() when inapplicable * Avoid creating array when uneccesary --------- Co-authored-by: Erik Demaine <edemaine@mit.edu>
This commit is contained in:
@@ -205,7 +205,8 @@ Math-mode Unicode (sub|super)script characters will render as if you had written
|
|||||||
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
| Italic | $\text{𝐴-𝑍 𝑎-𝑧}$ | Sans serif | $\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}$
|
||||||
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
| Bold Italic | $\text{𝑨-𝒁 𝒂-𝒛}$ | Sans serif bold | $\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}$
|
||||||
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
| Script | $\text{𝒜-𝒵}$ | Sans serif italic | $\text{𝘈-𝘡 𝘢-𝘻}$
|
||||||
| Fractur | $\text{𝔄-}ℨ\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
| Fractur | $\text{𝔄-ℨ}\text{ 𝔞-𝔷}$| Monospace | $\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}$
|
||||||
|
| Bold Fractur | $\text{𝕬-𝖅}\text{𝖆-𝖟}$ | |
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="katex-hopscotch">
|
<div class="katex-hopscotch">
|
||||||
|
@@ -165,9 +165,13 @@ const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
|
|||||||
// Math mode or Old font (i.e. \rm)
|
// Math mode or Old font (i.e. \rm)
|
||||||
const isFont = mode === "math" || (mode === "text" && options.font);
|
const isFont = mode === "math" || (mode === "text" && options.font);
|
||||||
const fontOrFamily = isFont ? options.font : options.fontFamily;
|
const fontOrFamily = isFont ? options.font : options.fontFamily;
|
||||||
|
let wideFontName = "";
|
||||||
|
let wideFontClass = "";
|
||||||
if (text.charCodeAt(0) === 0xD835) {
|
if (text.charCodeAt(0) === 0xD835) {
|
||||||
|
[wideFontName, wideFontClass] = wideCharacterFont(text, mode);
|
||||||
|
}
|
||||||
|
if (wideFontName.length > 0) {
|
||||||
// surrogate pairs get special treatment
|
// surrogate pairs get special treatment
|
||||||
const [wideFontName, wideFontClass] = wideCharacterFont(text, mode);
|
|
||||||
return makeSymbol(text, wideFontName, mode, options,
|
return makeSymbol(text, wideFontName, mode, options,
|
||||||
classes.concat(wideFontClass));
|
classes.concat(wideFontClass));
|
||||||
} else if (fontOrFamily) {
|
} else if (fontOrFamily) {
|
||||||
|
@@ -129,6 +129,12 @@
|
|||||||
font-family: KaTeX_Fraktur;
|
font-family: KaTeX_Fraktur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mathboldfrak,
|
||||||
|
.textboldfrak {
|
||||||
|
font-family: KaTeX_Fraktur;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.mathtt {
|
.mathtt {
|
||||||
font-family: KaTeX_Typewriter;
|
font-family: KaTeX_Typewriter;
|
||||||
}
|
}
|
||||||
|
@@ -816,6 +816,10 @@ for (let i = 0; i < letters.length; i++) {
|
|||||||
defineSymbol(math, main, mathord, ch, wideChar);
|
defineSymbol(math, main, mathord, ch, wideChar);
|
||||||
defineSymbol(text, main, textord, ch, wideChar);
|
defineSymbol(text, main, textord, ch, wideChar);
|
||||||
|
|
||||||
|
wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fractur
|
||||||
|
defineSymbol(math, main, mathord, ch, wideChar);
|
||||||
|
defineSymbol(text, main, textord, ch, wideChar);
|
||||||
|
|
||||||
wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif
|
wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif
|
||||||
defineSymbol(math, main, mathord, ch, wideChar);
|
defineSymbol(math, main, mathord, ch, wideChar);
|
||||||
defineSymbol(text, main, textord, ch, wideChar);
|
defineSymbol(text, main, textord, ch, wideChar);
|
||||||
|
@@ -45,8 +45,9 @@ const wideLatinLetterData: Array<[string, string, string]> = [
|
|||||||
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
||||||
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
||||||
|
|
||||||
["", "", ""], // A-Z bold Fraktur No font metrics
|
// Note that we are using a bold font, but font metrics for regular Fraktur.
|
||||||
["", "", ""], // a-z bold Fraktur. No font.
|
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur
|
||||||
|
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur
|
||||||
|
|
||||||
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
||||||
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
||||||
|
@@ -3919,6 +3919,7 @@ describe("Unicode", function() {
|
|||||||
wideCharStr += String.fromCharCode(0xD835, 0xDC00); // bold A
|
wideCharStr += String.fromCharCode(0xD835, 0xDC00); // bold A
|
||||||
wideCharStr += String.fromCharCode(0xD835, 0xDC68); // bold italic A
|
wideCharStr += String.fromCharCode(0xD835, 0xDC68); // bold italic A
|
||||||
wideCharStr += String.fromCharCode(0xD835, 0xDD04); // Fraktur A
|
wideCharStr += String.fromCharCode(0xD835, 0xDD04); // Fraktur A
|
||||||
|
wideCharStr += String.fromCharCode(0xD835, 0xDD6C); // bold Fraktur A
|
||||||
wideCharStr += String.fromCharCode(0xD835, 0xDD38); // double-struck
|
wideCharStr += String.fromCharCode(0xD835, 0xDD38); // double-struck
|
||||||
wideCharStr += String.fromCharCode(0xD835, 0xDC9C); // script A
|
wideCharStr += String.fromCharCode(0xD835, 0xDC9C); // script A
|
||||||
wideCharStr += String.fromCharCode(0xD835, 0xDDA0); // sans serif A
|
wideCharStr += String.fromCharCode(0xD835, 0xDDA0); // sans serif A
|
||||||
@@ -3935,6 +3936,7 @@ describe("Unicode", function() {
|
|||||||
wideCharText += String.fromCharCode(0xD835, 0xDC00); // bold A
|
wideCharText += String.fromCharCode(0xD835, 0xDC00); // bold A
|
||||||
wideCharText += String.fromCharCode(0xD835, 0xDC68); // bold italic A
|
wideCharText += String.fromCharCode(0xD835, 0xDC68); // bold italic A
|
||||||
wideCharText += String.fromCharCode(0xD835, 0xDD04); // Fraktur A
|
wideCharText += String.fromCharCode(0xD835, 0xDD04); // Fraktur A
|
||||||
|
wideCharStr += String.fromCharCode(0xD835, 0xDD6C); // bold Fraktur A
|
||||||
wideCharText += String.fromCharCode(0xD835, 0xDD38); // double-struck
|
wideCharText += String.fromCharCode(0xD835, 0xDD38); // double-struck
|
||||||
wideCharText += String.fromCharCode(0xD835, 0xDC9C); // script A
|
wideCharText += String.fromCharCode(0xD835, 0xDC9C); // script A
|
||||||
wideCharText += String.fromCharCode(0xD835, 0xDDA0); // sans serif A
|
wideCharText += String.fromCharCode(0xD835, 0xDDA0); // sans serif A
|
||||||
|
Reference in New Issue
Block a user