tomusborne / generatepress

450 stars 89 forks source link

Font Subset Selection Issue in new Font Manager #638

Open FunkyCss opened 2 months ago

FunkyCss commented 2 months ago

Issue Description: When I select a specific subset, such as "Greek," the font works correctly for Greek characters but does not display English (Latin) characters as expected. It seems that when a non-Latin subset is selected, the corresponding Latin characters are not loaded, which leads to fallback fonts being used for English text.

Expected Behavior: Ideally, when selecting a subset like "Greek," the system should still load the necessary Latin characters unless explicitly excluded. This would ensure that the font displays correctly for both Greek and English text, without requiring manual intervention or additional font loading.

Steps to Reproduce:

  1. Go to the GeneratePress font settings.
  2. Select a Google Font and choose the "Greek" subset.
  3. Apply the changes and observe the text rendering on the site.
  4. English text does not render using the selected font, and instead, a fallback font is used.

Suggested Solution: When a user selects a subset, the system should either:

This change would improve the user experience and ensure that fonts are rendered correctly across different languages on the site.

Please let me know if you need any further details to investigate this issue.

iansvo commented 2 months ago

@FunkyCss Thanks for the report. I think there's definitely a way we can tighten this up and I'm sorry for the inconvenience there.

That said, I'm pleased to report that you have 2 immediate options to get around this problem:

  1. You can use a filter to specify the subsets we use. The settings UI only supports choosing one, but we planned to originally include the ability to choose more than one, which you can still do using a PHP filter:
    <?php
    apply_filters( 'generatepress_google_font_subsets', function () {
        return array( 'latin', 'greek' ); // Customize this to whatever subsets you want
    }, 15 );

The setting is currently set as an array so it shouldn't necessarily break anything or the UI, but let me know if you have any issues going that direction.

  1. Otherwise, if you upload a font file from your computer (instead of using the Google Fonts tab) it will not change the subset in the font and will use whatever is included with it.

I hope this helps, let me know if you have any questions while we work on updating that control to allow choosing multiple subsets.

FunkyCss commented 2 months ago

@iansvo Hallo, and thanks for checking this issue.

The filter that you shared is working for now and I have done a couple of test and no issues there.

Glad to report this, keep rocking!