PHPackages                             justintadlock/hybrid-font - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. justintadlock/hybrid-font

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

justintadlock/hybrid-font
=========================

Helper functions for loading font stylesheets in WordPress themes.

1.1.3(1y ago)136.4k3GPL-2.0-or-laterPHPPHP &gt;=7.4

Since Sep 14Pushed 1y ago5 watchersCompare

[ Source](https://github.com/themehybrid/hybrid-font)[ Packagist](https://packagist.org/packages/justintadlock/hybrid-font)[ Docs](https://github.com/themehybrid/hybrid-font)[ RSS](/packages/justintadlock-hybrid-font/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (9)Used By (0)

Hybrid\\Font
============

[](#hybridfont)

Hybrid Font is a drop-in package that theme authors can use for loading fonts in their WordPress themes.

This package is a set of helper functions primarily for working with Google Web Fonts. The functions are simply wrappers around existing WordPress style-loading functions. The helpers just present a standard API for handling font styles.

The idea for this package came from a [tutorial on adding Google Fonts](https://blog.josemcastaneda.com/2016/02/29/adding-removing-fonts-from-a-theme/) by Jose Castaneda.

Requirements
------------

[](#requirements)

- WordPress 4.9+.
- PHP 7.4+ (preferably 8+)
- [Composer](https://getcomposer.org/) for managing PHP dependencies.

Technically, you could make this work without Composer by directly downloading and dropping the package into your theme. However, using Composer is ideal and the supported method for using this project.

Documentation
-------------

[](#documentation)

The following docs are written with theme authors in mind because that'll be the most common use case. If including in a plugin, it shouldn't be much different.

### Installation

[](#installation)

**Composer:**

First, you'll need to open your command line tool and change directories to your theme folder.

```
cd path/to/wp-content/themes/
```

Then, use Composer to install the package.

```
composer require themehybrid/hybrid-font
```

Assuming you're not already including the Composer autoload file for your theme and are shipping this as part of your theme package, you'll want something like the following bit of code in your theme's `functions.php` to autoload this package (and any others).

The Composer autoload file will automatically load up Hybrid Font for you and make its code available for you to use.

```
if ( file_exists( get_parent_theme_file_path( 'vendor/autoload.php' ) ) ) {
	require_once( get_parent_theme_file_path( 'vendor/autoload.php' ) );
}
```

**Manual:**

If manually installing the package, you simply need to put it in the desired location in your theme and include the bootstrap file like so:

```
require_once( get_parent_theme_file_path( 'path/to/hybrid-font/src/bootstrap-font.php' ) );
```

### Usage

[](#usage)

The primary function that you'll want to use is the `enqueue()` function. You'd load a font like in the following example.

```
add_action( 'wp_enqueue_scripts', function() {

	Hybrid\Font\enqueue( 'themeslug', [
		'family' => [
			'roboto'      => 'Roboto:400,400i,700,700i',
			'roboto-slab' => 'Roboto+Slab:400,700'
		],
		'subset' => [
			'latin',
			'latin-ext'
		]
	] );

} );
```

*Note that the plugin's namespace is `Hybrid\Font`. If you're working within another namespace, you'll want to add a `use` statement after your own namespace call or call `\Hybrid\Font\enqueue()` directly. I'll assume you know what you're doing if you're working with namespaces. Otherwise, stick to the above.*

### Parameters

[](#parameters)

The following parameters are available.

**$handle**

The first parameter is the handle/ID for the font. This should be a unique string.

**$args**

The `$args` parameter is an array of options that you may set. The arguments

- `family` - Array of Google-style font families that you wish to load.
- `display` - String to set the `font-display` CSS property.
- `subset` - Array of Google script subsets.
- `text` - String of specific text you want Google to load the font for.
- `effect` - Array of Google font effects.
- `depends` - Array of stylesheet handles this style depends on.
- `version` - Version of the stylesheet.
- `media` - What type of screen to load this all.
- `src` - A URL to a specific stylesheet to load. Note that this will overwrite any Google-specific arguments and load this stylesheet instead.

See the [Google Fonts documentation](https://developers.google.com/fonts/docs/getting_started) for more detailed docs on using the Google-specific arguments.

### Functions

[](#functions)

```
// Register and load a font stylesheet.
enqueue( $handle, $args = [] );

// Register a font stylesheet.
register( $handle, $args = [] );

// Build a font stylesheet URL.
url( $handle, $args = [] );
```

### Preloading

[](#preloading)

This package will automatically filter `wp_resource_hints` and preload Google Fonts. There's no need to do this yourself.

Copyright and License
---------------------

[](#copyright-and-license)

This project is licensed under the [GNU GPL](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.

2008 – 2024 © [Theme Hybrid](https://themehybrid.com).

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 68% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~358 days

Recently: every ~476 days

Total

7

Last Release

649d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6

1.1.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef868a4b45ef0263f49361744b8bb04e8f3cfcb8f3f79b274fc62823115ee596?d=identicon)[justintadlock](/maintainers/justintadlock)

---

Top Contributors

[![saas786](https://avatars.githubusercontent.com/u/1642796?v=4)](https://github.com/saas786 "saas786 (17 commits)")[![justintadlock](https://avatars.githubusercontent.com/u/1816309?v=4)](https://github.com/justintadlock "justintadlock (8 commits)")

---

Tags

wordpress

### Embed Badge

![Health badge](/badges/justintadlock-hybrid-font/health.svg)

```
[![Health](https://phpackages.com/badges/justintadlock-hybrid-font/health.svg)](https://phpackages.com/packages/justintadlock-hybrid-font)
```

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k222.5k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[justintadlock/hybrid-carbon

God-like post featured image script.

202.5k](/packages/justintadlock-hybrid-carbon)[typisttech/wp-admin-notices

A simplified OOP implementation of the WordPress admin notices

141.2k](/packages/typisttech-wp-admin-notices)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
