How to turn off the Font Library in WordPress

WordPress 6.5 added the Font Library, which lets you install fonts and upload your own right in the Site Editor. In WordPress 7.0, it also got its own screen in the admin, under “Appearance” → “Fonts”.

Exploring new typefaces and finding the right one for a project is one of my favorite parts of this job, and the Font Library makes it so much easier to try out and manage fonts on your WordPress site. It’s a wonderful, long-anticipated addition to the editor.

It can also be a double-edged sword. If you manage sites for clients, you might not want to make it too easy for them to replace your carefully selected type combinations with whatever is at the top of Google Fonts on any particular day.

The code snippet that’s been going around for turning off the Font Library since 6.5 still removes it from the editor, but not from the new Fonts screen. Here’s how to turn off both.

How to turn off the Font Library

The code below does three things: it removes the Font Library from the editor, removes “Fonts” from the “Appearance” menu, and blocks the Fonts screen for anyone who goes to it directly. The best place for it is a must-use plugin, so it keeps working whichever theme you use, and can’t be deactivated by accident:

  1. Connect to your site with an SFTP client, and open the wp-content folder.
  2. Create a folder called mu-plugins, if there isn’t one already.
  3. In it, create a file called turn-off-font-library.php with the code below.
<?php
/**
* Plugin Name: Turn Off Font Library
* Description: Removes the Font Library from the editor and the Fonts screen from the admin.
*/
/**
* Removes the Font Library from the editor.
*
* @param array $settings The editor settings.
* @return array The modified editor settings.
*/
function my_turn_off_font_library( $settings ) {
$settings['fontLibraryEnabled'] = false;
return $settings;
}
add_filter( 'block_editor_settings_all', 'my_turn_off_font_library' );
/**
* Removes the Fonts screen from the Appearance menu.
*/
function my_remove_fonts_menu() {
remove_submenu_page( 'themes.php', 'font-library.php' );
}
add_action( 'admin_menu', 'my_remove_fonts_menu' );
/**
* Blocks direct access to the Fonts screen.
*/
function my_block_fonts_screen() {
wp_die( esc_html__( 'The Font Library is turned off on this site.' ), '', array( 'response' => 403 ) );
}
add_action( 'load-font-library.php', 'my_block_fonts_screen' );

Reload the admin, and “Fonts” is gone from the “Appearance” menu. In the Site Editor, the Fonts section is gone from “Styles” → “Typography”, so there’s no way to install or upload new fonts. You can still choose between the fonts that are included with your theme or plugins, or that you’ve already installed, when you style text, headings and other elements.

If you have the Gutenberg plugin installed, it replaces the Fonts screen with its own version at a different address, which the code above doesn’t catch. To turn that one off too, add these lines to the end of the file:

/**
* Removes the Fonts screen added by the Gutenberg plugin.
*/
function my_remove_gutenberg_fonts_menu() {
remove_submenu_page( 'themes.php', 'font-library-wp-admin' );
}
add_action( 'admin_menu', 'my_remove_gutenberg_fonts_menu', 20 );
add_action( 'load-appearance_page_font-library-wp-admin', 'my_block_fonts_screen' );

Keep in mind that the Gutenberg plugin is where new editor features are developed and tested before they make it into WordPress, so it changes often. A future version could rename the Fonts screen, and these lines would stop working without any warning.

What happens to fonts you’ve already installed

Turning off the Font Library doesn’t remove any fonts. If you’ve installed a font and used it on your site, it keeps loading for your visitors, and you can still select it when you style an element. The font files stay in wp-content/uploads/fonts, so if you want to get rid of them, remove them in the Font Library before you add the plugin.

There’s a proposal in Gutenberg to make this a lot easier, with a font-library theme support that themes could turn off with a single line of code. It hasn’t been merged yet, but if it makes it into a future version of WordPress, I’ll update this tutorial.