PHP code example of adamb / google-fonts

1. Go to this page and download the library: Download adamb/google-fonts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adamb / google-fonts example snippets



Fonts\GoogleFonts;

$googleAPIKey = 'my-api-key';

$fonts = new GoogleFonts($googleAPIKey);


// Lists the fonts with a weight of 300
$fonts->getFontsByWeight(300); // Returns array

// Lists the fonts with a weight of 500 and italic
$fonts->getFontsByWeight('500italic'); // Returns array

// Lists all of the fonts with the latin subset
$fonts->getFontsBySubset('latin'); // Returns array

// Lists all of the serif fonts
$fonts->getFontsByType('serif'); // Returns array

// Lists all of the handwriting fonts
$fonts->getFontsByType('handwriting'); // Returns array


$weights = $fonts->getFontWeights();
print_r($weights);

$subsets = $fonts->getFontSubsets();
print_r($subsets);

$types = $fonts->getFontTypes();
print_r($types);