mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
move retrieveBaseFontName and retrieveFontStylesName into retrieveTextFontName (#1300)
This commit is contained in:
committed by
ylemkimon
parent
5c159abfbb
commit
43bfaedbc8
@@ -621,14 +621,8 @@ const retrieveTextFontName = function(
|
||||
fontWeight: string,
|
||||
fontShape: string,
|
||||
): string {
|
||||
const baseFontName = retrieveBaseFontName(fontFamily);
|
||||
const fontStylesName = retrieveFontStylesName(fontWeight, fontShape);
|
||||
return `${baseFontName}-${fontStylesName}`;
|
||||
};
|
||||
|
||||
const retrieveBaseFontName = function(font: string): string {
|
||||
let baseFontName = "";
|
||||
switch (font) {
|
||||
switch (fontFamily) {
|
||||
case "amsrm":
|
||||
baseFontName = "AMS";
|
||||
break;
|
||||
@@ -642,23 +636,21 @@ const retrieveBaseFontName = function(font: string): string {
|
||||
baseFontName = "Typewriter";
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Invalid font provided: ${font}`);
|
||||
throw new Error(`Invalid font provided: ${fontFamily}`);
|
||||
}
|
||||
return baseFontName;
|
||||
};
|
||||
|
||||
const retrieveFontStylesName = function(
|
||||
fontWeight?: string,
|
||||
fontShape?: string,
|
||||
): string {
|
||||
let fontStylesName = '';
|
||||
if (fontWeight === "textbf") {
|
||||
fontStylesName += "Bold";
|
||||
let fontStylesName;
|
||||
if (fontWeight === "textbf" && fontShape === "textit") {
|
||||
fontStylesName = "BoldItalic";
|
||||
} else if (fontWeight === "textbf") {
|
||||
fontStylesName = "Bold";
|
||||
} else if (fontWeight === "textit") {
|
||||
fontStylesName = "Italic";
|
||||
} else {
|
||||
fontStylesName = "Regular";
|
||||
}
|
||||
if (fontShape === "textit") {
|
||||
fontStylesName += "Italic";
|
||||
}
|
||||
return fontStylesName || "Regular";
|
||||
|
||||
return `${baseFontName}-${fontStylesName}`;
|
||||
};
|
||||
|
||||
// A map of spacing functions to their attributes, like size and corresponding
|
||||
|
Reference in New Issue
Block a user