MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / getFontRatios

Function getFontRatios

src/core/FontMeasurements.ts:60–94  ·  view source on GitHub ↗

* Rapidly shows a webview in order to measure the width and height of a character in the users font * * @returns The width and height ratios of the font

()

Source from the content-addressed store, hash-verified

58 * @returns The width and height ratios of the font
59 */
60function getFontRatios() {
61 const panel = vscode.window.createWebviewPanel(
62 "cursorless.loading",
63 "Cursorless",
64 {
65 preserveFocus: true,
66 viewColumn: vscode.ViewColumn.Active,
67 },
68 {
69 enableScripts: true,
70 }
71 );
72
73 panel.webview.html = getWebviewContent();
74
75 interface FontRatios {
76 /**
77 * The ratio of the width of a character in the given font to the font size
78 */
79 widthRatio: number;
80
81 /**
82 * The ratio of the height of a character in the given font to the font
83 * size. The height is measured from the baseline to the top of the span
84 */
85 heightRatio: number;
86 }
87
88 return new Promise<FontRatios>((resolve) => {
89 panel.webview.onDidReceiveMessage((message) => {
90 panel.dispose();
91 resolve(message);
92 });
93 });
94}
95
96function getFontSize() {
97 const config = vscode.workspace.getConfiguration("editor");

Callers 1

calculateMethod · 0.85

Calls 2

getWebviewContentFunction · 0.85
disposeMethod · 0.45

Tested by

no test coverage detected