今天我在新 Mac 上使用 VS Code 时注意到一些“奇怪”的事情。
macOS 中 VS Code 的默认字体大小(以像素为单位)设置为 12。我查看了我的 Windows 和 Linux 机器,发现它们的默认字体大小为 14。有谁知道为什么会有这样的字体大小?基于操作系统的默认字体大小之间的差异?
我做了一些研究,发现显示尺寸并不重要。任何 Mac(13'、14'、16'...)在 VS Code 上的默认字体大小都是 12,而任何 Windows/Linux 机器上的默认字体大小都是 14。
我不是问如何更改 VS Code 上的字体大小,这显然可以通过谷歌研究来查看,我想知道为什么操作系统之间存在如此大的差异,因为我无法在网上找到任何内容.
事情就是这样,因为 VS Code 的维护者就是这样写的。至于为什么这么写,我不知道。
如果您查看 src/vs/editor/common/config/editorOptions.ts,您会看到(至少在撰写本文时):
/**
* @internal
*/
export const EDITOR_FONT_DEFAULTS = {
fontFamily: (
platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY)
),
fontWeight: 'normal',
fontSize: (
platform.isMacintosh ? 12 : 14
),
lineHeight: 0,
letterSpacing: 0,
};
以下是在撰写本文时此文件最新版本的特定行的链接:https://github.com/microsoft/vscode/blob/e1c4a6d7bb4dbd5eeb8332b970d7b934fb325649/src/vs/editor/common/config/editorOptions .ts#L4757.
ed52cdd
之前:“将默认选项值移至editorOptions.ts”,默认值存储在此处的src/vs/editor/common/config/defaultConfig.ts中。如果你查看该提交的 git 责任,你会看到在该提交之前最后更改该行的提交包含了一系列其他更改以这样的方式设置编辑器字体:不需要通过小部件重置(例如查找小部件)#5972,但我无法判断该更改与该问题单有何关系。
我想我的简单侦探工作就到此为止了。为了进一步了解历史,您可能需要与做出这些更改的开发人员实际交谈。
对于交互式会话 API(说实话,不太确定那是什么):
如果您查看 src/vs/workbench/contrib/interactiveSession/browser/interactiveSession.contribution.ts 中的 VS Code 源代码,您会看到(至少在撰写本文时):
// Register configuration
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
id: 'interactiveSessionSidebar',
title: nls.localize('interactiveSessionConfigurationTitle', "Interactive Session"),
type: 'object',
properties: {
'interactiveSession.editor.fontSize': {
type: 'number',
description: nls.localize('interactiveSession.editor.fontSize', "Controls the font size in pixels in Interactive Sessions."),
default: isMacintosh ? 12 : 14,
},
...
}
});
以下是撰写本文时该文件最新版本的特定行的链接:https://github.com/microsoft/vscode/blob/c83f54aefc2dd212c01a42c57c930aa8a13af3a6/src/vs/workbench/contrib/interactiveSession/browser /interactiveSession.contribution.ts#L41.