You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I read in the Readme that you are using binary search. It seems that performance can be improved by not using binary search.
The algorithm for finding the font size is as follows:
get the width of the text const {width} = myElement. getBoundingClientRect();
coefficient = element_width / fontSize
to get the font size that will fit without breaking a line in a div with a width of 400 pixels, you need to divide 400 by this coefficient; newFontSize = 400 / coefficient
I know this is an old issue, but did you have any examples of this algorithm breaking? In my testing it's working okay, but it sounds like the issues are tricky edge case.
I read in the Readme that you are using binary search. It seems that performance can be improved by not using binary search.
The algorithm for finding the font size is as follows:
const {width} = myElement. getBoundingClientRect();
coefficient = element_width / fontSize
newFontSize = 400 / coefficient
A working demo and code can be viewed here
and here you can look at this algorithm:
The text was updated successfully, but these errors were encountered: