Skip to content

Use Drupal 11.4 fonts key for bundled font preloading#830

Merged
jjroelofs merged 2 commits into
8.xfrom
jur/8.x/825-font-preloading-library-key
Jul 8, 2026
Merged

Use Drupal 11.4 fonts key for bundled font preloading#830
jjroelofs merged 2 commits into
8.xfrom
jur/8.x/825-font-preloading-library-key

Conversation

@jjroelofs

Copy link
Copy Markdown
Collaborator

Linked issues

Solution

Add Drupal 11.4 fonts key to library definitions for the bundled LeagueGothic and ChunkFive fonts, enabling correct browser preloading. Update the font loading code to attach these as standard Drupal libraries instead of injecting raw HTML head elements. Also fix the missing crossorigin attribute on preload links for user-uploaded fonts.

Checklist

  • I have read the CONTRIBUTING.md document.
  • My commit messages follow the contributing standards and style of this project.
  • My code follows the coding standards and style of this project.
  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).
  • Need to run update.php after code changes.
  • Requires a change to end-user documentation.
  • Requires a change to developer documentation.
  • Requires a change to QA tests.
  • Requires a new QA test.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jjroelofs jjroelofs left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup here. I found two issues that should be addressed before merging:

  1. dxpr_theme.libraries.yml: the new fonts entries are YAML lists, but Drupal 11.4 expects font paths as keys with options, e.g.
fonts:
  fonts/leaguegothic/league_gothic-webfont.woff:
    preload: true

As written, core will not produce the intended font preload metadata and can hit missing/invalid font asset data during attachment processing. The Drupal change record documents the keyed structure: https://www.drupal.org/node/3585574.

  1. features/sooper-fonts/fonts-theme-settings-controller.inc: bundled fonts now bypass _dxpr_theme_add_local_font() for all installs, but dxpr_theme.info.yml still advertises Drupal ^9.3 || ^10 || ^11. On Drupal versions before 11.4, the fonts key is not processed, so LeagueGothic/ChunkFive lose the previous manual preload behavior. Either the core requirement needs to move to Drupal 11.4+, or this should keep a version-guarded fallback for older supported cores.

I also checked the current PR state: CI is green, and php -l plus git diff --check pass locally.

Use keyed format with preload option for the fonts library key
instead of list format, as required by Drupal 11.4. Add a version
check so the library approach is only used on Drupal 11.4+,
falling back to _dxpr_theme_add_local_font() on older versions.
@jjroelofs jjroelofs merged commit 01a7ff0 into 8.x Jul 8, 2026
5 checks passed
@jjroelofs jjroelofs deleted the jur/8.x/825-font-preloading-library-key branch July 8, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactoring: use Drupal 11.4 fonts key for local font preloading

1 participant