TehShrike / get-text-fit-size

Find out what font size will make a text block fit inside of another element without wrapping
1 stars 1 forks source link

get-text-fit-size

Given a target element and some text, figures out what font size you should use so that the text will exactly fit the width of the container.

getTextFitSize(containerElement, text)

The width and font styles of the container element will be used for the calculations.

There may be some weirdnesses with bold fonts on Safari. Open an issue or PR if you know anything.

Works in all modern browsers except IE or Edge.

License

WTFPL