[Resolved] Best way to use local fonts in style.css?

Home Forums Support [Resolved] Best way to use local fonts in style.css?

Home Forums Support Best way to use local fonts in style.css?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #227104
    Logan

    Tom,

    I posted in another thread about preconnecting sites for Google Fonts. I found a couple websites for downloading fonts from Google and hosting them locally. What is the best way to use a custom font family in the style.css to cover all fonts on the site? I was going to use the following CSS.

    @font-face {
      font-family: 'Oxygen';
      src:  url('fonts/oxygen.woff2') format('woff2'),
            url('fonts/oxygen.woff') format('woff'),
            url('fonts/oxygen.ttf') format('truetype');
            url('fonts/oxygen.svg#Oxygen') format('svg');
    }
    
    @font-face {
      font-family: 'OxygenMono';
      src:  url('fonts/oxygen_mono.woff2') format('woff2'),
            url('fonts/oxygen_mono.woff') format('woff'),
            url('fonts/oxygen_mono.ttf') format('truetype');
            url('fonts/oxygen_mono.svg#OxygenMono') format('svg');
    }
    body,
    button,
    input,
    select,
    textarea, 
    html {                                                                                                                                                                                                                                        
      font-family: 'Oxygen';
    }
    #227145
    Tom
    Lead Developer
    Lead Developer

    Yea, you can do that, just make sure the file you’re adding it to (style.css) has a fonts folder in the same directory.

    You’ll want to make a child theme to do this.

    Let me know if you need more info πŸ™‚

    #227574
    Logan

    I’m good now, thanks! Just needed to know which selectors to use!

    #425545
    Fernando

    Hi
    I’d like to do the same, but calling the font files from CSS field from customizer.
    How would be the path is I am placing the fonts in one folder (‘fonts’) of my child theme?
    Regards

    #425547
    Fernando

    I just figured out. I have to put the absolute URL paths. πŸ˜›
    Thanks anyway.

    #425576
    Leo
    Staff
    Customer Support

    Glad you figured out πŸ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.