未验证 提交 859367d6 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #56429 from andyli/ubuntu_font

override Ubuntu's default integrated terminal font options (#35901)
......@@ -12,7 +12,7 @@ import { IWorkspaceConfigurationService } from 'vs/workbench/services/configurat
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ITerminalConfiguration, ITerminalConfigHelper, ITerminalFont, IShellLaunchConfig, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, TERMINAL_CONFIG_SECTION, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MINIMUM_LETTER_SPACING } from 'vs/workbench/parts/terminal/common/terminal';
import Severity from 'vs/base/common/severity';
import { isFedora } from 'vs/workbench/parts/terminal/node/terminal';
import { isFedora, isUbuntu } from 'vs/workbench/parts/terminal/node/terminal';
import { Terminal as XTermTerminal } from 'vscode-xterm';
import { INotificationService } from 'vs/platform/notification/common/notification';
......@@ -114,15 +114,21 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
const editorConfig = this._configurationService.getValue<IEditorOptions>('editor');
let fontFamily = this.config.fontFamily || editorConfig.fontFamily;
let fontSize = this._toInteger(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
// Work around bad font on Fedora
// Work around bad font on Fedora/Ubuntu
if (!this.config.fontFamily) {
if (isFedora) {
fontFamily = '\'DejaVu Sans Mono\'';
}
if (isUbuntu) {
fontFamily = '\'Ubuntu Mono\'';
// Ubuntu mono is somehow smaller, so set fontSize a bit larger to get the same perceived size.
fontSize = this._toInteger(fontSize + 2, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
}
}
const fontSize = this._toInteger(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
const letterSpacing = this.config.letterSpacing ? Math.max(Math.floor(this.config.letterSpacing), MINIMUM_LETTER_SPACING) : DEFAULT_LETTER_SPACING;
const lineHeight = this.config.lineHeight ? Math.max(this.config.lineHeight, 1) : DEFAULT_LINE_HEIGHT;
......
......@@ -65,11 +65,14 @@ if (platform.isLinux) {
}
readFile(file).then(b => {
const contents = b.toString();
if (contents.indexOf('NAME=Fedora') >= 0) {
if (/NAME="?Fedora"?/.test(contents)) {
isFedora = true;
} else if (/NAME="?Ubuntu"?/.test(contents)) {
isUbuntu = true;
}
});
});
}
export let isFedora = false;
\ No newline at end of file
export let isFedora = false;
export let isUbuntu = false;
\ No newline at end of file
......@@ -6,7 +6,7 @@
import * as assert from 'assert';
import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import { isFedora } from 'vs/workbench/parts/terminal/node/terminal';
import { isFedora, isUbuntu } from 'vs/workbench/parts/terminal/node/terminal';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
suite('Workbench - TerminalConfigHelper', () => {
......@@ -32,6 +32,8 @@ suite('Workbench - TerminalConfigHelper', () => {
configHelper.panelContainer = fixture;
if (isFedora) {
assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\'', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set');
} if (isUbuntu) {
assert.equal(configHelper.getFont().fontFamily, '\'Ubuntu Mono\'', 'Ubuntu should have its font overridden when terminal.integrated.fontFamily not set');
} else {
assert.equal(configHelper.getFont().fontFamily, 'foo', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set');
}
......@@ -65,8 +67,11 @@ suite('Workbench - TerminalConfigHelper', () => {
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it');
if (isUbuntu) {
assert.equal(configHelper.getFont().fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it');
} else {
assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it');
}
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo'
});
......@@ -91,7 +96,11 @@ suite('Workbench - TerminalConfigHelper', () => {
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set');
if (isUbuntu) {
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set');
} else {
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set');
}
});
test('TerminalConfigHelper - getFont lineHeight', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册