Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/browser/gpu/raster/raster.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
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 type { MetadataConsts } from '../../../common/encodedTokenAttributes.js';
7
8
export interface IGlyphRasterizer {
9
/**
10
* A unique identifier for the rasterizer.
11
*/
12
readonly id: number;
13
14
/**
15
* An identifier for properties inherent to rendering with this rasterizer. This will be the
16
* same as other rasterizer cache keys provided they share the same property values in question.
17
*/
18
readonly cacheKey: string;
19
20
/**
21
* Rasterizes a glyph.
22
* @param chars The character(s) to rasterize. This can be a single character, a ligature, an
23
* emoji, etc.
24
* @param tokenMetadata The token metadata of the glyph to rasterize. See {@link MetadataConsts}
25
* for how this works.
26
* @param decorationStyleSetId The id of the decoration style sheet. Zero means no decoration.
27
* @param colorMap A theme's color map.
28
*/
29
rasterizeGlyph(
30
chars: string,
31
tokenMetadata: number,
32
decorationStyleSetId: number,
33
colorMap: string[],
34
): Readonly<IRasterizedGlyph>;
35
36
getTextMetrics(text: string): TextMetrics;
37
}
38
39
/**
40
* A simple bounding box in a 2D plane.
41
*/
42
export interface IBoundingBox {
43
/** The left x coordinate (inclusive). */
44
left: number;
45
/** The top y coordinate (inclusive). */
46
top: number;
47
/** The right x coordinate (inclusive). */
48
right: number;
49
/** The bottom y coordinate (inclusive). */
50
bottom: number;
51
}
52
53
/**
54
* A glyph that has been rasterized to a canvas.
55
*/
56
export interface IRasterizedGlyph {
57
/**
58
* The source canvas the glyph was rasterized to.
59
*/
60
source: OffscreenCanvas;
61
/**
62
* The bounding box of the glyph within {@link source}.
63
*/
64
boundingBox: IBoundingBox;
65
/**
66
* The offset to the glyph's origin (where it should be drawn to).
67
*/
68
originOffset: { x: number; y: number };
69
/**
70
* The distance from the glyph baseline to the top of the highest bounding rectangle of all
71
* fonts used to render the text.
72
*
73
* @see {@link TextMetrics.fontBoundingBoxAscent}
74
*/
75
fontBoundingBoxAscent: number;
76
/**
77
* The distance from the glyph baseline to the bottom of the bounding rectangle of all fonts
78
* used to render the text.
79
*
80
* @see {@link TextMetrics.fontBoundingBoxDescent}
81
*/
82
fontBoundingBoxDescent: number;
83
}
84
85