@@ -11,7 +11,7 @@ import * as platform from 'vs/base/common/platform';
1111import { CharWidthRequest , CharWidthRequestType , readCharWidths } from 'vs/editor/browser/config/charWidthReader' ;
1212import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver' ;
1313import { CommonEditorConfiguration , IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig' ;
14- import { EditorOption , IEditorConstructionOptions } from 'vs/editor/common/config/editorOptions' ;
14+ import { EditorOption , IEditorConstructionOptions , EditorFontLigatures } from 'vs/editor/common/config/editorOptions' ;
1515import { BareFontInfo , FontInfo } from 'vs/editor/common/config/fontInfo' ;
1616import { IDimension } from 'vs/editor/common/editorCommon' ;
1717import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
@@ -79,6 +79,7 @@ export interface ISerializedFontInfo {
7979 readonly fontFamily : string ;
8080 readonly fontWeight : string ;
8181 readonly fontSize : number ;
82+ fontFeatureSettings : string ;
8283 readonly lineHeight : number ;
8384 readonly letterSpacing : number ;
8485 readonly isMonospace : boolean ;
@@ -151,11 +152,14 @@ class CSSBasedConfiguration extends Disposable {
151152 return this . _cache . getValues ( ) . filter ( item => item . isTrusted ) ;
152153 }
153154
154- public restoreFontInfo ( savedFontInfo : ISerializedFontInfo [ ] ) : void {
155+ public restoreFontInfo ( savedFontInfos : ISerializedFontInfo [ ] ) : void {
155156 // Take all the saved font info and insert them in the cache without the trusted flag.
156157 // The reason for this is that a font might have been installed on the OS in the meantime.
157- for ( let i = 0 , len = savedFontInfo . length ; i < len ; i ++ ) {
158- const fontInfo = new FontInfo ( savedFontInfo [ i ] , false ) ;
158+ for ( let i = 0 , len = savedFontInfos . length ; i < len ; i ++ ) {
159+ const savedFontInfo = savedFontInfos [ i ] ;
160+ // compatibility with older versions of VS Code which did not store this...
161+ savedFontInfo . fontFeatureSettings = savedFontInfo . fontFeatureSettings || EditorFontLigatures . OFF ;
162+ const fontInfo = new FontInfo ( savedFontInfo , false ) ;
159163 this . _writeToCache ( fontInfo , fontInfo ) ;
160164 }
161165 }
@@ -171,6 +175,7 @@ class CSSBasedConfiguration extends Disposable {
171175 fontFamily : readConfig . fontFamily ,
172176 fontWeight : readConfig . fontWeight ,
173177 fontSize : readConfig . fontSize ,
178+ fontFeatureSettings : readConfig . fontFeatureSettings ,
174179 lineHeight : readConfig . lineHeight ,
175180 letterSpacing : readConfig . letterSpacing ,
176181 isMonospace : readConfig . isMonospace ,
@@ -249,9 +254,9 @@ class CSSBasedConfiguration extends Disposable {
249254
250255 const maxDigitWidth = Math . max ( digit0 . width , digit1 . width , digit2 . width , digit3 . width , digit4 . width , digit5 . width , digit6 . width , digit7 . width , digit8 . width , digit9 . width ) ;
251256
252- let isMonospace = true ;
257+ let isMonospace = ( bareFontInfo . fontFeatureSettings === EditorFontLigatures . OFF ) ;
253258 const referenceWidth = monospace [ 0 ] . width ;
254- for ( let i = 1 , len = monospace . length ; i < len ; i ++ ) {
259+ for ( let i = 1 , len = monospace . length ; isMonospace && i < len ; i ++ ) {
255260 const diff = referenceWidth - monospace [ i ] . width ;
256261 if ( diff < - 0.001 || diff > 0.001 ) {
257262 isMonospace = false ;
@@ -276,6 +281,7 @@ class CSSBasedConfiguration extends Disposable {
276281 fontFamily : bareFontInfo . fontFamily ,
277282 fontWeight : bareFontInfo . fontWeight ,
278283 fontSize : bareFontInfo . fontSize ,
284+ fontFeatureSettings : bareFontInfo . fontFeatureSettings ,
279285 lineHeight : bareFontInfo . lineHeight ,
280286 letterSpacing : bareFontInfo . letterSpacing ,
281287 isMonospace : isMonospace ,
@@ -294,6 +300,7 @@ export class Configuration extends CommonEditorConfiguration {
294300 domNode . style . fontFamily = fontInfo . getMassagedFontFamily ( ) ;
295301 domNode . style . fontWeight = fontInfo . fontWeight ;
296302 domNode . style . fontSize = fontInfo . fontSize + 'px' ;
303+ domNode . style . fontFeatureSettings = fontInfo . fontFeatureSettings ;
297304 domNode . style . lineHeight = fontInfo . lineHeight + 'px' ;
298305 domNode . style . letterSpacing = fontInfo . letterSpacing + 'px' ;
299306 }
@@ -302,6 +309,7 @@ export class Configuration extends CommonEditorConfiguration {
302309 domNode . setFontFamily ( fontInfo . getMassagedFontFamily ( ) ) ;
303310 domNode . setFontWeight ( fontInfo . fontWeight ) ;
304311 domNode . setFontSize ( fontInfo . fontSize ) ;
312+ domNode . setFontFeatureSettings ( fontInfo . fontFeatureSettings ) ;
305313 domNode . setLineHeight ( fontInfo . lineHeight ) ;
306314 domNode . setLetterSpacing ( fontInfo . letterSpacing ) ;
307315 }
0 commit comments