diff --git a/apps/mobile/changelog/next.md b/apps/mobile/changelog/next.md index 000f858e3..e59e74d12 100644 --- a/apps/mobile/changelog/next.md +++ b/apps/mobile/changelog/next.md @@ -2,6 +2,8 @@ ## Shiny new things +- Add option for independent content font size and presets + ## Improvements ## No longer broken diff --git a/apps/mobile/src/atoms/settings/ui.ts b/apps/mobile/src/atoms/settings/ui.ts index 343396cb2..59c8c9fe7 100644 --- a/apps/mobile/src/atoms/settings/ui.ts +++ b/apps/mobile/src/atoms/settings/ui.ts @@ -8,6 +8,8 @@ import { createSettingAtom } from "./internal/helper" export interface UISettings extends BaseUISettings { fontScale: number useSystemFontScaling: boolean + useDifferentFontSizeForContent: boolean + mobileContentFontSize: number } export const createDefaultSettings = (): UISettings => ({ ...defaultUISettings, @@ -15,6 +17,8 @@ export const createDefaultSettings = (): UISettings => ({ fontScale: 1, useSystemFontScaling: true, + useDifferentFontSizeForContent: false, + mobileContentFontSize: 16, }) export const { diff --git a/apps/mobile/src/components/native/webview/hooks.ts b/apps/mobile/src/components/native/webview/hooks.ts index 33bbe2639..31bfab0a1 100644 --- a/apps/mobile/src/components/native/webview/hooks.ts +++ b/apps/mobile/src/components/native/webview/hooks.ts @@ -61,12 +61,25 @@ export function useWebViewEntry({ const readerRenderInlineStyle = useUISettingKey("readerRenderInlineStyle") const useSystemFontScaling = useUISettingKey("useSystemFontScaling") const customFontScale = useUISettingKey("fontScale") + const useDifferentFontSizeForContent = useUISettingKey("useDifferentFontSizeForContent") + const mobileContentFontSize = useUISettingKey("mobileContentFontSize") useEffect(() => { const fontScale = useSystemFontScaling ? PixelRatio.getFontScale() : customFontScale WebViewManager.setRootFontSize(fontScale * 16) }, [useSystemFontScaling, customFontScale]) + // Handle content-specific font size + useEffect(() => { + if (useDifferentFontSizeForContent) { + WebViewManager.setRootFontSize(mobileContentFontSize) + } else { + // Reset to use the global font scaling + const fontScale = useSystemFontScaling ? PixelRatio.getFontScale() : customFontScale + WebViewManager.setRootFontSize(fontScale * 16) + } + }, [useDifferentFontSizeForContent, mobileContentFontSize, useSystemFontScaling, customFontScale]) + // Prepare entry data for WebView const entryInWebview = useMemo(() => { if (!entry) return null diff --git a/apps/mobile/src/modules/settings/routes/Appearance.tsx b/apps/mobile/src/modules/settings/routes/Appearance.tsx index 194413062..31b41da5e 100644 --- a/apps/mobile/src/modules/settings/routes/Appearance.tsx +++ b/apps/mobile/src/modules/settings/routes/Appearance.tsx @@ -40,6 +40,31 @@ const fontSizePresets = [ key: "xl", }, ] as const + +// Content font size presets (in px) +const contentFontSizePresets = [ + { + value: 12, + key: "xs", + }, + { + value: 14, + key: "s", + }, + { + value: 16, + key: "m", + }, + { + value: 18, + key: "l", + }, + { + value: 20, + key: "xl", + }, +] as const + export const AppearanceScreen = () => { const { t } = useTranslation("settings") const showUnreadCountViewAndSubscriptionMobile = useUISettingKey( @@ -57,6 +82,8 @@ export const AppearanceScreen = () => { // Font scaling settings const fontScale = useUISettingKey("fontScale") const useSystemFontScaling = useUISettingKey("useSystemFontScaling") + const useDifferentFontSizeForContent = useUISettingKey("useDifferentFontSizeForContent") + const mobileContentFontSize = useUISettingKey("mobileContentFontSize") return ( { /> + + { + setUISetting("useDifferentFontSizeForContent", val) + }} + /> + + {useDifferentFontSizeForContent && ( + + +