From 971196d820b658025ec66b689666376e6264b741 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 9 Oct 2017 12:59:36 -0700 Subject: [PATCH] Force DejaVu Sans Mono font in terminal on Fedora Fixes #35644 --- .../parts/terminal/electron-browser/terminal.ts | 17 +++++++++++++++++ .../electron-browser/terminalConfigHelper.ts | 11 ++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index 4601182e9a708..48da053457211 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -8,6 +8,7 @@ import * as cp from 'child_process'; import * as os from 'os'; import * as platform from 'vs/base/common/platform'; import * as processes from 'vs/base/node/processes'; +import { readFile, fileExists } from 'vs/base/node/pfs'; export const TERMINAL_DEFAULT_SHELL_LINUX = !platform.isWindows ? (process.env.SHELL || 'sh') : 'sh'; export const TERMINAL_DEFAULT_SHELL_OSX = !platform.isWindows ? (process.env.SHELL || 'sh') : 'sh'; @@ -21,3 +22,19 @@ export const TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPat export interface ITerminalProcessFactory { create(env: { [key: string]: string }): cp.ChildProcess; } + +if (platform.isLinux) { + fileExists('/etc/os-release').then(exists => { + if (!exists) { + return; + } + readFile('/etc/os-release').then(b => { + const contents = b.toString(); + if (contents.indexOf('NAME=Fedora')) { + isFedora = true; + } + }); + }); +} + +export let isFedora = false; \ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts index 6507587aa9788..b1793339026f8 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts @@ -14,6 +14,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { ITerminalConfiguration, ITerminalConfigHelper, ITerminalFont, IShellLaunchConfig, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY } from 'vs/workbench/parts/terminal/common/terminal'; import { TPromise } from 'vs/base/common/winjs.base'; import Severity from 'vs/base/common/severity'; +import { isFedora } from 'vs/workbench/parts/terminal/electron-browser/terminal'; interface IEditorConfiguration { editor: IEditorOptions; @@ -89,7 +90,15 @@ export class TerminalConfigHelper implements ITerminalConfigHelper { const editorConfig = (config).editor; const terminalConfig = this.config; - const fontFamily = terminalConfig.fontFamily || editorConfig.fontFamily; + let fontFamily = terminalConfig.fontFamily || editorConfig.fontFamily; + + // Work around bad font on Fedora + if (!terminalConfig.fontFamily) { + if (isFedora) { + fontFamily = '\'DejaVu Sans Mono\''; + } + } + let fontSize = this._toInteger(terminalConfig.fontSize, 0); if (fontSize <= 0) { fontSize = EDITOR_FONT_DEFAULTS.fontSize;