diff --git a/apps/main/src/window.ts b/apps/main/src/window.ts index 47282cdc6..5a0aae4a4 100644 --- a/apps/main/src/window.ts +++ b/apps/main/src/window.ts @@ -7,7 +7,7 @@ import { IMAGE_PROXY_URL, imageRefererMatches } from "@follow/shared/image" import type { BrowserWindowConstructorOptions } from "electron" import { BrowserWindow, screen, shell } from "electron" -import { isDev, isMacOS, isWindows11 } from "./env" +import { isDev, isMacOS, isWindows, isWindows11 } from "./env" import { getIconPath } from "./helper" import { registerContextMenu } from "./lib/context-menu" import { store } from "./lib/store" @@ -135,6 +135,28 @@ export function createWindow( }, }) }) + + if (isWindows) { + // Change the default font-family and font-size of the devtools. + // Make it consistent with Chrome on Windows, instead of SimSun. + // ref: [[Feature Request]: Add possibility to change DevTools font · Issue #42055 · electron/electron](https://github.com/electron/electron/issues/42055) + window.webContents.on("devtools-opened", () => { + const css = ` + :root { + --source-code-font-family: consolas; // For code such as Elements panel + --source-code-font-size: 13px; + --monospace-font-family: consolas; // For sidebar such as Event Listener Panel + --monospace-font-size: 13px; + }` + window.webContents.devToolsWebContents?.executeJavaScript(` + const overriddenStyle = document.createElement('style'); + overriddenStyle.innerHTML = '${css.replaceAll("\n", " ")}'; + document.body.append(overriddenStyle); + document.body.classList.remove('platform-windows'); + `) + }) + } + registerContextMenu(window) return window