mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge pull request #125601 from cpsauer/line-height-multiple
Accept editor line height as multiple of font size
This commit is contained in:
commit
750390dcd3
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue