Skip to main content
Documentation/Developers/APIs/Hooks Reference/Fonts

Fonts

Register before the font controller is first used. breakdance_register_fonts receives BreakdanceFontsFontsController:

PHP
add_action('breakdance_register_fonts', function ($fontsController) {
    $fontsController->registerFont(
        'acme-interface',
        '"Acme Interface"',
        'Acme Interface',
        'sans-serif',
        ['styles' => [plugins_url('fonts/interface.css', __FILE__)]]
    );
});

Supply the stylesheet and font files with matching @font-face family names.

PHP
registerFont($slug, $cssName, $label, $fallbackString, $dependencies,
             $previewImageUrl = null, $category = null, $variants = null);

Returns nothing. First four arguments are strings; dependencies use the element structure without conditions. Preview/category are optional strings; variants use font-variant records.

Disable Google Fonts Registration

breakdance_register_font($font) returns a font record or false to omit it:

PHP
add_filter('breakdance_register_font', function ($font) {
    return !empty($font['dependencies']['googleFonts']) ? false : $font;
});

This does not remove fonts loaded through other paths.

Change the Google Fonts Stylesheet URL

breakdance_google_fonts_url($url) returns the generated stylesheet URL string. Its replacement must serve compatible CSS; font-file URLs inside are not automatically rewritten.

The Google Fonts registration example is also covered in the canonical hooks reference.