textWidth
Returns how wide a piece of text is at a size in a face, in pixels, measured by the browser where there is one and estimated from an average glyph where there is not.
@internote/canvas-sdkOn this page
import { textWidth } from '@internote/canvas-sdk';Cached, except while the face is still downloading: a measurement taken against the fallback must not be remembered as the answer.
#Signature
(text: string, px: number, family?: string): number#Parameters
textThe text to measure.
pxThe font size in pixels.
familyThe CSS font stack, which may name a
var().#Example
const gutter = textWidth(renderedText(axisName), labelPx(size, unit)) + unit;Declared in packages/canvas-sdk/src/text/index.ts:94.