src/vs/editor/common/config/fontInfo.ts

244 LOC · 208 covered · 36 uncovered · 5 ranges · 2068 concepts · 1 introducers · 1048 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/editor/common/config/editorOptions.ts · 6891 LOCconfig/editorOptions.tssrc/vs/editor/common/config/editorZoom.ts · 34 LOCconfig/editorZoom.tssrc/vs/editor/common/core/misc/textModelDefaults.ts · 17 LOCmisc/textModelDefaults.t…src/vs/platform/accessibility/common/accessibility.ts · 57 LOCcommon/accessibility.tstextModel.ts ×6 · 31 introduced LOCtextModel.ts ×6computeAutomaticInstructions.ts ×1 · 2 introduced LOCcomputeAutomaticInstruct…computeAutomaticInstructions.ts ×1 · 2 introduced LOCcomputeAutomaticInstruct…computeAutomaticInstructions.ts ×2 · 6 introduced LOCcomputeAutomaticInstruct…modelService.ts ×4 · 8 introduced LOCmodelService.ts ×4extHostTerminalService.ts ×31 · 156 introduced LOCextHostTerminalService.t…extHostSCM.ts ×86 · 432 introduced LOCextHostSCM.ts ×86extHostChatAgents2.ts ×98 · 451 introduced LOCextHostChatAgents2.ts ×9…textModel.ts ×1 · 1 introduced LOCtextModel.ts ×1textModel.ts ×20 · 342 introduced LOCtextModel.ts ×20extHostTerminalService.ts ×109 · 894 introduced LOCextHostTerminalService.t…testRPCProtocol.ts ×2 · 5 introduced LOCtestRPCProtocol.ts ×2testRPCProtocol.ts ×9 · 119 introduced LOCtestRPCProtocol.ts ×9extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions roundtrip from -> to preserves data|occurrence=1 · 0 introduced LOCextHostTypeConverters.te…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 6 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×4 · 12 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to handles Dto with UriComponents|occurrence=1 · 0 introduced LOCextHostTypeConverters.te…extHostTypeConverters.ts ×3 · 14 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×13 · 70 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 5 introduced LOCextHostTypeConverters.ts…themables.ts ×1 · 5 introduced LOCthemables.ts ×1extHostRpcService.ts ×2 · 38 introduced LOCextHostRpcService.ts ×2extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHost.protocol.ts ×3 · 4200 introduced LOCextHost.protocol.ts ×3extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×2 · 11 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×1 · 1 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×3 · 3 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×3 · 3 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×2 · 2 introduced LOCextHostTypeConverters.ts…extHostTypeConverters.ts ×2 · 2 introduced LOCextHostTypeConverters.ts…extHostTypes.ts ×270 · 6339 introduced LOCextHostTypes.ts ×270textModel.ts ×2 · 6 introduced LOCtextModel.ts ×2pieceTreeBase.ts ×1 · 2 introduced LOCpieceTreeBase.ts ×1pieceTreeBase.ts ×1 · 2 introduced LOCpieceTreeBase.ts ×1sparseTokensStore.ts ×1 · 4 introduced LOCsparseTokensStore.ts ×1testThemeService.ts ×18 · 401 introduced LOCtestThemeService.ts ×18modelService.ts ×30 · 152 introduced LOCmodelService.ts ×30pieceTreeTextBufferBuilder.ts ×19 · 149 introduced LOCpieceTreeTextBufferBuild…modelLineProjectionData.ts ×2 · 13 introduced LOCmodelLineProjectionData.…pieceTreeTextBuffer.ts ×1 · 3 introduced LOCpieceTreeTextBuffer.ts ×…pieceTreeTextBuffer.ts ×4 · 31 introduced LOCpieceTreeTextBuffer.ts ×…textModel.ts ×3 · 10 introduced LOCtextModel.ts ×3textModel.ts ×190 · 2948 introduced LOCtextModel.ts ×190brackets.ts ×1 · 3 introduced LOCbrackets.ts ×1tokenizer.ts ×18 · 196 introduced LOCtokenizer.ts ×18languageConfigurationRegistry.ts ×5 · 64 introduced LOClanguageConfigurationReg…languageConfiguration.ts ×1 · 1 introduced LOClanguageConfiguration.ts…testLanguageConfigurationService.ts ×4 · 23 introduced LOCtestLanguageConfiguratio…languageConfigurationRegistry.ts ×28 · 260 introduced LOClanguageConfigurationReg…linesLayout.ts ×3 · 29 introduced LOClinesLayout.ts ×3modelLineProjectionData.ts ×1 · 17 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×18 · 97 introduced LOCmodelLineProjectionData.…linesLayout.ts ×2 · 27 introduced LOClinesLayout.ts ×2linesLayout.ts ×7 · 44 introduced LOClinesLayout.ts ×7textModelEvents.ts ×25 · 438 introduced LOCtextModelEvents.ts ×25linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Bug|occurrence=1 · 0 introduced LOClinesLayout.test|title=E…linesLayout.ts ×2 · 6 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 4 introduced LOClinesLayout.ts ×1linesLayout.ts ×2 · 12 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 4 introduced LOClinesLayout.ts ×1linesLayout.ts ×13 · 72 introduced LOClinesLayout.ts ×13linesLayout.ts ×3 · 5 introduced LOClinesLayout.ts ×3linesLayout.ts ×3 · 8 introduced LOClinesLayout.ts ×3linesLayout.ts ×46 · 279 introduced LOClinesLayout.ts ×46onEnter.ts ×1 · 7 introduced LOConEnter.ts ×1onEnter.ts ×2 · 4 introduced LOConEnter.ts ×2onEnter.ts ×8 · 32 introduced LOConEnter.ts ×8lineHeights.ts ×2 · 3 introduced LOClineHeights.ts ×2lineHeights.ts ×24 · 127 introduced LOClineHeights.ts ×24onEnter.ts ×6 · 37 introduced LOConEnter.ts ×6strings.ts ×1 · 7 introduced LOCstrings.ts ×1editorOptions.ts ×92 · 6015 introduced LOCeditorOptions.ts ×92brackets.test|title=Bracket Pair Colorizer - Brackets Basic|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/bracketPairColorizer/brackets.test|title=Bracket Pair Colorizer - Brackets Basic|occurrence=1brackets.test|title=Brac…linesTextBuffer.test|title=PieceTreeTextBuffer._getInverseEdits multiline delete|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/linesTextBuffer/linesTextBuffer.test|title=PieceTreeTextBuffer._getInverseEdits multiline delete|occurrence=1linesTextBuffer.test|tit…linesTextBuffer.test|title=PieceTreeTextBuffer._getInverseEdits single delete|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/linesTextBuffer/linesTextBuffer.test|title=PieceTreeTextBuffer._getInverseEdits single delete|occurrence=1linesTextBuffer.test|tit…modelInjectedText.test|title=Editor Model - Injected Text Events Basic|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/modelInjectedText.test|title=Editor Model - Injected Text Events Basic|occurrence=1modelInjectedText.test|t…languageConfiguration.test|title=StandardAutoClosingPairConditional Missing notIn|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/languageConfiguration.test|title=StandardAutoClosingPairConditional Missing notIn|occurrence=1languageConfiguration.te…onEnter.test|title=OnEnter uses brackets|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/modes/supports/onEnter.test|title=OnEnter uses brackets|occurrence=1onEnter.test|title=OnEnt…modelService.test|title=ModelService EOL setting respected depending on root|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/modelService.test|title=ModelService EOL setting respected depending on root|occurrence=1modelService.test|title=…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Bug|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Bug|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLinesViewportData 2 & getWhitespaceViewportData|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLinesViewportData 2 & getWhitespaceViewportData|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getWhitespaceAtVerticalOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getWhitespaceAtVerticalOffset|occurrence=1linesLayout.test|title=E…lineBreakData.test|title=Editor ViewModel - LineBreakData Basic|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/lineBreakData.test|title=Editor ViewModel - LineBreakData Basic|occurrence=1lineBreakData.test|title…extHostChatAgents2.test|title=ExtHostChatAgents2 reports anchor before resolving it|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostChatAgents2.test|title=ExtHostChatAgents2 reports anchor before resolving it|occurrence=1extHostChatAgents2.test|…extHostSCM.test|title=ExtHostSCM disposed source controls are removed from extension bookkeeping|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostSCM.test|title=ExtHostSCM disposed source controls are removed from extension bookkeeping|occurrence=1extHostSCM.test|title=Ex…extHostTerminalService.test|title=ExtHostTerminalService $acceptTerminalClosed cancels in-flight link providers and clears the link cache|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTerminalService.test|title=ExtHostTerminalService $acceptTerminalClosed cancels in-flight link providers and clears the link cache|occurrence=1extHostTerminalService.t…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions from converts API type to IChatRequestModeInstructions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions from converts API type to IChatRequestModeInstructions|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions from handles missing toolReferences|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions from handles missing toolReferences|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions from returns undefined for undefined input|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions from returns undefined for undefined input|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions roundtrip from -> to preserves data|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions roundtrip from -> to preserves data|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to converts IChatRequestModeInstructions to API type|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to converts IChatRequestModeInstructions to API type|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to handles Dto with UriComponents|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to handles Dto with UriComponents|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to returns undefined for undefined input|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatRequestModeInstructions to returns undefined for undefined input|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters ChatToolInvocationPart converts subagent data with its model name|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters ChatToolInvocationPart converts subagent data with its model name|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters IconPath from ThemeIcon|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath from ThemeIcon|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters IconPath from URI|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath from URI|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters IconPath from undefined|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath from undefined|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters IconPath to ThemeIcon|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath to ThemeIcon|occurrence=1extHostTypeConverters.te…extHostTypeConverters.test|title=extHostTypeConverters IconPath to URI|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath to URI|occurrence=1extHostTypeConverters.te…light|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath to dark/light|occurrence=1light|occurrence=1extHostTypeConverters.test|title=extHostTypeConverters IconPath to undefined|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/api/test/common/extHostTypeConverters.test|title=extHostTypeConverters IconPath to undefined|occurrence=1extHostTypeConverters.te…computeAutomaticInstructions.test|title=getFilePath should return uri.toString() for other schemes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/promptSyntax/computeAutomaticInstructions.test|title=getFilePath should return uri.toString() for other schemes|occurrence=1computeAutomaticInstruct… URIs when connected to a Windows remote|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/promptSyntax/computeAutomaticInstructions.test|title=getFilePath should return vscode-local:/ URI string for file:// URIs when connected to a Windows remote|occurrence=1 URIs when connected to … URIs when connected to a remote|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/promptSyntax/computeAutomaticInstructions.test|title=getFilePath should return vscode-local:/ URI string for file:// URIs when connected to a remote|occurrence=1 URIs when connected to …Focused file · src/vs/editor/common/config/fontInfo.ts · 244 LOCconfig/fontInfo.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- editorOptions.ts ×92
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as platform from '../../../base/common/platform.js';
7 > import { EditorOption, FindComputedEditorOptionValueById } from './editorOptions.js';
8 > import { EditorZoom } from './editorZoom.js';
9 >
10 > /**
11 > * Determined from empirical observations.
12 > * @internal
13 > */
14 > export const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
15 >
16 > /**
17 > * @internal
18 > */
19 > export const MINIMUM_LINE_HEIGHT = 8;
20 >
21 > /**
22 > * @internal
23 > */
24 > export interface IValidatedEditorOptions {
25 > get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
26 > }
27 >
28 > export class BareFontInfo {
29 > readonly _bareFontInfoBrand: void = undefined;
30 >
31 > /**
32 > * @internal
33 > */
34 > public static _create(fontFamily: string, fontWeight: string, fontSize: number, fontFeatureSettings: string, fontVariationSettings: string, lineHeight: number, letterSpacing: number, pixelRatio: number, ignoreEditorZoom: boolean): BareFontInfo {
35 > if (lineHeight === 0) {
36 > lineHeight = GOLDEN_LINE_HEIGHT_RATIO * fontSize;
37 > } else if (lineHeight < MINIMUM_LINE_HEIGHT) {
38 > // Values too small to be line heights in pixels are in ems.
39 > lineHeight = lineHeight * fontSize;
40 > }
41 >
42 > // Enforce integer, minimum constraints
43 > lineHeight = Math.round(lineHeight);
44 > if (lineHeight < MINIMUM_LINE_HEIGHT) {
45 > lineHeight = MINIMUM_LINE_HEIGHT;
46 > }
47 >
48 > const editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
49 > fontSize *= editorZoomLevelMultiplier;
50 > lineHeight *= editorZoomLevelMultiplier;
51 >
52 > if (fontVariationSettings === FONT_VARIATION_TRANSLATE) {
53 > if (fontWeight === 'normal' || fontWeight === 'bold') {
54 > fontVariationSettings = FONT_VARIATION_OFF;
55 > } else {
56 > const fontWeightAsNumber = parseInt(fontWeight, 10);
57 > fontVariationSettings = `'wght' ${fontWeightAsNumber}`;
58 > fontWeight = 'normal';
59 > }
60 > }
61 >
62 > return new BareFontInfo({
63 > pixelRatio: pixelRatio,
64 > fontFamily: fontFamily,
65 > fontWeight: fontWeight,
66 > fontSize: fontSize,
67 > fontFeatureSettings: fontFeatureSettings,
68 > fontVariationSettings,
69 > lineHeight: lineHeight,
70 > letterSpacing: letterSpacing
71 > });
72 > }
73 >
74 > readonly pixelRatio: number;
75 > readonly fontFamily: string;
76 > readonly fontWeight: string;
77 > readonly fontSize: number;
78 > readonly fontFeatureSettings: string;
79 > readonly fontVariationSettings: string;
80 > readonly lineHeight: number;
81 > readonly letterSpacing: number;
82 >
83 > /**
84 > * @internal
85 > */
86 > protected constructor(opts: {
87 > pixelRatio: number;
88 > fontFamily: string;
89 > fontWeight: string;
90 > fontSize: number;
91 > fontFeatureSettings: string;
92 > fontVariationSettings: string;
93 > lineHeight: number;
94 > letterSpacing: number;
95 > }) {
96 > this.pixelRatio = opts.pixelRatio;
97 > this.fontFamily = String(opts.fontFamily);
98 > this.fontWeight = String(opts.fontWeight);
99 > this.fontSize = opts.fontSize;
100 > this.fontFeatureSettings = opts.fontFeatureSettings;
101 > this.fontVariationSettings = opts.fontVariationSettings;
102 > this.lineHeight = opts.lineHeight | 0;
103 > this.letterSpacing = opts.letterSpacing;
104 > }
105 >
106 > /**
107 > * @internal
108 > */
109 > public getId(): string {
110 return `${this.pixelRatio}-${this.fontFamily}-${this.fontWeight}-${this.fontSize}-${this.fontFeatureSettings}-${this.fontVariationSettings}-${this.lineHeight}-${this.letterSpacing}`;
111 }
113 > /**
114 > * @internal
115 > */
116 > public getMassagedFontFamily(): string {
117 const fallbackFontFamily = EDITOR_FONT_DEFAULTS.fontFamily;
118 const fontFamily = BareFontInfo._wrapInQuotes(this.fontFamily);
119 if (fallbackFontFamily && this.fontFamily !== fallbackFontFamily) {
120 return `${fontFamily}, ${fallbackFontFamily}`;
121 }
122 return fontFamily;
123 }
125 > private static _wrapInQuotes(fontFamily: string): string {
126 if (/[,"']/.test(fontFamily)) {
127 // Looks like the font family might be already escaped
128 return fontFamily;
129 }
130 if (/[+ ]/.test(fontFamily)) {
131 // Wrap a font family using + or <space> with quotes
132 return `"${fontFamily}"`;
133 }
134 return fontFamily;
135 }
137 >
138 > // change this whenever `FontInfo` members are changed
139 > export const SERIALIZED_FONT_INFO_VERSION = 2;
140 >
141 > export class FontInfo extends BareFontInfo {
142 > readonly _editorStylingBrand: void = undefined;
143 >
144 > readonly version: number = SERIALIZED_FONT_INFO_VERSION;
145 > readonly isTrusted: boolean;
146 > readonly isMonospace: boolean;
147 > readonly typicalHalfwidthCharacterWidth: number;
148 > readonly typicalFullwidthCharacterWidth: number;
149 > readonly canUseHalfwidthRightwardsArrow: boolean;
150 > readonly spaceWidth: number;
151 > readonly middotWidth: number;
152 > readonly wsmiddotWidth: number;
153 > readonly maxDigitWidth: number;
154 >
155 > /**
156 > * @internal
157 > */
158 > constructor(opts: {
159 > pixelRatio: number;
160 > fontFamily: string;
161 > fontWeight: string;
162 > fontSize: number;
163 > fontFeatureSettings: string;
164 > fontVariationSettings: string;
165 > lineHeight: number;
166 > letterSpacing: number;
167 > isMonospace: boolean;
168 > typicalHalfwidthCharacterWidth: number;
169 > typicalFullwidthCharacterWidth: number;
170 > canUseHalfwidthRightwardsArrow: boolean;
171 > spaceWidth: number;
172 > middotWidth: number;
173 > wsmiddotWidth: number;
174 > maxDigitWidth: number;
175 > }, isTrusted: boolean) {
176 > super(opts);
177 > this.isTrusted = isTrusted;
178 > this.isMonospace = opts.isMonospace;
179 > this.typicalHalfwidthCharacterWidth = opts.typicalHalfwidthCharacterWidth;
180 > this.typicalFullwidthCharacterWidth = opts.typicalFullwidthCharacterWidth;
181 > this.canUseHalfwidthRightwardsArrow = opts.canUseHalfwidthRightwardsArrow;
182 > this.spaceWidth = opts.spaceWidth;
183 > this.middotWidth = opts.middotWidth;
184 > this.wsmiddotWidth = opts.wsmiddotWidth;
185 > this.maxDigitWidth = opts.maxDigitWidth;
186 > }
187 >
188 > /**
189 > * @internal
190 > */
191 > public equals(other: FontInfo): boolean {
192 return (
193 this.fontFamily === other.fontFamily
194 && this.fontWeight === other.fontWeight
195 && this.fontSize === other.fontSize
196 && this.fontFeatureSettings === other.fontFeatureSettings
197 && this.fontVariationSettings === other.fontVariationSettings
198 && this.lineHeight === other.lineHeight
199 && this.letterSpacing === other.letterSpacing
200 && this.typicalHalfwidthCharacterWidth === other.typicalHalfwidthCharacterWidth
201 && this.typicalFullwidthCharacterWidth === other.typicalFullwidthCharacterWidth
202 && this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow
203 && this.spaceWidth === other.spaceWidth
204 && this.middotWidth === other.middotWidth
205 && this.wsmiddotWidth === other.wsmiddotWidth
206 && this.maxDigitWidth === other.maxDigitWidth
207 );
208 }
210 > /**
211 > * @internal
212 > */
213 > export const FONT_VARIATION_OFF = 'normal';
214 > /**
215 > * @internal
216 > */
217 > export const FONT_VARIATION_TRANSLATE = 'translate';
218 >
219 > /**
220 > * @internal
221 > */
222 > export const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
223 > /**
224 > * @internal
225 > */
226 > export const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
227 > /**
228 > * @internal
229 > */
230 > export const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', monospace';
231 > /**
232 > * @internal
233 > */
234 > export const EDITOR_FONT_DEFAULTS = {
235 > fontFamily: (
236 > platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isWindows ? DEFAULT_WINDOWS_FONT_FAMILY : DEFAULT_LINUX_FONT_FAMILY)
237 > ),
238 > fontWeight: 'normal',
239 > fontSize: (
240 > platform.isMacintosh ? 12 : 14
241 > ),
242 > lineHeight: 0,
243 > letterSpacing: 0,
244 > };