diff --git a/spec/config-spec.js b/spec/config-spec.js index a654cd6f..c360a72e 100644 --- a/spec/config-spec.js +++ b/spec/config-spec.js @@ -185,12 +185,20 @@ describe('Call to maximumFontSize', () => { }) }) -describe('Call to fontFamily()', () => { - it('return the same font of the editor', () => { +describe('fontFamily test', () => { + it('uses editor\'s font', () => { + atom.config.set('x-terminal.terminalSettings.useFontEditor', true) + expect(resetConfigDefaults().fontFamily).toBe(atom.config.get('editor.fontFamily')) + }) + + it('uses the font set manually', () => { + atom.config.set('x-terminal.terminalSettings.useFontEditor', false) atom.config.set('editor.fontFamily', 'Cascadia Code PL') expect(resetConfigDefaults().fontFamily).toBe('Cascadia Code PL') }) - it('return \'monospace\' when the editor font is not set', () => { + + it('uses \'monospace\' when the editor font is not set', () => { + atom.config.set('x-terminal.terminalSettings.useFontEditor', false) atom.config.set('editor.fontFamily', '') expect(resetConfigDefaults().fontFamily).toBe('monospace') }) diff --git a/src/config.js b/src/config.js index c49394e6..bdb9bd87 100644 --- a/src/config.js +++ b/src/config.js @@ -39,6 +39,7 @@ export function resetConfigDefaults () { // NOTE: Atom will crash if the font is set below 8. minimumFontSize: 8, maximumFontSize: 100, + useEditorFont: true, fontFamily: atom.config.get('editor.fontFamily') || 'monospace', theme: 'Custom', colorForeground: '#ffffff', diff --git a/src/x-terminal.js b/src/x-terminal.js index 83d4206c..f9267c49 100644 --- a/src/x-terminal.js +++ b/src/x-terminal.js @@ -213,6 +213,13 @@ class XTerminalSingleton { 'x-terminal:copy': () => this.copy(), 'x-terminal:paste': () => this.paste(), }), + + // font config observer + atom.config.observe('x-terminal.terminalSettings.useEditorFont', (useEditorFont) => { + if (useEditorFont) { + atom.config.set('x-terminal.terminalSettings.fontFamily', atom.config.get('editor.fontFamily')) + } + }), ) }