diff options
Diffstat (limited to 'src/new_fields/RichTextUtils.ts')
-rw-r--r-- | src/new_fields/RichTextUtils.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/new_fields/RichTextUtils.ts b/src/new_fields/RichTextUtils.ts index 9b6e55948..8f4ab58eb 100644 --- a/src/new_fields/RichTextUtils.ts +++ b/src/new_fields/RichTextUtils.ts @@ -317,6 +317,10 @@ export namespace RichTextUtils { attributes.fontSize = value.magnitude; } + if (converted === "weightedFontFamily") { + converted = ImportFontFamilyMapping.get(value.fontFamily) || "timesNewRoman"; + } + let mapped = schema.marks[converted]; if (!mapped) { alert(`No mapping found for ${converted}!`); @@ -342,7 +346,7 @@ export namespace RichTextUtils { ["impact", "weightedFontFamily"] ]); - const FontFamilyMapping = new Map<string, string>([ + const ExportFontFamilyMapping = new Map<string, string>([ ["timesNewRoman", "Times New Roman"], ["arial", "Arial"], ["georgia", "Georgia"], @@ -351,6 +355,15 @@ export namespace RichTextUtils { ["impact", "Impact"] ]); + const ImportFontFamilyMapping = new Map<string, string>([ + ["Times New Roman", "timesNewRoman"], + ["Arial", "arial"], + ["Georgia", "georgia"], + ["Comic Sans MS", "comicSans"], + ["Tahoma", "tahoma"], + ["Impact", "impact"] + ]); + const ignored = ["user_mark"]; const marksToStyle = async (nodes: (Node<any> | null)[]): Promise<docs_v1.Schema$Request[]> => { @@ -408,7 +421,7 @@ export namespace RichTextUtils { value = fromHex(attrs.color); break; case "weightedFontFamily": - value = { fontFamily: FontFamilyMapping.get(markName) }; + value = { fontFamily: ExportFontFamilyMapping.get(markName) }; } let matches: RegExpExecArray | null; if ((matches = /p(\d+)/g.exec(markName)) !== null) { |