GlyphContext
import type { GlyphContext } from 'pixi-silk/text';
The slice of a 2D canvas context the atlas needs. Pass your own to SdfAtlasOptions.context to bake glyphs somewhere else (a worker canvas, or a fake one in tests).
Properties#
Methods#
clearRect()#
clearRect(
x: number,
y: number,
w: number,
h: number
): void;
Clears a rectangle to transparent.
Parameters#
| Parameter | Type |
|---|---|
x | number |
y | number |
w | number |
h | number |
Returns#
void
fillText()#
fillText(
text: string,
x: number,
y: number
): void;
Draws a string with its pen at (x, y).
Parameters#
| Parameter | Type |
|---|---|
text | string |
x | number |
y | number |
Returns#
void
getImageData()#
getImageData(
x: number,
y: number,
w: number,
h: number
): {
data: ArrayLike<number>;
};
Reads pixels back as RGBA bytes.
Parameters#
| Parameter | Type |
|---|---|
x | number |
y | number |
w | number |
h | number |
Returns#
| Name | Type | Description | Defined in |
|---|---|---|---|
data | ArrayLike<number> | RGBA bytes, row by row. | text/atlas.ts:81 |
measureText()#
measureText(text: string): Pick<TextMetrics,
| "width"
| "actualBoundingBoxLeft"
| "actualBoundingBoxRight"
| "actualBoundingBoxAscent"
| "actualBoundingBoxDescent">;
Measures a string in the current font.
Parameters#
| Parameter | Type |
|---|---|
text | string |
Returns#
Pick<TextMetrics,
| "width"
| "actualBoundingBoxLeft"
| "actualBoundingBoxRight"
| "actualBoundingBoxAscent"
| "actualBoundingBoxDescent">