<.> Encodable
Getting startedWhy use Encodable?
Gallery
Guides
Encodable API
Submodule API
@encodable/color@encodable/dimensionInstallAPIs@encodable/format@encodable/registry
Contributing guidelinesAbout

@encodable/dimension

Version David (path)

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