Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override Ubuntu's default integrated terminal font options (#35901) #56429

Merged
merged 2 commits into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;

Expand Down
7 changes: 5 additions & 2 deletions src/vs/workbench/parts/terminal/node/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
export let isFedora = false;
export let isUbuntu = false;
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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');
}
Expand Down Expand Up @@ -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'
});
Expand All @@ -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 () {
Expand Down