zachleat / BigText

jQuery plugin, calculates the font-size and word-spacing needed to match a line of text to a specific width.
http://www.zachleat.com/web/bigtext-makes-text-big/
MIT License
888 stars 257 forks source link

BigText stops working when required font-size is less than 24px #134

Open Tomtids opened 7 years ago

Tomtids commented 7 years ago

I'm working on a responsive website at the moment and bigtext.js is working great on resizing my title within a fluid box UNTIL the font-size would need to be less than 24px. At this point instead of continuing the size the font down by 0.1 increments the font-size jumps to 10px. When the box gets wider the text remains at 10px until it can jump to 24px again.

Is there a way to override this behaviour so it continues to scale please?

Tomtids commented 7 years ago

I've found a solution for my issue. When the font size gets small the 'autoGuessSubtraction' which is set at 32px was meaning that a negative font size was being applied to the element. This meant that the inline style was being correctly ignored by the browser (you can't have a negative font size!) so it was falling back to the default size of 10.

By setting 'autoGuessSubtraction' to 0 everything seems to work fine.

I'm not clear what 'autoGuessSubtraction' is supposed to do (i've not figured out the whole plugin yet), but I hope this fix won't cause any longer term issues or surprises when I browser test!