Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use italic google fonts?

Tags:

html

css

fonts

So I'm trying to use an italic version of the Google font Roboto.

This is the bit of code Google gave me for the fonts I chose...

<link href='http://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700|Roboto:300,100italic' rel='stylesheet' type='text/css'>

I can get it to apply Roboto Slab and Roboto but I'm not sure how to get it to use Roboto Italic.

I can do...

font-style: italic;

But you can do that with any font and get a faux italic. I want the real italic Google font.

Anyone know how to use Italic Google fonts correctly?

like image 964
Arsinek Avatar asked Mar 08 '15 23:03

Arsinek


People also ask

How do I put fonts in italics?

To make your selected text italic or start writing text in italic, press the Ctrl + I keys on your keyboard. To make your selected text underlined or start writing underlined text, press the Ctrl + U keys on your keyboard.

Can I use font style italic?

The font-style property allows you to make text appear italicized (i.e. sloped, or slanted). This property accepts one of three possible values: normal , italic , and oblique . If a given font family has an italic or oblique face embedded, the browser will select that face.

Why is my Google font italics?

Check “Customize fonts…” in the settings, you may have italics font selected (happened to me in some other app). To keep (99% of) your data set up a Google account and enable syncing of everything. After you reinstall it will restore it.


1 Answers

The correct way to apply italic font styles with google fonts is to use

font-style: italic;

for a bold font weight use

font-weight: bold;

The problem you're running into is that you're not including the appropriate font-weight for the italic font.

If you want font-weight: normal; font-style: italic to work, you need to include the 400, and 400italic versions:

http://fonts.googleapis.com/css?family=Roboto:400,400italic

The reason font-style: italic will work is because the font-declarations are set up to specify their appropriate style and weight. If you look at a the source for the link above, you'll find:

@font-face {
  font-family: 'Roboto';
  font-style: italic;
  font-weight: 400;
  src: ...sources...
}

Having the font-weight and font-style declared allows the font to take over at the specified weight and style. This can be used to reverse font-styles in situations such as where you might want a blockquote to appear italicized and emphasized text to appear normal.

If no overriding font-file is specified for the style and weight, then the browser will do its best to render a faux italic or faux bold.

like image 76
zzzzBov Avatar answered Sep 30 '22 09:09

zzzzBov