2017 © Pedro Peláez
 

library google-fonts

Get a list of Google Fonts and search by type or weight

image

adamb/google-fonts

Get a list of Google Fonts and search by type or weight

  • Tuesday, February 27, 2018
  • by AdamBinnersley
  • Repository
  • 1 Watchers
  • 2 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 43 % Grown

The README.md

Build Status Scrutinizer Quality Score Minimum PHP Version, (*1)

Google Fonts Lists PHP

Produces a PHP array of all of the fonts available in Google Fonts searchable by weight/subset/type;, (*2)

Installation

Installation is available via Composer/Packagist:, (*3)

composer require adamb/google-fonts

You will also need to obtain a Google Fonts API key to use this package., (*4)

Usage

Example of usage can be found below:, (*5)

Set-up

<?php
require "vendor\autoload.php";

use Fonts\GoogleFonts;

$googleAPIKey = 'my-api-key';

$fonts = new GoogleFonts($googleAPIKey);

List Fonts

You can list fonts using 3 different methods (getFontsByWeight($weight), getFontsBySubset($subset) and getFontsByType($type)., (*6)

Example Usage

// 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

List Types Available

You can list the available options using 1 of 3 different methods (getFontWeights(), getFontSubsets() or getFontTypes()), (*7)

Font Weights

PHP
$weights = $fonts->getFontWeights();
print_r($weights);
HTML Output
Array ( [0] => 100 [1] => 100italic [2] => 200 [3] => 200italic [4] => 300italic [5] => italic [6] => regular [7] => 300 [8] => 500 [9] => 500italic [10] => 600 [11] => 600italic [12] => 700 [13] => 700italic [14] => 800 [15] => 800italic [16] => 900 [17] => 900italic ) 

Font Subsets

PHP
$subsets = $fonts->getFontSubsets();
print_r($subsets);
HTML Output
Array ( [0] => arabic [1] => bengali [2] => cyrillic [3] => cyrillic-ext [4] => devanagari [5] => greek [6] => greek-ext [7] => gujarati [8] => gurmukhi [9] => hebrew [10] => kannada [11] => khmer [12] => korean [13] => latin [14] => latin-ext [15] => malayalam [16] => myanmar [17] => oriya [18] => sinhala [19] => tamil [20] => telugu [21] => thai [22] => vietnamese )

Font Types/Categories

PHP
$types = $fonts->getFontTypes();
print_r($types);
HTML Output
Array ( [0] => display [1] => handwriting [2] => monospace [3] => sans-serif [4] => serif ) 

License

This software is distributed under the MIT license. Please read LICENSE for information on the software availability and distribution., (*8)

The Versions

27/02 2018

dev-master

9999999-dev

Get a list of Google Fonts and search by type or weight

  Sources   Download

MIT

The Requires

 

The Development Requires

27/02 2018

v1.0

1.0.0.0

Get a list of Google Fonts and search by type or weight

  Sources   Download

MIT

The Requires

 

The Development Requires