add custom font size option

This commit is contained in:
bunnybeam 2025-08-08 17:03:56 +01:00
parent 0f6413d4b9
commit 55a0e11366
No known key found for this signature in database
6 changed files with 33 additions and 2 deletions

View file

@ -129,7 +129,12 @@
const fontSize = localStorage.getItem('fontSize');
if (fontSize) {
document.documentElement.classList.add('f-' + fontSize);
if (fontSize === "custom") {
const customFontSize = localStorage.getItem('customFontSize');
document.documentElement.style.setProperty('font-size', `${customFontSize}px`);
} else {
document.documentElement.classList.add('f-' + fontSize);
}
}
const cornerRadius = localStorage.getItem('cornerRadius');

View file

@ -20,6 +20,7 @@ export type Keys = (
'colorScheme' |
'useSystemFont' |
'fontSize' |
'customFontSize' |
'cornerRadius' |
'ui' |
'ui_temp' |

View file

@ -700,9 +700,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="1"><span style="font-size: 15px;">Aa</span></option>
<option value="2"><span style="font-size: 16px;">Aa</span></option>
<option value="3"><span style="font-size: 17px;">Aa</span></option>
<option value="custom"><span style="font-size: 14px;">Custom</span></option>
</MkRadios>
</SearchMarker>
<SearchMarker :keywords="['font', 'size']">
<MkInput v-model="customFontSize" :min="12" :max="48" type="number" :step="1" :manualSave="true" :disabled="fontSize !== 'custom'">
<template #label><SearchLabel>{{ i18n.ts.customFontSize }}</SearchLabel></template>
</MkInput>
</SearchMarker>
<SearchMarker :keywords="['font', 'system', 'native']">
<MkSwitch v-model="useSystemFont">
<template #label><SearchLabel>{{ i18n.ts.useSystemFont }}</SearchLabel></template>
@ -1081,6 +1088,7 @@ const defaultCW = ref($i.defaultCW);
const defaultCWPriority = ref($i.defaultCWPriority);
const lang = prefer.model('lang');
const fontSize = prefer.model('fontSize');
const customFontSize = prefer.model('customFontSize');
const useSystemFont = prefer.model('useSystemFont');
const cornerRadius = prefer.model('cornerRadius');
const trustedDomains = prefer.model(

View file

@ -497,7 +497,18 @@ export const PREF_DEF = {
miLocalStorage.removeItem('fontSize');
}
},
} as Pref<'0' | '1' | '2' | '3'>,
} as Pref<'0' | '1' | '2' | '3' | 'custom'>,
customFontSize: {
default: 14,
needsReload: true,
onSet: customFontSize => {
if (customFontSize) {
miLocalStorage.setItem('customFontSize', customFontSize.toString());
} else {
miLocalStorage.removeItem('customFontSize');
}
},
} as Pref<number>,
useSystemFont: {
default: false,
needsReload: true,