@mbtech-nl/bitmap / measureText
Function: measureText()
ts
function measureText(text: string, options?: TextRenderOptions): {
heightPx: number;
widthPx: number;
};Defined in: font/render.ts:129
Compute the dimensions a renderText call would produce, without allocating a bitmap. Empty strings return { widthPx: 0, heightPx }.
Parameters
| Parameter | Type |
|---|---|
text | string |
options | TextRenderOptions |
Returns
ts
{
heightPx: number;
widthPx: number;
}heightPx
ts
heightPx: number;widthPx
ts
widthPx: number;Example
ts
const { widthPx, heightPx } = measureText('SKU-1234', { scaleX: 2 });