I'm using one of the new google api fonts for a heading on a site. It's Yannone Kaffeesatz and is quite a condensed typeface.
My font stack is as follows:
font-family: 'Yanone Kaffeesatz', arial, serif;
This is fine when the Yannone Kaffeesatz font renders, but if it doesn't, Arial is much more open and the heading spans over two lines.
My question is:
Is it possible to use a different font-size depending on which font is rendered on the page?
Ideally supported across a multitude of browsers.
Thanks
Tom
A font stack is a list of fonts and font keywords used to let a browser know our preferred and fallback fonts.
The font-size-adjust CSS property sets the size of lower-case letters relative to the current font size (which defines the size of upper-case letters).
A font stack is a list of fonts in the CSS font-family declaration. The fonts are listed in order of preference that you would like them to appear in case of a problem, such as a font not loading.
Nope, this is not possible. It is complex and difficult to find out the actual used font from a font-family
list even in JavaScript - it's impossible in pure CSS.
If you want to go the JavaScript route, here is a link to a clever method to detect the actual font-family in JavaScript.
Once you know the font used, it's easy to adjust element.style.letterSpacing
to the required amount.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With