FitText.js icon indicating copy to clipboard operation
FitText.js copied to clipboard

"font-size: 0px", found a wierd font-size bug.

Open RobinBertilsson opened this issue 8 years ago • 3 comments

Sometimes you'll get "font-size: 0px", this is my solution..

  1. Break out the value var value = Math.max(Math.min($this.width() / (compressor * 10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize));
  2. Basicly check if the font-size is 0 if (value !== 0) { $this.css('font-size', value); }

Works fine for me. /R

RobinBertilsson avatar May 20 '16 13:05 RobinBertilsson

@RobinBertilsson I realize you posted this quite awhile ago. But could you post a CodePen or something that demonstrates the problem? Or are you just saying it'd be good to never set the font-size to 0 ever?

davatron5000 avatar Oct 19 '16 14:10 davatron5000

Hey sorry, missed that you replied, cant rly figure out what caused it atm. But i'd say skip font-size: 0, why would you "fittext" a text with fontsize 0 :)

RobinBertilsson avatar Dec 27 '16 19:12 RobinBertilsson

I'm currently having a similar issue where its calculating 0 for font-size because its currently within a hidden div in my view. Haven't found a way around it but just wanted to share one case the same event occurs.

Memocana avatar Nov 17 '17 18:11 Memocana