1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Desktop: Make font size consistent between Markdown and Rich Text editors

This commit is contained in:
Laurent Cozic 2021-06-08 20:21:11 +02:00
parent 594084e274
commit a058e09183
2 changed files with 8 additions and 9 deletions

View File

@ -909,7 +909,7 @@ class Setting extends BaseModel {
// Deprecated in favour of windowContentZoomFactor
'style.zoom': { value: 100, type: SettingItemType.Int, public: false, storage: SettingStorage.File, appTypes: ['desktop'], section: 'appearance', label: () => '', minimum: 50, maximum: 500, step: 10 },
'style.editor.fontSize': { value: 13, type: SettingItemType.Int, public: true, storage: SettingStorage.File, appTypes: ['desktop'], section: 'appearance', label: () => _('Editor font size'), minimum: 4, maximum: 50, step: 1 },
'style.editor.fontSize': { value: 15, type: SettingItemType.Int, public: true, storage: SettingStorage.File, appTypes: ['desktop'], section: 'appearance', label: () => _('Editor font size'), minimum: 4, maximum: 50, step: 1 },
'style.editor.fontFamily':
(mobilePlatform) ?
({

View File

@ -52,7 +52,7 @@ const globalStyle: any = {
disabledOpacity: 0.3,
buttonMinWidth: 50,
buttonMinHeight: 30,
editorFontSize: 12,
// editorFontSize: 12,
textAreaLineHeight: 17,
lineHeight: '1.6em',
headerButtonHPadding: 6,
@ -368,23 +368,22 @@ const themeCache_: any = {};
function themeStyle(themeId: number) {
if (!themeId) throw new Error('Theme must be specified');
const zoomRatio = 1;
const cacheKey = themeId;
const cacheKey = `${themeId}_${Setting.value('style.editor.fontSize')}`;
if (themeCache_[cacheKey]) return themeCache_[cacheKey];
// Font size are not theme specific, but they must be referenced
// and computed here to allow them to respond to settings changes
// without the need to restart
const fontSizes: any = {
fontSize: Math.round(12 * zoomRatio),
fontSize: 12,
toolbarIconSize: 18,
};
fontSizes.noteViewerFontSize = Math.round(fontSizes.fontSize * 1.25);
// For consistency, and now that the Markdown editor can use non-monospace
// fonts, we use the same font size everywhere.
fontSizes.noteViewerFontSize = Setting.value('style.editor.fontSize'); // fontSizes.fontSize; //Math.round(fontSizes.fontSize * 1.25);
let output: any = {};
output.zoomRatio = zoomRatio;
// All theme are based on the light style, and just override the
// relevant properties
@ -406,7 +405,7 @@ const cachedStyles_: any = {
// the dependencies of the style change. If the style depends only
// on the theme, a static string can be provided as a cache key.
function buildStyle(cacheKey: any, themeId: number, callback: Function) {
cacheKey = Array.isArray(cacheKey) ? cacheKey.join('_') : cacheKey;
cacheKey = `${Array.isArray(cacheKey) ? cacheKey.join('_') : cacheKey}_${Setting.value('style.editor.fontSize')}`;
// We clear the cache whenever switching themes
if (cachedStyles_.themeId !== themeId) {