BigText
BigText copied to clipboard
Negative font size on Mac OS X/iPad
For some reason this plugin was generating a negative font size for a long title which was causing it to instead use the default size (which was far too large).
I couldn't figure out where the calculation was going wrong, but I was able to fix it by modifying the generateCSS function so that the for loop instead reads (line 78):
(linesFontSizes[j] > 0 ? ' font-size: ' + linesFontSizes[j] + 'px;' : ' font-size: 25px;') +
I had to hardcode the min font size because "minFontSizes" seemed to be a boolean instead of a numeric value.
I ran into issues with negative sizes as well.
The starting font-size must be small enough to guarantee that each individual line is not wrapping pre-BigText. If the line is too long, BigText will not size it correctly.
After reading this line from the readme, I set the default font-size in my css to a much lower value and no longer saw negative font sizes.
Thanks @timrwood, this is likely the issue. I’d like to fix this internally to BigText so I’ll leave this issue open to log it. Thanks!
In case it helps anyone, the offending value in the code that causes a negative font size for small displays is line 211
var autoGuessSubtraction = 32, // font size in px
this gets substracted and if the font is generally smaller, results in a negative number.
So just setting this to lets say 10 fixes it:
var autoGuessSubtraction = 10, // font size in px
wearetelescopic's post fixed this for me
Is there any reason for not changing this value in code? Would it break something else?
The tip by @wearetelescopic actually helps, thanks a lot!, and is still needed: https://jsfiddle.net/70d2caze/1/
Set autoGuessSubtraction = 10 and it will look neat and tidy.