Reputation: 4701
When we import a font from Google we can use the following to reference it
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&lang=en" />
In this example you can see I'm using a font with 4 font weights
I now want to embed the fonts so I can use them locally. Within google-fonts I can download them but this means I download multiple fonts.
Where as previously I could do
.myCss {
font-family:myGoogleFont;
font-weight:700;
}
Can I achieve the same when I embed the fonts or do I have to do:
@font-face {
font-family: myRegularFont;
src: url(myGoogleFont-Regular.tff);
}
@font-face {
font-family: my300Font;
src: url(myGoogleFont-300.tff);
}
@font-face {
font-family: my400Font;
src: url(myGoogleFont-400.tff);
}
etc
Upvotes: 0
Views: 58
Reputation: 584
You can do something like the following:
// Normal
@font-face {
font-family: myRegularFont;
font-style: normal;
font-weight: 400; // 400 is considered normal
src: url(myGoogleFont-Regular.tff);
}
// Thin
@font-face {
font-family: myRegularFont;
font-style: normal;
font-weight: 300;
src: url(myGoogleFont-300.tff);
}
// Semi-bold
@font-face {
font-family: myRegularFont;
font-style: normal;
font-weight: 500;
src: url(myGoogleFont-500.tff);
}
// Italic
@font-face {
font-family: myRegularFont;
font-style: italic;
font-weight: 400;
src: url(myGoogleFont-italic.tff);
}
Upvotes: 1