typographic icon indicating copy to clipboard operation
typographic copied to clipboard

Responsive letter-spacing

Open larsenwork opened this issue 9 years ago • 15 comments

I'm currently using media queries for responsive letter spacing to increase letter spacing at smaller font sizes but would be great if they could be variables here. I know these are some very minute adjustments but they can make a big difference in overall typographic sexiness.

E.g.:

$min-font            : 12px !default;
$max-font            : 20px !default;
$min-font-spacing    : 1px !default;
$max-font-spacing    : 0px !default;
$header-font-spacing : -0.2em !default;

larsenwork avatar Jun 17 '15 08:06 larsenwork

This is how  has done it with their new system fonts. @corysimmons any thoughts on this? 804_introducing_the_new_system_fonts

larsenwork avatar Jun 23 '15 08:06 larsenwork

Seems complicated for a small payoff. I think maybe Typographic is already overly complicated, but I'm willing to examine a PR if you want to make one.

Appreciate this.

corysimmons avatar Jun 23 '15 14:06 corysimmons

@corysimmons you're right about it being a bit complicated - but it's very capable though ;)

I don't have the time or skills to make a pr right now and what I'll end up doing sometime in the future (if someone else doesn't beat me to it) is making a typographic-light with this feature added and some other trimmed.

Feel free to close this issue or leave it open for someone else to stumble upon

larsenwork avatar Jun 23 '15 15:06 larsenwork

Sorry it's taken me so long to respond. I have my ups and downs with being a good maintainer.

I'm planning on migrating this project to PostCSS in the next month or so, and when I do, I'll probably rewrite it from scratch.


Sorry I didn't take a proper look at this earlier. This seems pretty easy actually. It should be the same concept as scaling down the fonts, except we'd be scaling the letter-spacing.

I'll definitely try to add this feature to the next version of Typographic. Sorry again!

corysimmons avatar Feb 06 '16 04:02 corysimmons

@corysimmons no worries, looking forward to it. I tried simplifying the font scaling calc function in typographic using rem units but for some reason it doesn't work properly in safari (firefox + chrome works perfectly) - any idea why:

font-size: calc(0.875rem + (1.25 - 0.875) * ( (100vw - 20rem) / (40 - 20) ) );

larsenwork avatar Feb 13 '16 14:02 larsenwork

It's possible Safari doesn't know how to add 0.875rem + 0.375?

corysimmons avatar Feb 13 '16 15:02 corysimmons

Do you happen to know where the letter-spacing formula is that Apple is using?

corysimmons avatar Feb 13 '16 15:02 corysimmons

Dropping a note here to use ch units for this.

corysimmons avatar Feb 15 '16 18:02 corysimmons

safari had an issue with rem, em worked

larsenwork avatar Feb 18 '16 09:02 larsenwork

unfortunately don't know the exact formula

larsenwork avatar Feb 18 '16 09:02 larsenwork

Yeah I'm probably gonna drop rem's all together in favor of em's.

corysimmons avatar Feb 18 '16 15:02 corysimmons

VICTORY ;)

But seriously, that's the biggest benefit of using EM's over any of the other relative units: they are very universal. As long as you never put font-size on a container but rather on the element itself, you'll never have the inheritance issues that so many people complain about. CH and CX are interesting, but unfortunately not very well supported yet.

Nice work Cory!

jpamental avatar Feb 18 '16 15:02 jpamental

:+1: Sorry I didn't understand your point years ago. I think the PostCSS version will be cool. =)

corysimmons avatar Feb 18 '16 16:02 corysimmons

No worries; probably my fault for not explaining it well enough :)

jpamental avatar Feb 19 '16 13:02 jpamental

I thought it meant I couldn't be lazy.

Like once you start nesting with em's, many things become coupled/dependent on font-sizes higher up the chain.

I thought the rule you were trying to say was "Always use em for everything ever".

Now I realize you can use hard values to reset these font sizes wherever you want. http://codepen.io/corysimmons/pen/zrQaje?editors=1100 (not that all these need to be resetted)

corysimmons avatar Feb 19 '16 16:02 corysimmons