0

I'm trying to include my own font to my drupal website. I've got a custom.css file in my theme inside 'sites/all/themes/mytheme/css' folder. My fonts are in my 'sites/all/themes/mytheme/fonts' folder. The css is called from the template.php in my theme folder. This is my css code right now:

@font-face {
    font-family: 'slashbadass_black';
    src: url('../fonts/Myfont.eot');
    src: url('../fonts/Myfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/Myfont.woff2') format('woff2'),
         url('../fonts/Myfont.woff') format('woff'),
         url('../fonts/Myfont.ttf') format('truetype'),
         url('../fonts/Myfont.svg#slashbadass_black') format('svg');
    font-weight: normal;
    font-style: normal;
} 

So is this path OK? For what I've seen the font-family is not available right now.

1 Answer 1

0

Define your css in mytheme.info:

stylesheets[all][] = css/style.css

@font-face {
  font-family: "Oswald";
  src: url(../fonts/oswald.eot?#iefix) format("embedded-opentype"),
     url(../fonts/oswald.woff) format("woff"),
     url(../fonts/oswald.ttf) format("truetype"), 
     url(../fonts/oswald.svg) format("svg")
}

instead of template.php

3
  • I'm adapting an external theme so I try to follow the same structure. If i call the css file from theme.info the path will be fine as it is? Commented Oct 21, 2015 at 11:50
  • I have it so in all my Drupal projects so it will work Commented Oct 21, 2015 at 11:58
  • It worked as you said but the real problem was not having the fonts on the server. Commented Oct 22, 2015 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.