Skip to content

Commit 609c4f6

Browse files
committed
Apply fontWeight to font-feature-settings for variable fonts
1 parent 9051021 commit 609c4f6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/vs/base/browser/fastDomNode.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ export class FastDomNode<T extends HTMLElement> {
110110
return;
111111
}
112112
this._fontWeight = fontWeight;
113-
this.domNode.style.fontWeight = this._fontWeight;
113+
if (fontWeight !== 'normal' && fontWeight !== 'bold') {
114+
const fontWeightAsNumber = parseInt(fontWeight, 10);
115+
this.domNode.style.fontVariationSettings = `"wght" ${fontWeightAsNumber}`;
116+
} else {
117+
this.domNode.style.fontWeight = this._fontWeight;
118+
}
114119
}
115120

116121
public setFontSize(_fontSize: number | string): void {

src/vs/editor/browser/config/domFontInfo.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export function applyFontInfo(domNode: FastDomNode<HTMLElement> | HTMLElement, f
1616
domNode.setLetterSpacing(fontInfo.letterSpacing);
1717
} else {
1818
domNode.style.fontFamily = fontInfo.getMassagedFontFamily();
19-
domNode.style.fontWeight = fontInfo.fontWeight;
19+
if (fontInfo.fontWeight !== 'normal' && fontInfo.fontWeight !== 'bold') {
20+
const fontWeightAsNumber = parseInt(fontInfo.fontWeight, 10);
21+
domNode.style.fontWeight = `"wght" ${fontWeightAsNumber}`;
22+
} else {
23+
domNode.style.fontWeight = fontInfo.fontWeight;
24+
}
2025
domNode.style.fontSize = fontInfo.fontSize + 'px';
2126
domNode.style.fontFeatureSettings = fontInfo.fontFeatureSettings;
2227
domNode.style.lineHeight = fontInfo.lineHeight + 'px';

0 commit comments

Comments
 (0)