davatron5000 / FitText.js

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

Is it really supposed to work? #131

Closed OnkelTem closed 9 years ago

OnkelTem commented 9 years ago

Let me first say that I haven't tried this lib — instead I used it's jQuery-free variant: https://github.com/adactio/FitText.js which does pretty much the same as this library. And it doesn't work for me. I have an element of 640px width and 96px height. The result of using this would be 64px new font size according to: https://github.com/davatron5000/FitText.js/blob/master/jquery.fittext.js#L30

 $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));

So we take box width, divide it by 10 and... what? Why this should fit something to somewhere? I just don't get the logic.

OnkelTem commented 9 years ago

Answering to myself. I just realized why this library is for. It is for static text objects with fixed width, and you just manually match a factor in %% of box width so that when you change container's width - text will resize.

So this library doesn't actually fit text, it just maintain fixed text width inside a container. If text changes (switching language for instance) - layout breaks.

I think this information should be on the project's main page.

davatron5000 commented 9 years ago

Yes. FitText is for fluid width, scalable text.

Already documented here:

FitText makes font-sizes flexible. Use this plugin on your responsive design for ratio-based resizing of your headlines.

And here https://github.com/davatron5000/FitText.js#in-use on the readme.

You might like one of the other options listed there in that link or the brand spanking new: http://jxnblk.com/fitter-happier-text/ - I am told it's Fitter and Happier than this version.

OnkelTem commented 9 years ago

Thank you, Dave!

I reread project's page and now I see what you are talking about :) Actually, project name confused me, so I decided I know what this thing is for. Sorry for being careless.

Talking to really fitting libs, I'm checking out this one at the moment: https://github.com/STRML/textFit Wanna try Happier too as it looks really interesting!