using private files download default breaks fontyourface

Created on 22 November 2023, 12 months ago
Updated 12 July 2024, 4 months ago

Problem/Motivation

Have used @fontyourface for several years and love the ability to choose distinctive fonts for the look I want.

After the default file download path changed to private, when I load site pages, I get a lot of warning messages and the selected fonts are not showing up.


I also recently updated Drupal to version 10.1.6 and along with it @fontyourface to version 4.0.0 but I had this problem also with 9.5.10 and @fontyourface 3.6.

Steps to reproduce

  1. Set the Default download method to private in /admin/config/media/file-system
  2. Load a site page (home page or anything)
  3. See lots of warnings like this one:
  4. Warning: file_get_contents(private://fontyourface/font_display/headers.css): Failed to open stream: "Drupal\Core\StreamWrapper\PrivateStream::stream_open" call failed in Drupal\Core\Asset\CssCollectionOptimizerLazy->generateHash() (line 43 of /var/www/html/web/core/lib/Drupal/Core/Asset/AssetGroupSetHashTrait.php)

  5. Also, the selected fonts don't appear. (Site displays browser default fonts.)
  6. But, if I manually copy over the fontyourface/ directory from sites/default/files to the private path, the fonts are fine.

Proposed resolution

  1. Fontyourface selects site fonts that all users should be able to see. So css files for it should be in the public file path. I didn't set it specifically to use the private files path but it does anyway.
  2. Also a problem because if you change from public to private, the fontyourface css files dir stays in the public path.
  3. If not, then there should be a place for users to select to use the public path even if the site has a private files default set up.
  4. I read the documentation I could find, and the config on the UI but didn't see a place to do this.

User interface changes

Add a selector in the config to use public file path.
Or default to public and have selector to use private. This fixes the problem with the selected fonts css files not being copied to the private files dir.

πŸ› Bug report
Status

Active

Version

4.0

Component

Code (general)

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024