Skip to content

modern-pdf-lib


modern-pdf-lib / computeFontSize

Function: computeFontSize()

computeFontSize(text, options): number

Defined in: src/core/layout.ts:130

Compute the largest font size (in points) at which text fits within the given width (and optionally height) constraints.

Uses binary search between minSize (default 4) and maxSize (default 500), converging to within 0.1 pt.

Parameters

text

string

options

ComputeFontSizeOptions

Returns

number

Released under the MIT License.