Repository: microsoft/vscode (TypeScript)
Date: 2022-12-06 21:24:31+00:00
Task type: Bug Fix

Issue:
[safari] Ugly fallback font for terminal
* use safari
* use "Fira Code" as editor font (which is picked up by the terminal by default)
* tunnel onto a machine
* run a task or command in the terminal
* 🙈 the fallback font is ugly

<img width="1792" alt="Screenshot 2022-11-18 at 12 18 26" src="https://user-images.githubusercontent.com/1794099/202693482-27d6484c-ff57-441c-9884-6096cd0de1fc.png">



Issue discussion:

Solution patch:
diff --git a/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts b/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
--- a/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
+++ b/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
@@ -161,16 +161,19 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
 		// Work around bad font on Fedora/Ubuntu
 		if (!this.config.fontFamily) {
 			if (this._linuxDistro === LinuxDistro.Fedora) {
-				fontFamily = '\'DejaVu Sans Mono\', monospace';
+				fontFamily = '\'DejaVu Sans Mono\'';
 			}
 			if (this._linuxDistro === LinuxDistro.Ubuntu) {
-				fontFamily = '\'Ubuntu Mono\', monospace';
+				fontFamily = '\'Ubuntu Mono\'';
 
 				// Ubuntu mono is somehow smaller, so set fontSize a bit larger to get the same perceived size.
 				fontSize = this._clampInt(fontSize + 2, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
 			}
 		}
 
+		// Always fallback to monospace, otherwise a proportional font may become the default
+		fontFamily += ', monospace';
+
 		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;
 


Test patch:
diff --git a/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts b/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts
--- a/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts
+++ b/src/vs/workbench/contrib/terminal/test/browser/terminalConfigHelper.test.ts
@@ -34,7 +34,7 @@ suite('Workbench - TerminalConfigHelper', function () {
 		});
 		const configHelper = new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!);
 		configHelper.panelContainer = fixture;
-		assert.strictEqual(configHelper.getFont().fontFamily, 'bar', 'terminal.integrated.fontFamily should be selected over editor.fontFamily');
+		assert.strictEqual(configHelper.getFont().fontFamily, 'bar, monospace', 'terminal.integrated.fontFamily should be selected over editor.fontFamily');
 	});
 
 	test('TerminalConfigHelper - getFont fontFamily (Linux Fedora)', () => {
@@ -66,7 +66,7 @@ suite('Workbench - TerminalConfigHelper', function () {
 		});
 		const configHelper = new TestTerminalConfigHelper(configurationService, null!, null!, null!, null!);
 		configHelper.panelContainer = fixture;
-		assert.strictEqual(configHelper.getFont().fontFamily, 'foo', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set');
+		assert.strictEqual(configHelper.getFont().fontFamily, 'foo, monospace', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set');
 	});
 
 	test('TerminalConfigHelper - getFont fontSize 10', () => {