WordPress – Google Fonts not working in .php file

  css, javascript, jquery, php, wordpress

I the use ‘Flexible Invoices for WooCommerce PRO’ plugin and I have a problem. Based on the .php file, a .pdf file is generated.
I add a link to the Poppins font to the .php file, but after opening the file on the web page, the fonts do not work. Ultimately, it is supposed to be a pdf file.
I tried different points:

  1. I added to the section and to the container
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:[email protected];300;400;500;600;700;900&display=swap" rel="stylesheet">
body, p, tr, th, td {font-family: 'Poppins', sans-serif!important;}
  1. I used the @import option:
@import 'https://fonts.googleapis.com/css2?family=Poppins:[email protected];300;400;500;600;700;900&display=swap';
  1. I used a separate .css file with @media print {}
  2. I added a function to the functions.php file
function wpb_add_google_fonts() {
   wp_enqueue_style( 'wpb-google-fonts', 'https://fonts.googleapis.com/css2?family=Poppins:[email protected];300;400;500;600;700;900&display=swap', false );
   }
   
   add_action( 'wp_enqueue_scripts', 'wpb_add_google_fonts' );

Unfortunately, the Poppins font still does not work. Do you have any ideas on how to fix it?

Source: Ask Javascript Questions

LEAVE A COMMENT