diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 0c7358aeeb32e..1a03051470337 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -1256,5 +1256,11 @@ configurationRegistry.registerConfiguration({ type: 'boolean', default: false }, + [NotebookSetting.markupFontFamily]: { + markdownDescription: nls.localize('notebook.markupFontFamily', "Controls the font family of rendered markup in notebooks. When left blank, this will fall back to the default workbench font family."), + type: 'string', + default: '', + tags: ['notebookLayout'] + }, } }); diff --git a/src/vs/workbench/contrib/notebook/browser/notebookOptions.ts b/src/vs/workbench/contrib/notebook/browser/notebookOptions.ts index 634b9cdb5bb1a..159928cf81b2a 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookOptions.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookOptions.ts @@ -53,6 +53,7 @@ export interface NotebookDisplayOptions { // TODO @Yoyokrazy rename to a more ge 'editor.tabSize': number; 'editor.insertSpaces': boolean; }> | undefined; + markupFontFamily: string; } export interface NotebookLayoutConfiguration { @@ -108,6 +109,7 @@ export interface NotebookOptionsChangeEvent { readonly outputLinkifyFilePaths?: boolean; readonly minimalError?: boolean; readonly readonly?: boolean; + readonly markupFontFamily?: boolean; } const defaultConfigConstants = Object.freeze({ @@ -213,6 +215,7 @@ export class NotebookOptions extends Disposable { const outputLineLimit = this.configurationService.getValue(NotebookSetting.textOutputLineLimit) ?? 30; const linkifyFilePaths = this.configurationService.getValue(NotebookSetting.LinkifyOutputFilePaths) ?? true; const minimalErrors = this.configurationService.getValue(NotebookSetting.minimalErrorRendering); + const markupFontFamily = this.configurationService.getValue(NotebookSetting.markupFontFamily); const editorTopPadding = this._computeEditorTopPadding(); @@ -259,7 +262,8 @@ export class NotebookOptions extends Disposable { outputWordWrap: outputWordWrap, outputLineLimit: outputLineLimit, outputLinkifyFilePaths: linkifyFilePaths, - outputMinimalError: minimalErrors + outputMinimalError: minimalErrors, + markupFontFamily }; this._register(this.configurationService.onDidChangeConfiguration(e => { @@ -426,6 +430,7 @@ export class NotebookOptions extends Disposable { const outputWordWrap = e.affectsConfiguration(NotebookSetting.outputWordWrap); const outputLinkifyFilePaths = e.affectsConfiguration(NotebookSetting.LinkifyOutputFilePaths); const minimalError = e.affectsConfiguration(NotebookSetting.minimalErrorRendering); + const markupFontFamily = e.affectsConfiguration(NotebookSetting.markupFontFamily); if ( !cellStatusBarVisibility @@ -454,7 +459,8 @@ export class NotebookOptions extends Disposable { && !outputScrolling && !outputWordWrap && !outputLinkifyFilePaths - && !minimalError) { + && !minimalError + && !markupFontFamily) { return; } @@ -569,6 +575,10 @@ export class NotebookOptions extends Disposable { configuration.outputMinimalError = this.configurationService.getValue(NotebookSetting.minimalErrorRendering); } + if (markupFontFamily) { + configuration.markupFontFamily = this.configurationService.getValue(NotebookSetting.markupFontFamily); + } + this._layoutConfiguration = Object.freeze(configuration); // trigger event @@ -599,7 +609,8 @@ export class NotebookOptions extends Disposable { outputScrolling, outputWordWrap, outputLinkifyFilePaths, - minimalError + minimalError, + markupFontFamily }); } @@ -814,7 +825,8 @@ export class NotebookOptions extends Disposable { outputWordWrap: this._layoutConfiguration.outputWordWrap, outputLineLimit: this._layoutConfiguration.outputLineLimit, outputLinkifyFilePaths: this._layoutConfiguration.outputLinkifyFilePaths, - minimalError: this._layoutConfiguration.outputMinimalError + minimalError: this._layoutConfiguration.outputMinimalError, + markupFontFamily: this._layoutConfiguration.markupFontFamily }; } @@ -838,7 +850,8 @@ export class NotebookOptions extends Disposable { outputWordWrap: this._layoutConfiguration.outputWordWrap, outputLineLimit: this._layoutConfiguration.outputLineLimit, outputLinkifyFilePaths: false, - minimalError: false + minimalError: false, + markupFontFamily: this._layoutConfiguration.markupFontFamily }; } diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts index 8eb293b41bac3..966a7e6991736 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts @@ -121,6 +121,7 @@ interface BacklayerWebviewOptions { readonly outputLineLimit: number; readonly outputLinkifyFilePaths: boolean; readonly minimalError: boolean; + readonly markupFontFamily: string; } @@ -281,6 +282,7 @@ export class BackLayerWebView extends Themable { key: 'notebook.error.rendererFallbacksExhausted', comment: ['$0 is a placeholder for the mime type'] }, "Could not render content for '$0'"), + 'notebook-markup-font-family': this.options.markupFontFamily, }; } @@ -370,6 +372,7 @@ export class BackLayerWebView extends Themable { font-size: var(--notebook-markup-font-size); line-height: var(--notebook-markdown-line-height); color: var(--theme-ui-foreground); + font-family: var(--notebook-markup-font-family); } #container div.preview.draggable { diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index e52053da2d711..6fd9ec8fa9ac9 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -1034,6 +1034,7 @@ export const NotebookSetting = { cellFailureDiagnostics: 'notebook.cellFailureDiagnostics', outputBackupSizeLimit: 'notebook.backup.sizeLimit', multiCursor: 'notebook.multiCursor.enabled', + markupFontFamily: 'notebook.markupFontFamily', } as const; export const enum CellStatusbarAlignment {