diff --git a/src/renderer/components/+preferences/terminal.tsx b/src/renderer/components/+preferences/terminal.tsx index 995b82e32d..e12c702764 100644 --- a/src/renderer/components/+preferences/terminal.tsx +++ b/src/renderer/components/+preferences/terminal.tsx @@ -23,11 +23,12 @@ interface Dependencies { defaultShell: string; } -const NonInjectedTerminal = observer(({ - userStore, - themeStore, - defaultShell, -}: Dependencies) => { +const NonInjectedTerminal = observer(( + { + userStore, + themeStore, + defaultShell, + }: Dependencies) => { const themeOptions = [ { value: "", // TODO: replace with a sentinal value that isn't string (and serialize it differently) @@ -39,6 +40,12 @@ const NonInjectedTerminal = observer(({ })), ]; + // fonts must be declared in `fonts.scss` and at `template.html` (if early-preloading required) + const supportedCustomFonts = [ + "RobotoMono", "Anonymous Pro", "IBM Plex Mono", "JetBrains Mono", "Red Hat Mono", + "Source Code Pro", "Space Mono", "Ubuntu Mono", + ]; + return (
@@ -88,11 +95,11 @@ const NonInjectedTerminal = observer(({
- userStore.terminalConfig.fontFamily = value} + options={supportedCustomFonts} + onChange={opt => userStore.terminalConfig.fontFamily = opt?.value ?? supportedCustomFonts[0]} />
diff --git a/src/renderer/components/dock/terminal/terminal.ts b/src/renderer/components/dock/terminal/terminal.ts index 991e7e232e..c39b9e31be 100644 --- a/src/renderer/components/dock/terminal/terminal.ts +++ b/src/renderer/components/dock/terminal/terminal.ts @@ -74,7 +74,7 @@ export class Terminal { constructor(protected readonly dependencies: TerminalDependencies, { tabId, - api + api, }: TerminalArguments) { this.tabId = tabId; this.api = api; @@ -110,8 +110,8 @@ export class Terminal { }, { fireImmediately: true, }), - reaction(() => this.fontSize, this.setFontSize, { fireImmediately: true, }), - reaction(() => this.fontFamily, this.setFontFamily, { fireImmediately: true, }), + reaction(() => this.fontSize, this.setFontSize, { fireImmediately: true }), + reaction(() => this.fontFamily, this.setFontFamily, { fireImmediately: true }), () => onDataHandler.dispose(), () => this.fitAddon.dispose(), () => this.api.removeAllListeners(), @@ -203,14 +203,18 @@ export class Terminal { } }; - setFontSize = (size: number) => { - this.xterm.options.fontSize = size; + setFontSize = (fontSize: number) => { + logger.info(`[TERMINAL]: set fontSize to ${fontSize}`); + + this.xterm.options.fontSize = fontSize; }; setFontFamily = (fontFamily: string) => { + logger.info(`[TERMINAL]: set fontFamily to ${fontFamily}`); + this.xterm.options.fontFamily = fontFamily; - // provide access to current terminal-font in css in :root {} + // provide css-variable within `:root {}` document.documentElement.style.setProperty("--font-terminal", fontFamily); }; diff --git a/src/renderer/components/fonts.scss b/src/renderer/components/fonts.scss index 96f806c910..d4a890342e 100644 --- a/src/renderer/components/fonts.scss +++ b/src/renderer/components/fonts.scss @@ -16,44 +16,44 @@ // Terminal fonts (monospaced) // Source: https://fonts.google.com/?category=Monospace @font-face { - font-family: "Anonymous Pro", monospace; + font-family: "Anonymous Pro"; src: local("Anonymous Pro"), url("../fonts/AnonymousPro-Regular.ttf") format("truetype"); font-display: block; } @font-face { - font-family: "IBM Plex Mono", monospace; + font-family: "IBM Plex Mono"; src: local("IBM Plex Mono"), url("../fonts/IBMPlexMono-Regular.ttf") format("truetype"); font-display: block; } @font-face { - font-family: "JetBrains Mono", monospace; + font-family: "JetBrains Mono"; src: local("JetBrains Mono"), url("../fonts/JetBrainsMono-Regular.ttf") format("truetype"); font-display: block; } @font-face { - font-family: "Red Hat Mono", monospace; + font-family: "Red Hat Mono"; src: local("Red Hat Mono"), url("../fonts/RedHatMono-Regular.ttf") format("truetype"); font-display: block; } @font-face { - font-family: "Source Code Pro", monospace; + font-family: "Source Code Pro"; src: local("Source Code Pro"), url("../fonts/SourceCodePro-Regular.ttf") format("truetype"); font-display: block; } @font-face { - font-family: "Space Mono", monospace; + font-family: "Space Mono"; src: local("Space Mono"), url("../fonts/SpaceMono-Regular.ttf") format("truetype"); font-display: block; } @font-face { - font-family: "Ubuntu Mono", monospace; + font-family: "Ubuntu Mono"; src: local("Ubuntu Mono"), url("../fonts/UbuntuMono-Regular.ttf") format("truetype"); font-display: block; } @@ -62,7 +62,7 @@ // RobotoMono Windows Compatible for using in terminal // https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/RobotoMono @font-face { - font-family: "RobotoMono", monospace; + font-family: "RobotoMono"; src: local("RobotoMono"), url("../fonts/roboto-mono-nerd.ttf") format("truetype"); font-display: block; } diff --git a/src/renderer/template.html b/src/renderer/template.html index 22af34b547..5860854d9a 100755 --- a/src/renderer/template.html +++ b/src/renderer/template.html @@ -4,14 +4,11 @@ -
-
-
- + @@ -19,6 +16,6 @@
- +