You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-20 23:30:05 +02:00
Mobile: Custom mobile editor font (#1797)
* Make editor font "Menlo" * Add .vscode/* to .gitignore * Add "editor font" config UI * Render "editor font" chosen in config * Add shim.mobilePlatform() * Use style.editor.fontFamily rather than editorFont * Add default font option * Fixed for Android
This commit is contained in:
committed by
Laurent Cozic
parent
fe9a037cf9
commit
4ba4910a9c
@@ -98,9 +98,25 @@ function addExtraStyles(style) {
|
||||
return style;
|
||||
}
|
||||
|
||||
function editorFont(fontId) {
|
||||
// IMPORTANT: The font mapping must match the one in Setting.js
|
||||
const fonts = {
|
||||
[Setting.FONT_DEFAULT]: null,
|
||||
[Setting.FONT_MENLO]: 'Menlo',
|
||||
[Setting.FONT_COURIER_NEW]: 'Courier New',
|
||||
[Setting.FONT_AVENIR]: 'Avenir',
|
||||
[Setting.FONT_MONOSPACE]: 'monospace',
|
||||
};
|
||||
if (!fontId) {
|
||||
console.warn('Editor font not set! Falling back to default font."');
|
||||
fontId = Setting.FONT_DEFAULT;
|
||||
}
|
||||
return fonts[fontId];
|
||||
}
|
||||
|
||||
function themeStyle(theme) {
|
||||
if (!theme) {
|
||||
console.warn('Theme not set!! Defaulting to Light theme');
|
||||
console.warn('Theme not set! Defaulting to Light theme.');
|
||||
theme = Setting.THEME_LIGHT;
|
||||
}
|
||||
|
||||
@@ -140,4 +156,4 @@ function themeStyle(theme) {
|
||||
return addExtraStyles(themeCache_[theme]);
|
||||
}
|
||||
|
||||
module.exports = { globalStyle, themeStyle };
|
||||
module.exports = { globalStyle, themeStyle, editorFont };
|
||||
|
||||
@@ -24,7 +24,7 @@ const { reg } = require('lib/registry.js');
|
||||
const { shim } = require('lib/shim.js');
|
||||
const ResourceFetcher = require('lib/services/ResourceFetcher');
|
||||
const { BaseScreenComponent } = require('lib/components/base-screen.js');
|
||||
const { themeStyle } = require('lib/components/global-style.js');
|
||||
const { themeStyle, editorFont } = require('lib/components/global-style.js');
|
||||
const { dialogs } = require('lib/dialogs.js');
|
||||
const DialogBox = require('react-native-dialogbox').default;
|
||||
const { NoteBodyViewer } = require('lib/components/note-body-viewer.js');
|
||||
@@ -209,6 +209,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
color: theme.color,
|
||||
backgroundColor: theme.backgroundColor,
|
||||
fontSize: theme.fontSize,
|
||||
fontFamily: editorFont(this.props.editorFont),
|
||||
},
|
||||
noteBodyViewer: {
|
||||
flex: 1,
|
||||
@@ -916,6 +917,7 @@ const NoteScreen = connect(state => {
|
||||
folders: state.folders,
|
||||
searchQuery: state.searchQuery,
|
||||
theme: state.settings.theme,
|
||||
editorFont: [state.settings['style.editor.fontFamily']],
|
||||
ftsEnabled: state.settings['db.ftsEnabled'],
|
||||
sharedData: state.sharedData,
|
||||
showSideMenu: state.showSideMenu,
|
||||
|
||||
Reference in New Issue
Block a user