Indra_Optus
13 years agoGuide
Custom Font ?
Is it possible to have custom font in Lithium (either buy adding it to Lithium or sourcing it using external URL)? Our company use custom font and would like to use it in Lithium page. We have S...
I've tried using a Google font but it doesn't seem to work -- have I simply done something wrong or does Lithium block external file calls?
Hi Inactive User ,
To use google fonts, you shouldn't have to download and add the font file to your community's assets folder. Just make sure you've added the external link correctly to your header's head content, like so; for the font family Source Sans Pro;
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
When I'm specfing the font in my css, its written like so;
.blah { font-family: 'Source Sans Pro', sans-serif;}
When adding the font to your custom skin's skin property page font values, it should be entered like so;
font-family:Source Sans Pro, sans-serif; font-weight:normal;
Hope this helps
Thanks for the replies. I understand that one doesn't have to upload google fonts -- I've linked it exactly as you have described above :)
Upon inspection of the stage source html the correct css is there, the google font is linked and and right class is being applied in the markup. I wondered if the font didn't work because it couldn't import external files -- now I'm thinking it might be because the css is loaded before the font is.
Is there any way to change the order in which the head wrapper and the custom css is applied?
Hmm no. The load order for css files is the core Base Skin > Your Custom Skin > any css files added in the assets folder, then any css files linked in the head content.
Silly question, but is the custom skin where the font link/css live being applied to the community? Be sure to check via the admin > display > skins and see if the right skin has been set.
I see Paolo asked eariler if you were sourcing fonts over HTTP on a SSL page? Is this the case? Otherwise if what your syntax everywhere else is correct, the fonts should load.
Yup, the right custom skin is set. The fonts are sourced from https://www.google.com/fonts, and I've followed the quick-use instructions; i.e.,
<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
was placed in the header wrapper and embeds the following
@font-face { font-family: 'Bitter'; font-style: normal; font-weight: 700; src: local('Bitter-Bold'), url(http://themes.googleusercontent.com/static/fonts/bitter/v5/evC1haE-MsorTl_A7_uSGbO3LdcAZYWl9Si6vvxL-qU.woff) format('woff'); }
and
.bitter { font-family: ‘Bitter’, Arial, serif; }
was placed in the active skin's custom css. The class was triggered in the markup like so:
<h1 class="bitter">And hopefully custom fonts work too.</h1>
I've also tried loading the font manually in the custom css only, so it doesn't seem to be a loading order problem. Any thoughts?