Path: blob/main/src/vs/editor/browser/gpu/raster/raster.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import type { MetadataConsts } from '../../../common/encodedTokenAttributes.js';67export interface IGlyphRasterizer {8/**9* A unique identifier for the rasterizer.10*/11readonly id: number;1213/**14* An identifier for properties inherent to rendering with this rasterizer. This will be the15* same as other rasterizer cache keys provided they share the same property values in question.16*/17readonly cacheKey: string;1819/**20* Rasterizes a glyph.21* @param chars The character(s) to rasterize. This can be a single character, a ligature, an22* emoji, etc.23* @param tokenMetadata The token metadata of the glyph to rasterize. See {@link MetadataConsts}24* for how this works.25* @param decorationStyleSetId The id of the decoration style sheet. Zero means no decoration.26* @param colorMap A theme's color map.27*/28rasterizeGlyph(29chars: string,30tokenMetadata: number,31decorationStyleSetId: number,32colorMap: string[],33): Readonly<IRasterizedGlyph>;3435getTextMetrics(text: string): TextMetrics;36}3738/**39* A simple bounding box in a 2D plane.40*/41export interface IBoundingBox {42/** The left x coordinate (inclusive). */43left: number;44/** The top y coordinate (inclusive). */45top: number;46/** The right x coordinate (inclusive). */47right: number;48/** The bottom y coordinate (inclusive). */49bottom: number;50}5152/**53* A glyph that has been rasterized to a canvas.54*/55export interface IRasterizedGlyph {56/**57* The source canvas the glyph was rasterized to.58*/59source: OffscreenCanvas;60/**61* The bounding box of the glyph within {@link source}.62*/63boundingBox: IBoundingBox;64/**65* The offset to the glyph's origin (where it should be drawn to).66*/67originOffset: { x: number; y: number };68/**69* The distance from the glyph baseline to the top of the highest bounding rectangle of all70* fonts used to render the text.71*72* @see {@link TextMetrics.fontBoundingBoxAscent}73*/74fontBoundingBoxAscent: number;75/**76* The distance from the glyph baseline to the bottom of the bounding rectangle of all fonts77* used to render the text.78*79* @see {@link TextMetrics.fontBoundingBoxDescent}80*/81fontBoundingBoxDescent: number;82}838485