The Protostar Template for Joomla 3 comes included with the base Joomla installation. Admin interface allows you to set only the heading font with the google font. I can show you how to add a google font for the body tag.
In order to add this feature I found 2 ways. The 1st one is very easy and fast but it is not enough elegant and not very professional. The first method consists to change only the index.php without change the interface of the template manager. The second method will provide a new field in the template manager module for the "Google Font Name for Body" and every time we want to change the google font for body, we will not need to edit the index.php, but just open Joomla Back-end -> Template Manager and type the font in the new field.
The following changes were applied to Joomla 3.2.3 and Joomla 3.3 (may 4th 2014)
The Protostar Template for Joomla 3 comes included with the base Joomla installation. Admin interface allows you to set only the heading font with the google font. I can show you how to add a google font for the body tag.
In order to add this feature I found 2 ways. The 1st one is very easy and fast but it is not enough elegant and not very professional. The first method consists to change only the index.php without change the interface of the template manager. The second method will provide a new field in the template manager module for the "Google Font Name for Body" and every time we want to change the google font for body, we will not need to edit the index.php, but just open Joomla Back-end -> Template Manager and type the font in the new field.
The following changes were applied to Joomla 3.2.3 and Joomla 3.3 (may 4th 2014)
Create one or more file on /administrator/language/overrides
en-GB.override.ini
it-IT.override.ini
and so on...
In alternative you can use the Joomla Language Override Interface under the menu Components. BTW after you created the file you fille find the entries in component->Language->Override.
TPL_PROTOSTAR_FONT_DESC="Load a Google font for the headings and body (H1, H2, H3, etc. and BODY)"
TPL_PROTOSTAR_FONT_LABEL="Google Font for Headings"
TPL_PROTOSTAR_FONT_NAME_BODY_DESC="Example: Open+Sans or Source+Sans+Pro"
TPL_PROTOSTAR_FONT_NAME_BODY_LABEL="Google Font Name Body"
index.php
Locate the index.php under the "joomla root"/templates/protostar use the ftp to browse the server folders of your site
<?php
// Use of Google Font
if ($this->params->get('googleFont'))
{
?>
<link href='//fonts.googleapis.com/css?family=<?php echo $this->params->get('googleFontName');?>' rel='stylesheet' type='text/css' />
<link href='//fonts.googleapis.com/css?family=<?php echo urlencode($this->params->get('googleFontNameBody'));?>' rel='stylesheet' type='text/css' />
<style type="text/css">
h1,h2,h3,h4,h5,h6,.site-title{
font-family: '<?php echo str_replace('+', ' ', $this->params->get('googleFontName'));?>', sans-serif;
}
body {
font-family: '<?php echo str_replace('+', ' ', $this->params->get('googleFontNameBody'));?>', sans-serif;
}
</style>
The php urlencode(...) is useful to prevent a blank space on font name. It will works but will generate an error on html5 validation.
Since Joomla 3.4.3 my google body fonts does not work.
I had to create a new style /style just before the /head and I copied inside the body style. This is not so elegant but it's the last work around found ;-)