Tagged: @font-face, child theme, custom.css, Fonts, webfont
-
AuthorPosts
-
October 28, 2014 at 3:26 am #341947
Hi folks, this is my first post after reading quite a lot. I’ve done some thorough searching but I’m having no luck, in spite of the similar posts.
I’m seeking to add a custom web font, Verb Condensed, to my Enfold site to use across header and body styles, and generally throughout the site. I’m familiar with the @font-face protocol, and I have that working on my current website which does not use Enfold.
Here’s what I’ve done so far:
1. Uploaded the web font files (EOT, SVG, TTF, and WOFF) to a folder within my “enfold-child” folder called
css/webfonts/
2. I updated thestyles.css
in the Child Theme to include those. Here’s a sample:@font-face { font-family: 'VerbCond Light Italic'; src: url('css/webfonts/verbcond-light-italic.eot'); src: url('css/webfonts/verbcond-light-italic.eot?#iefix') format('embedded-opentype'), url('css/webfonts/verbcond-light-italic.woff') format('woff'), url('css/webfonts/verbcond-light-italic.ttf') format('truetype'), url('css/webfonts/verbcond-light-italic.svg#ywftsvg') format('svg'); font-weight: normal; font-style: normal; }
3. I’ve added another line in the
styles.css
file to give some of the site styles the ‘VerbCond’ typefacebody { font-family: 'VerbCond Regular', sans-serif !important; }
The result is that everything appears as Helvetica. It seems to be half-working, in that I’ve stripped the formatting from the drop-down menus within Theme Options > General Styling > General, but it’s not recognizing the Verb Condensed files I’ve uploaded. The site is also very slow to load.
Can anyone advise how to sort this out? I know you get this question a lot, in slightly different forms, so appreciate your insight.
Should I make modifications to a different CSS file aside from styles.css? Should I upload the font files to a different folder location? Is there a reason I should only use fontsquirrel or some other protocol?
If possible, I’d like to add Verb Condensed to the drop-down menu so I can simply select it, rather than having to write a custom style for every use case.
October 29, 2014 at 8:16 am #342596Hey!
Try adding this at the very end of your theme / child theme functions.php file:
add_filter( 'avf_google_content_font', 'add_custom_font'); add_filter( 'avf_google_heading_font', 'add_custom_font'); function add_custom_font($fonts) { $fonts['VerbCond Regular'] = 'VerbCond Regular'; return $fonts; }
That should make appear the “VerbCond Regular” font in the Theme Options dropdowns, but it will only work if the @font-face inclusion is working correctly.
Cheers!
JosueOctober 29, 2014 at 3:48 pm #342759Hi Josue,
The code bits did add VerbCond Regular to the drop-down list. Thanks for the advice! But unfortunately the @font-face is still not working.
I have used Verb Condensed on another WordPress website with a different, more basic, theme. It was a very straightforward process, which is why it’s so frustrating here. My first thought is that it’s something to do with the Child Theme, since I don’t have one on the other site. Should I modify my main Enfold files? Or is there something wrong with my CSS to begin with?
The drop-down thing is a nice little bonus, but I appreciate any insight into the main question — how to get an outside webfont to load. I see this is a common question, but unfortunately none of the straightforward solutions presented seem to work for me.
October 29, 2014 at 4:12 pm #342772Ok, quick update. I seem to have solved the @font-face issue by changing the CSS so the URL is an absolute link to the font files … on my other website! Here’s the code:
@font-face { font-family: VerbCond Regular; src: url(https://busycreator.com/wp-content/themes/Busy%20Creator%201.0/css/webfonts/verbcond-regular.eot); src: url(https://busycreator.com/wp-content/themes/Busy%20Creator%201.0/css/webfonts/verbcond-regular.eot?#iefix) format('embedded-opentype'), url(https://busycreator.com/wp-content/themes/Busy%20Creator%201.0/css/webfonts/verbcond-regular.woff) format('woff'), url(https://busycreator.com/wp-content/themes/Busy%20Creator%201.0/css/webfonts/verbcond-regular.ttf) format('truetype'), url(https://busycreator.com/wp-content/themes/Busy%20Creator%201.0/css/webfonts/verbcond-regular.svg#ywftsvg) format('svg'); font-weight: normal; font-style: normal; }
As you can see, I’m linking to the files on http://busycreator.com. The same files are indeed uploaded to my Enfold site, but for some reason I can make a reference to the relative files. I’d prefer to keep this as a relative URL in case I have to make future updates or move the same code to another installation. Should I redirect to a parent directory, such as ../enfold/ rather than within the /enfold-child/ folder?
I’ll stick with the workaround for now, but I’d love if someone persnickety could examine my CSS and advise. Thanks for your help so far.
October 29, 2014 at 4:57 pm #342806You are welcome, alternatively you can use a plugin solution for the @font-face inclusion, like WP Font Face.
Regards,
JosueOctober 31, 2014 at 1:11 am #343817To follow up, I managed to use a relative URL, but it required I move the /webfonts/ folder outside of both the child theme and main enfold folder and put it directly in /wp-content/. Not sure why that worked, but it seems to be the trick to a relative URL in the CSS.
October 31, 2014 at 2:35 am #343835In that case you could create a “/fonts” folder in the root of the installation so you don’t have to alter the wp-content structure.
Regards,
JosueNovember 11, 2014 at 7:45 pm #349630I’m having exactly the same problem however none of the solutions posted here have worked for me.
If you move the fonts folder into the root of the installation, you should be able to access with /fonts as the URL, correct? Tried this and it’s not working either.
Any suggestions would be appreciate. This is driving me insane.
November 11, 2014 at 7:49 pm #349631Hi,
Can you post the link to your website please? FTP and Dashboard access may be needed too.
Regards,
JosueNovember 11, 2014 at 7:53 pm #349632This reply has been marked as private.November 11, 2014 at 8:12 pm #349641Hi!
Font inclusion is working, the problem resides in the font declaration, for example:
The font it’s declared like this in @font-face:font-family:"ITCFranklinGothicW01-Dm_812677";
But It’s like this down below:
font-family:"ITCFranklinGothicW01-Dm 812677";
Make sure it is exactly the same in all iterations.
Best regards,
JosueNovember 11, 2014 at 9:18 pm #349674Thank you so much for catching that. Been banging my head against the wall for hours.
November 11, 2014 at 10:14 pm #349700You are welcome, always glad to help :)
Regards,
JosueOctober 12, 2015 at 12:51 pm #517312Thank for the help, I works great for me, but now how can I change the font size?
I tried to add
.h1{ font-size: 124pt !important; }
to te custom css, but it doesn’t work.
thanks
October 12, 2015 at 2:42 pm #517372 -
AuthorPosts
- You must be logged in to reply to this topic.