Tagged: google fonts
-
AuthorPosts
-
May 10, 2016 at 12:32 pm #629848
Hi Kriesi
I would like to add a new Google Font as an option for my headings in advanced styling.
Now i go to Google fonts and i wish to add Roboto Slab.
The Javascript they give me is<script type="text/javascript"> WebFontConfig = { google: { families: [ 'Roboto+Slab::latin' ] } }; (function() { var wf = document.createElement('script'); wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'true'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })(); </script>
How should i use this in my child theme’s functions.php ?
is the below correct, and which name do i use, where does Google show the name of the font and how you have to
type it, is it “Roboto Slab or Roboto+Slab” .//Google Fonts add_filter( 'avf_google_heading_font', 'avia_add_heading_font'); function avia_add_heading_font($fonts) { $fonts['Roboto+Slab'] = 'Roboto+Slab :400,700'; $fonts['Roboto+Slab'] = 'Roboto+Slab :400,700,400italic,700italic'; return $fonts; } add_filter( 'avf_google_content_font', 'avia_add_content_font'); function avia_add_content_font($fonts) { $fonts['Source Sans Pro'] = 'Source Sans Pro:400,700'; $fonts['Source Sans Pro'] = 'Source Sans Pro:400,700,400italic,700italic'; return $fonts; }
and another question is if i want the font to be bolder like 400,500,700 weight should i add tha as well and how?
Thanks a mill for your time
- This topic was modified 8 years, 6 months ago by waveshaper.
May 11, 2016 at 6:55 am #630455Hey indieweb,
Did you try following this tutorial? http://kriesi.at/documentation/enfold/register-additional-google-fonts-for-theme-options/
Best regards,
RikardMay 11, 2016 at 10:31 am #630563Hi Rikard
Yes, thank you, it works.
what i want to know is if i add numerous Google fonts should the code be like the following://Google Fonts add_filter( 'avf_google_heading_font', 'avia_add_heading_font'); function avia_add_heading_font($fonts) { $fonts['Roboto Slab'] = 'Roboto Slab:400,700'; $fonts['Roboto Slab'] = 'Roboto Slab:400,700,400italic,700italic'; return $fonts; } add_filter( 'avf_google_content_font', 'avia_add_content_font'); function avia_add_content_font($fonts) { $fonts['Roboto Slab'] = 'Roboto Slab:400,700'; $fonts['Roboto Slab'] = 'Roboto Slab:400,700,400italic,700italic'; return $fonts; } add_filter( 'avf_google_heading_font', 'avia_add_heading_font'); function avia_add_heading_font($fonts) { $fonts['Oswald'] = 'Oswald:400,700'; $fonts['Oswald'] = 'Oswald:400,700,400italic,700italic'; return $fonts; } add_filter( 'avf_google_content_font', 'avia_add_content_font'); function avia_add_content_font($fonts) { $fonts['Oswald'] = 'Oswald:400,700'; $fonts['Oswald'] = 'Oswald:400,700,400italic,700italic'; return $fonts; } add_filter( 'avf_google_heading_font', 'avia_add_heading_font'); function avia_add_heading_font($fonts) { $fonts['Roboto Condensed'] = 'Roboto Condensed:400,700'; $fonts['Roboto Condensed'] = 'Roboto Condensed:400,700,400italic,700italic'; return $fonts; } add_filter( 'avf_google_content_font', 'avia_add_content_font'); function avia_add_content_font($fonts) { $fonts['Roboto Condensed'] = 'Roboto Condensed:400,700'; $fonts['Roboto Condensed'] = 'Roboto Condensed:400,700,400italic,700italic'; return $fonts; }
Is that the correct way?
Thanks a mill, just need some clarity on thisMay 12, 2016 at 5:50 am #631130Hi,
I can’t see any obvious problems with the code except you seem to have some duplicate code, like for instance:
$fonts['Roboto Condensed'] = 'Roboto Condensed:400,700'; $fonts['Roboto Condensed'] = 'Roboto Condensed:400,700,400italic,700italic';
I think you can remove the first line completely since your importing the same font on the second line as well.
Regards,
RikardMay 12, 2016 at 9:32 am #631239Hi Rikard
Thank you so much for your input, that clears it up for me.
Excellent support.
CheersMay 13, 2016 at 5:38 am #631794 -
AuthorPosts
- You must be logged in to reply to this topic.