-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong local font file being referenced by @font-face generated from theme.json #42190
Comments
The use of |
Nice to know these details @aristath. I personally don't get why the error occurred with my client since she was downloading the font file from Google Fonts itself... But I also agree that it is a nice thing to have by default. Would just be good to have a filter or something like that to either remove it or change the name passed to the |
See also in the tt2 forum: A workaround in the child themes theme.json or in the additional CSS cannot be a permanent solution. |
@aristath I'm not sure if the actual point has been made clear enough here as there are two different topics being discussed here. Actually I think you guys were talking past each other. The initial comment refers to the following bug: So because WordPress passes only the font family name ( I had the same problem with "Source Sans Pro". However, because it's a logical error I am sure that the problem occurs with all font families that have different files for weight and style (so very most fonts). This means that most fonts have big problems when the font is installed on user's system. Even if the files installed are exactly the same as the ones the site supplies. Therefore, in my opinion, the label "[Feature] Webfonts" does not fit here, as there is definitely a bug. |
Chiming in to second what @eHtmlu said – this bug is caused by Wordpress outputting only the family name, not the full name of the font face. This would match the way it's phrased over at MDN (emphasis mine):
In my case, |
As for solving it, it seems like we would need to know either the Full name or the PostScript name of the font face. I would imagine there are a couple of options:
Just looking at a couple of fonts on my machine, I would not expect a very high hit rate for options 1 & 2. Still, if it's meant as a zero-config best guess, maybe that's acceptable? Option 1 has the benefit of giving some control back to the user, as they can choose to tweak the filenames of self-hosted font files. Option 3 would be the most correct, but is probably not desirable due to the added complexity, unless we already read the font files for some other reason. Option 4 would probably be my preference, even if we use one of the other options by default. Maybe we could allow |
@carolinan Please consider classifying this issue as a bug rather than a feature, because WordPress uses |
I strongly support dropping the default addition of local() to the webfonts stylesheet. Not only is the usage from WordPress questionable, most big vendors have dropped the usage of local as well, due to the plethora of potential issues due to version mismatch and such. I've prepared a core ticket and patch to drop local from the stylesheet. |
I fail to see the reasoning behind the accessibility issues. The reporting user mentions performance as an issue, but that seems to be in the same lane as using images and other static assets. To be fair, in terms of accessibility, I believe the contrary to be the case: Using local and possibly creating a version mismatch between a locally installed version and the intended version can lead to legibility issues, which can become an accessibility issue.
The fact that Google dropped the use of local worldwide over 2 years ago and that there is no resistance or outcry leads me to believe that this issue is not as ambiguous as it may seem. |
I can confirm that See: |
Description
When using the
settings.typography.fontFamilies[].fontFace
setting intheme.json
, we have a nice way to let Gutenberg create@font-face
css for ourselves.Sadly, that feature is causing a bug by generating a
src
list prepended by `local('Name of the font'). The internals are done here:gutenberg/lib/experimental/class-wp-webfonts-provider-local.php
Line 231 in 6cdd6ae
This seems nice, as it automatically handles the possibility of having local fonts installed on the user system. The problem is that by taking the
$font_familiy
name here, we don't consider that the user may have installed the font from separate files to bold, medium, light, etc. And those files should be listed as differentlocal
files.I am not 100% sure that this is the cause of the bug that I will describe here, but I do feel we should have some option to disable or at least configure this prepending.
Step-by-step reproduction instructions
assets/fonts/static/
;theme.json
file with the following settings configuration:@font-face
will be something like this:The font will appear bold in computers where the local font is not installed, but regular where it is. (attachments bellow). In other words, is like if the font-face gives up loading the bold font once it finds the regular one.
I know it sounds weird, but I am bringing this here as the issue is completely solved if we remove the
local('El Messiri')
from the font-face css.Screenshots, screen recording, code snippet
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: