diff --git a/webclient/src/App.js b/webclient/src/App.js index 296a5ab..d134436 100644 --- a/webclient/src/App.js +++ b/webclient/src/App.js @@ -23,6 +23,8 @@ function App() { const [settingsOpen, setSettingsOpen] = useState(false); const defaultBodyFontSize = 1.0; const [bodyFontSize, setBodyFontSize] = useState(Number(localStorage.getItem('bodyFontSize')) || defaultBodyFontSize); + const [bodyFont, setBodyFont] = useState(localStorage.getItem('bodyFont') || 'Sans Serif'); + const [articleFont, setArticleFont] = useState(localStorage.getItem('articleFont') || 'Apparatus SIL'); const updateCache = useCallback((key, value) => { cache.current[key] = value; @@ -48,6 +50,16 @@ function App() { localStorage.setItem('theme', 'red'); }; + const changeBodyFont = (font) => { + setBodyFont(font); + localStorage.setItem('bodyFont', font); + }; + + const changeArticleFont = (font) => { + setArticleFont(font); + localStorage.setItem('articleFont', font); + }; + const changeBodyFontSize = (amount) => { const newSize = bodyFontSize + amount; setBodyFontSize(parseFloat(newSize.toFixed(2))); @@ -112,6 +124,27 @@ function App() { document.documentElement.style.fontSize = `${bodyFontSize}rem`; }, [bodyFontSize]); + const fontMap = { + 'Sans Serif': 'sans-serif', + 'Serif': 'serif', + 'Apparatus SIL': "'Apparatus SIL', sans-serif" + }; + + useEffect(() => { + document.body.style.fontFamily = fontMap[bodyFont]; + }, [bodyFont]); + + useEffect(() => { + const styleId = 'article-font-family-style'; + let style = document.getElementById(styleId); + if (!style) { + style = document.createElement('style'); + style.id = styleId; + document.head.appendChild(style); + } + style.innerHTML = `.story-text { font-family: ${fontMap[articleFont]} !important; }`; + }, [articleFont]); + const fullScreenAvailable = document.fullscreenEnabled || document.mozFullscreenEnabled || @@ -138,6 +171,36 @@ function App() { +