The Test Team helps manage testing and triage across the WordPress ecosystem. They focus on user testing of the editing experience and WordPress dashboard, replicating and documenting bug reports, and supporting a culture of review and triage across the project.
Please drop by any time in SlackSlackSlack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. with questions or to help out.
Understanding and Testing Font Library Feature with block editor theme
Font Library in WordPress 6.5 allows users to opt-in to a collection listing for Google Fonts. To comply with GDPR, installing a Google Font uploads the file to the site. When a Font Collection is registered, it will appear in the Font Library UIUIUI is an acronym for User Interface - the layout of the page the user interacts with. Think ‘how are they doing that’ and less about what they are doing. in the editor. From here, users can install and activate fonts from the collection.
Before we start testing, we need to first prepare the test environment.
Test Setup
Local Environment
If you have a local development environment running WordPress 6.5 to get started.
Navigate to Plugins > Add NewPluginPluginA plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party and install and activateGutenbergGutenbergThe Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/.
WordPress Playground
To test only using your browser (no installation required), try out Playground. These links open WordPress directly in your browser and automatically install Gutenberg so that you can start testing right away.
(Playground limitation: Due to browser network security policies, you will be unable to test installation of Google fonts. However, you can test uploaded fonts.)
Things to Test
Here are some suggestions for functionality to test, but you are encouraged to experiment beyond these:
Upload fonts using the upload dialog and drag-and-drop.
Install fonts from Google Fonts using the Install Fonts tab.
Verify that uploaded/installed font assets are stored in your site’s /wp-content/fonts/ directory.
Activate/deactivate individual font variants.
Compare active fonts with the list on the Styles > TypographysidebarSidebarA sidebar in WordPress is referred to a widget-ready area used by WordPress themes to display information that is not a part of the main content. It is not always a vertical column on the side. It can be a horizontal rectangle below or above the content area, footer, header, or any where in the theme..
Assign custom fonts to elements (like text or headings) on the Styles > Typography sidebar.
Assign custom fonts to specific blockBlockBlock is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. types (like buttons) in Styles > Blocks.
Check how the fonts appear on your site’s frontend.
Delete an uploaded font family, and verify that the font assets are removed from /wp-content/fonts/
So these are the possible areas which we should consider testing. Later part of this post explains some of them with details along with step by step instructions.
Let’s check on how we can achieve this.
When you go to the Dashboard -> themes -> editor -> Choose the component (Navigation, Templates, Patterns, Style etc)-> site icon.
Here, click on the style icon, and it will open up an option for typography. This shows us the fonts.
Now, once you click on this icon, you will get a font manager option here. And with the help of it one can install, upload, activate/deactivate, delete the fonts.
In the font manager you can see what fonts you have and look at the variants from the Library tab.
Here, on the Upload tab you can upload fonts if you have already uploaded some, and it tells you the formats that are acceptable.
And on the Install Fonts tab you can install Google Fonts.
These are the main areas of the Font Library. Now, let’s go into the details on how we can test this from various aspects.
1. Font Collections: Editor View/Admin
Test Scenario:Verify that Font Collections are correctly displayed in the Font Library UI and can be installed and activated by the user.
Steps to Test:
Log in to the site dashboard as an administrator.
Navigate to a post or page editor.
Locate the Font Library UI section.
Click on the Font Manager Icon.
Try installing and activating fonts from the available Font Collection.
Ensure that the font appears in Typography after the installation, and the user should be able to use it; the changes should be reflected based on selected fonts in the Editor and on the frontend.
Ensure that search and categoryCategoryThe 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging. filters are working properly.
2. Adding and Removing Font Collections Programmatically
Test Scenario: Ensure that Font Collections can be added and removed programmatically using the provided functions.
Steps to Test:
Try avoiding the theme’s function.php file. Instead, create a custom plugin with a given code snippet.
Use wp_register_font_collection() to add a new Font Collection.
Verify that the newly added collection appears in the Font Library UI.
Use wp_unregister_font_collection() to remove a Font Collection.
Confirm that the removed collection is no longer available in the Font Library UI and is gone from the fonts folder (by default, it is /wp-content/fonts/).
We can add a list of font families with their font faces in either PHPPHPPHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. http://php.net/manual/en/intro-whatis.php. or JSONJSONJSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. format as part of the Font Collection array.
The JSON format for the font_families field can be a local path or a remote URLURLA specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org that points to the JSON file. Please walk through the code shared below when using PHP to add Font Collection.
Test Scenario: Validate the process of installing, activating, and deactivating fonts within the Font Library.
Steps to Test:
Install a font from a Font Collection.
Verify that the font settings are saved.
Activate the installed font and check if it reflects in Global Styles.
Switch to a new theme and ensure installed fonts can be reactivated.
Deactivate a font and confirm its removal from Global Styles.
4. Customizing Fonts Upload Directory location
Test Scenario: Test the customization of the fonts upload directory and ensure proper functionality.
Steps to Test:
Modify the fonts upload directory using the font_dirfilterFilterFilters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output..
Check if fonts are uploaded to the specified directory.
Verify that wp_get_font_dir() returns the customized directory path.
Ensure that the chosen directory has correct permissions for file operations.
For example, wp-content/uploads directory, the fonts upload directory will not adhere to wp_is_file_mod_allowed / DISALLOW_FILE_MODS to prevent font uploads. Alternatively, if we have no clarity on permissions, we can also create a new folder with the current set of permissions.
The example below changes the fonts directory to the WordPress “Uploads” directory (by default, this is /wp-content/uploads/)
Here is the code sample that helps in customizing the fonts.
$fonts_dir = $uploads_basedir . '/fonts'; // Generate the URL for the fonts directory from the font dir. $fonts_url = str_replace( $uploads_basedir, $uploads_baseurl, $fonts_dir );
Test Scenario: Verify that the Font Library can be disabled in terms of both UI and REST APIREST APIThe REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/..
Steps to Test (UI Disable):
Use a filter to customize editor settings and disable the Font Library UI.
Access the post or page editor and confirm the absence of Font Library features.
Use unregister_post_type() to remove Font Library-associated post types and REST API endpoints.
Check if the Font Library functionality is completely disabled without affecting other editor features. This can verified by visiting the APIAPIAn API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. Endpoint URL: /wp-json/wp/v2/font-families
Record or write down by steps how an issue can be reproduced.
Use Test report plugin to collect all essential information about the site you are testing.
Check if there is a related ticket in TracTracTrac is the place where contributors create issues for bugs or feature requests much like GitHub.https://core.trac.wordpress.org/. and add your report to it or create a new one. In the case of the Font Library, start the ticket’s summary with Font Library, the component will be Editor and before the 6.5 release version will be trunk.