|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import type {Mode} from "./types"; |
|
import ParseError from "./ParseError"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const wideLatinLetterData: Array<[string, string, string]> = [ |
|
["mathbf", "textbf", "Main-Bold"], |
|
["mathbf", "textbf", "Main-Bold"], |
|
|
|
["mathnormal", "textit", "Math-Italic"], |
|
["mathnormal", "textit", "Math-Italic"], |
|
|
|
["boldsymbol", "boldsymbol", "Main-BoldItalic"], |
|
["boldsymbol", "boldsymbol", "Main-BoldItalic"], |
|
|
|
|
|
|
|
["mathscr", "textscr", "Script-Regular"], |
|
["", "", ""], |
|
|
|
["", "", ""], |
|
["", "", ""], |
|
|
|
["mathfrak", "textfrak", "Fraktur-Regular"], |
|
["mathfrak", "textfrak", "Fraktur-Regular"], |
|
|
|
["mathbb", "textbb", "AMS-Regular"], |
|
["mathbb", "textbb", "AMS-Regular"], |
|
|
|
|
|
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], |
|
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], |
|
|
|
["mathsf", "textsf", "SansSerif-Regular"], |
|
["mathsf", "textsf", "SansSerif-Regular"], |
|
|
|
["mathboldsf", "textboldsf", "SansSerif-Bold"], |
|
["mathboldsf", "textboldsf", "SansSerif-Bold"], |
|
|
|
["mathitsf", "textitsf", "SansSerif-Italic"], |
|
["mathitsf", "textitsf", "SansSerif-Italic"], |
|
|
|
["", "", ""], |
|
["", "", ""], |
|
|
|
["mathtt", "texttt", "Typewriter-Regular"], |
|
["mathtt", "texttt", "Typewriter-Regular"], |
|
]; |
|
|
|
const wideNumeralData: Array<[string, string, string]> = [ |
|
["mathbf", "textbf", "Main-Bold"], |
|
["", "", ""], |
|
["mathsf", "textsf", "SansSerif-Regular"], |
|
["mathboldsf", "textboldsf", "SansSerif-Bold"], |
|
["mathtt", "texttt", "Typewriter-Regular"], |
|
]; |
|
|
|
export const wideCharacterFont = function( |
|
wideChar: string, |
|
mode: Mode, |
|
): [string, string] { |
|
|
|
|
|
const H = wideChar.charCodeAt(0); |
|
const L = wideChar.charCodeAt(1); |
|
const codePoint = ((H - 0xD800) * 0x400) + (L - 0xDC00) + 0x10000; |
|
|
|
const j = mode === "math" ? 0 : 1; |
|
|
|
if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { |
|
|
|
|
|
const i = Math.floor((codePoint - 0x1D400) / 26); |
|
return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; |
|
|
|
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { |
|
|
|
const i = Math.floor((codePoint - 0x1D7CE) / 10); |
|
return [wideNumeralData[i][2], wideNumeralData[i][j]]; |
|
|
|
} else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { |
|
|
|
return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; |
|
|
|
} else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { |
|
|
|
return ["", ""]; |
|
|
|
} else { |
|
|
|
throw new ParseError("Unsupported character: " + wideChar); |
|
} |
|
}; |
|
|