未验证 提交 750390dc 编写于 作者: A Alexandru Dima 提交者: GitHub

Merge pull request #125601 from cpsauer/line-height-multiple

Accept editor line height as multiple of font size
......@@ -2471,13 +2471,14 @@ class EditorInlayHints extends BaseEditorOption<EditorOption.inlayHints, EditorI
//#region lineHeight
class EditorLineHeight extends EditorIntOption<EditorOption.lineHeight> {
class EditorLineHeight extends EditorFloatOption<EditorOption.lineHeight> {
constructor() {
super(
EditorOption.lineHeight, 'lineHeight',
EDITOR_FONT_DEFAULTS.lineHeight, 0, 150,
{ description: nls.localize('lineHeight', "Controls the line height. Use 0 to compute the line height from the font size.") }
EDITOR_FONT_DEFAULTS.lineHeight,
x => EditorFloatOption.clamp(x, 0, 150),
{ markdownDescription: nls.localize('lineHeight', "Controls the line height. \n - Use 0 to automatically compute the line height from the font size.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than 8 will be used as effective values.") }
);
}
......
......@@ -52,8 +52,15 @@ export class BareFontInfo {
*/
private static _create(fontFamily: string, fontWeight: string, fontSize: number, fontFeatureSettings: string, lineHeight: number, letterSpacing: number, zoomLevel: number, pixelRatio: number, ignoreEditorZoom: boolean): BareFontInfo {
if (lineHeight === 0) {
lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
lineHeight = GOLDEN_LINE_HEIGHT_RATIO * fontSize;
} else if (lineHeight < MINIMUM_LINE_HEIGHT) {
// Values too small to be line heights in pixels are probably in ems. Accept them gracefully.
lineHeight = lineHeight * fontSize;
}
// Enforce integer, minimum constraints
lineHeight = Math.round(lineHeight);
if (lineHeight < MINIMUM_LINE_HEIGHT) {
lineHeight = MINIMUM_LINE_HEIGHT;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册