Site logo

Archived topic

Can't have local font

1 reply · Started by Hung on November 22, 2021

Viewing posts 1–2 of 2

Not sure why, but I have added CSS, loaded functions, but Typography in Customize doesn't show my local font. It is still showing Google fonts, even I added removed functions. No cache plugin. Any idea? Thanks.

CSS

@font-face {
    font-family: 'Optima';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local(''),
         url('https://my-domain/wp-content/themes/theme-gp/fonts/optima.woff2') format('woff2');
  }
  @font-face {
    font-family: 'Optima';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: local(''),
         url('https://my-domain/wp-content/themes/theme-gp/fonts/optima-italic.woff2') format('woff2');
  }
  @font-face {
    font-family: 'Optima';
    font-style: bold;
    font-weight: 700;
    font-display: swap;
    src: local(''),
         url('https://my-domain/wp-content/themes/theme-gp/fonts/optima-bold.woff2') format('woff2');
  }

Double-check the URLs already.

functions.php

/* remove default Google fonts */
add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-fonts' );
} );
add_action( 'admin_init', function() {
    add_filter( 'generate_google_fonts_array', '__return_empty_array' );
} );

/* add local font */
add_filter( 'generate_typography_default_fonts', function( $fonts ) {
    $fonts[] = 'Optima';

    return $fonts;
} );

local font

Hi there,

It doesn't appear in the list - just add the name of the Font in the Font family name field

This archived topic is closed to new replies.