davatron5000 / FitText.js

A jQuery plugin for inflating web type
http://fittextjs.com
6.75k stars 1.39k forks source link

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

Closed RobinBertilsson closed 1 year ago

RobinBertilsson commented 8 years ago

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

davatron5000 commented 8 years ago

@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?

RobinBertilsson commented 7 years ago

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 :)

Memocana commented 6 years ago

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.