Fix font size not applying on initial load in EPUB viewer

This commit is contained in:
aditya.chandel
2025-06-30 18:33:02 -06:00
committed by Aditya Chandel
parent d5c217d306
commit 0fd5c12fd0
@@ -131,7 +131,6 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
body: { body: {
...baseTheme.body, ...baseTheme.body,
...(this.selectedFontType ? {'font-family': this.selectedFontType} : {}), ...(this.selectedFontType ? {'font-family': this.selectedFontType} : {}),
...(this.fontSize != null ? {'font-size': `${this.fontSize}%`} : {}),
...(this.lineHeight != null ? {'line-height': this.lineHeight} : {}), ...(this.lineHeight != null ? {'line-height': this.lineHeight} : {}),
...(this.letterSpacing != null ? {'letter-spacing': `${this.letterSpacing}em`} : {}), ...(this.letterSpacing != null ? {'letter-spacing': `${this.letterSpacing}em`} : {}),
}, },
@@ -142,6 +141,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
}, },
}; };
this.rendition.themes.override('font-size', `${this.fontSize}%`);
this.rendition.themes.register('custom', combinedTheme); this.rendition.themes.register('custom', combinedTheme);
this.rendition.themes.select('custom'); this.rendition.themes.select('custom');
@@ -214,7 +214,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
updateFontSize(): void { updateFontSize(): void {
if (this.rendition) { if (this.rendition) {
this.rendition.themes.fontSize(`${this.fontSize}%`); this.rendition.themes.override('font-size', `${this.fontSize}%`);
this.updateViewerSetting(); this.updateViewerSetting();
} }
} }