@encodable/dimension
Utilities for managing dimension.
Install
npm install @encodable/dimension
APIs
getTextDimension(...)
Get dimension (width & height) of a rendered text.
Signature
function getTextDimension(input: {className?: string;container?: HTMLElement;style?: TextStyle;text: string;},defaultDimension?: Dimension): Dimension;
Example
import { getTextDimension } from '@encodable/dimension';getTextDimension({ text: 'abcdef' });
getMultipleTextDimension(...)
Same with getTextDimension()
but takes an array of strings which is more efficient for batch computation.
computeMaxFontSize(...)
Compute maximum font size to fit in the the given container.
parseLength()
Parse length from string or number;
mergeMargin(...)
Merge two margin objects
mergePadding(...)
Merge two padding objects