Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify custom name for a Google Font?

Here is a sample CSS

h1 {
   font-family: 'header-font', arial, sans-serif;
}

p {
   font-family: 'paragraph-font', arial, serif;
}

Is it possible to load any remote Google Font (let say 'Lato') so that it's family name in CSS would be 'header-font'?

Edit: The idea behind this is to be able to easily swap fonts in a WP theme. Unfortunately using variables in CSS preprocessors is not an option in my case.

like image 838
Vilius Paulauskas Avatar asked Jan 10 '13 13:01

Vilius Paulauskas


2 Answers

I don't think you can to be honest. The Google font has a predefined name when you view the google font. See this for example: http://fonts.googleapis.com/css?family=Akronim

Its name is set as 'Akronim' and I dont think you can reference it by any other name.

like image 59
azzy81 Avatar answered Sep 21 '22 20:09

azzy81


Yes, very easily. Once you located the font at Google, eg.

@import url('https://fonts.googleapis.com/css?family=Lato:400&subset=latin-ext');

just direct your browser to the url specified:

https://fonts.googleapis.com/css?family=Lato:400&subset=latin-ext

What you get back is the @font-face CSS item for the font (or fonts). Simply use this verbose version in your CSS instead of the original @import specification. You can freely rename the font-family item in any of these descriptions. Yes, you have to make sure there are no clashes with other fonts but the naming is completely up to you.

like image 31
Gábor Avatar answered Sep 23 '22 20:09

Gábor