@altano/satori-fit-text
Version:
Fit text to a bounding box in Node or the browser
56 lines (55 loc) • 1.37 kB
TypeScript
import { Font } from "./types.js";
//#region src/fitText.d.ts
type FindOptions = {
/**
* The text you want to fit
*/
text: string;
/**
* The font of your text. Options are the same as [those taken by
* Satori](https://github.com/vercel/satori#fonts), but only one font and not
* an array of fonts is accepted here.
*/
font: Font;
/**
* The max width the text must be contained in
*/
maxWidth: number;
/**
* The max height the text must be contained in
*/
maxHeight: number;
/**
* Optional: the CSS line height factor to use, e.g. 1.1
*/
lineHeight?: number | "normal";
/**
* The minimum font size that should be returned, even if smaller fonts fit
*/
minFontSize?: number;
/**
* The maximum font size that should be returned, even if larger fonts fit
*/
maxFontSize?: number;
/**
* The maximum number of font sizes to try before giving up. Defaults to 1000.
*/
maxTries?: number;
};
/**
* Given text, dimensions, and some options, returns the largest font size that
* would keep the text contained within the dimensions.
*/
declare function findLargestUsableFontSize({
text,
font,
maxWidth,
maxHeight,
lineHeight,
minFontSize,
maxFontSize,
maxTries
}: FindOptions): Promise<number>;
//#endregion
export { FindOptions, findLargestUsableFontSize };
//# sourceMappingURL=fitText.d.ts.map