move retrieveBaseFontName and retrieveFontStylesName into retrieveTextFontName (#1300)

This commit is contained in:
Kevin Barabash
2018-05-09 07:00:12 -04:00
committed by ylemkimon
parent 5c159abfbb
commit 43bfaedbc8

View File

@@ -621,14 +621,8 @@ const retrieveTextFontName = function(
fontWeight: string, fontWeight: string,
fontShape: string, fontShape: string,
): string { ): string {
const baseFontName = retrieveBaseFontName(fontFamily);
const fontStylesName = retrieveFontStylesName(fontWeight, fontShape);
return `${baseFontName}-${fontStylesName}`;
};
const retrieveBaseFontName = function(font: string): string {
let baseFontName = ""; let baseFontName = "";
switch (font) { switch (fontFamily) {
case "amsrm": case "amsrm":
baseFontName = "AMS"; baseFontName = "AMS";
break; break;
@@ -642,23 +636,21 @@ const retrieveBaseFontName = function(font: string): string {
baseFontName = "Typewriter"; baseFontName = "Typewriter";
break; break;
default: default:
throw new Error(`Invalid font provided: ${font}`); throw new Error(`Invalid font provided: ${fontFamily}`);
} }
return baseFontName;
};
const retrieveFontStylesName = function( let fontStylesName;
fontWeight?: string, if (fontWeight === "textbf" && fontShape === "textit") {
fontShape?: string, fontStylesName = "BoldItalic";
): string { } else if (fontWeight === "textbf") {
let fontStylesName = ''; fontStylesName = "Bold";
if (fontWeight === "textbf") { } else if (fontWeight === "textit") {
fontStylesName += "Bold"; fontStylesName = "Italic";
} else {
fontStylesName = "Regular";
} }
if (fontShape === "textit") {
fontStylesName += "Italic"; return `${baseFontName}-${fontStylesName}`;
}
return fontStylesName || "Regular";
}; };
// A map of spacing functions to their attributes, like size and corresponding // A map of spacing functions to their attributes, like size and corresponding