diff --git a/ts/src/browser.ts b/ts/src/browser.ts index f4c650d..0e6fc78 100644 --- a/ts/src/browser.ts +++ b/ts/src/browser.ts @@ -218,14 +218,17 @@ function setSectionField(si: number, key: string, val: any) { function setSectionType(si: number, sectionType: string) { const sec = getSectionByIndex(si); if (!sec) return; + const wasElementsSection = sec.sectionType !== MonoDisplay.SectionType.CustomFont; (sec as any).sectionType = MonoDisplay.StringToSectionType[sectionType as MonoDisplay.SectionTypeName]; if ((sec as any).sectionType === MonoDisplay.SectionType.CustomFont) { (sec as any).fontData = new Uint8Array(); delete (sec as any).elements; delete (sec as any).flags; } else { - (sec as any).elements = []; - (sec as any).flags = {}; + if (!wasElementsSection) { + (sec as any).elements = []; + (sec as any).flags = {}; + } delete (sec as any).fontData; if ((sec as any).sectionType === MonoDisplay.SectionType.ElementsTimespan) { const now = BigInt(Math.floor(Date.now() / 1000));