Problem/Motivation

If you have multiple fonts in your theme (i.e.) and organise them in subdirectories, the current implementation of the font discovery is not able to detect these fonts.

Example:

/fonts
  /museoslab
    - museoslab-300-webfont.ttf
    - museoslab-700-webfont.ttf
  /ubuntu
    - ubuntu-300.ttf
    - ubuntu-300italic.ttf
    - ubuntu-700.ttf
    - ubuntu-700italic.ttf

Proposed resolution

Scan the configured font directory and its subdirectories for fonts.

Remaining tasks

Create patch.

Comments

stBorchert created an issue. See original summary.

stborchert’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.4 KB

Instead of using <?php opendir(); ?> and <?php readdir(); ?> I simply used <?php file_scan_directory(); ?> to get all fonts from the given directory and its subdirectories.

mondrake’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thank you!

Looks nice, it would help to adjust Drupal\Tests\image_effects\Functional\SelectorPluginTest::testFontSelector to cover the change.

Also, to be nitpicky the UI text will be a bit off after the change, i.e.

* help = @Translation("Access a list of fonts stored in the directory specified in configuration.")

and

'#description' => $this->t('Location of the directory where the fonts are stored.')

and others should be rephrased to cater for the fact that subdirectories will be scanned too. But that'd be a string change and we're stable now, so I'd rather have a follow-up for a future new branch.

mondrake’s picture

Status: Needs work » Closed (outdated)

Closing any stale issue with latest comment over 5 years old.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.