STRML / textFit

A jQuery-free component that quickly fits single and multi-line text to the width (and optionally height) of its container.
https://textfit.strml.net
637 stars 123 forks source link

Text shrinks more than necessary (AKA no odd font-sizes?) #26

Closed Mesoptier closed 5 years ago

Mesoptier commented 7 years ago

I am trying to fit a single line of text ({ minFontSize: 16, maxFontSize: 30 }). But the text is often smaller than it needs to be, and when I increase the font-size property by 1px it still fits in the container. The library seems to skip odd font-sizes for some reason.

I suspect the binary search algorithm may be the problem.

alpha-and-omega commented 6 years ago

Yes, there is a bug. I have fixed this bug in my local copy. Should I pull the fix ?

billewanick commented 6 years ago

@alpha-and-omega yes please!!

alpha-and-omega commented 6 years ago

here is the gist: https://gist.github.com/alpha-and-omega/2bafcc5ef77e81d3fd45ee82d2b5a236

ahobsonsayers commented 5 years ago

@alpha-and-omega reckon you could submit a pull request with your edits? Would be great to have the fix in the official release

alpha-and-omega commented 5 years ago

You are free to apply it without pull request.

ahobsonsayers commented 5 years ago

I realise that, I'm more just thinking if it became official it could help more people instead of them having to look in the issues to find the fix and apply it themselves.

If you'd prefer I could open the pull request with your changes myself if you gave permission.

alpha-and-omega commented 5 years ago

Yes, please create pull request.

STRML commented 5 years ago

Thanks, fixed in #37.