-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Static font name for loading fonts #29210
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
Static font name for loading fonts #29210
Conversation
…changing the variable's value (e.g. in a child theme) can result in loading open sans under a wrong name
Hi @woutk88. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run Functional Tests CE |
this is not actually a bug in my opinion as frontender In css/source/_variables.less change font here is correct but not enough In css/source/_typography.less Example in typography @font-path: '@{baseDir}fonts/trenda/Trenda-Regular', |
Ok, sure it makes sense to override And what if you want to switch to a web safe font, which doesn't require any loading of fonts with Or, if you change the base font but still want to use Open Sans for headings? You should be able to do this by only setting Therefore I think, regardless of the way or the place you load and set/change your fonts, |
Hi @ihor-sviziev, thank you for the review. |
@mrtuvn I think it's an issue, as the font path is already defined as open sans, and not getting from some variable |
@magento run all tests |
We found some time ago following code in styles-m.css file on the frontend: 🤯 @font-face {
font-family: 'MyCustomFont';
src: url('../fonts/opensans/light/opensans-300.woff2') format('woff2'), url('../fonts/opensans/light/opensans-300.woff') format('woff');
font-weight: 300;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'MyCustomFont';
src: url('../fonts/opensans/regular/opensans-400.woff2') format('woff2'), url('../fonts/opensans/regular/opensans-400.woff') format('woff');
font-weight: 400;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'MyCustomFont';
src: url('../fonts/opensans/semibold/opensans-600.woff2') format('woff2'), url('../fonts/opensans/semibold/opensans-600.woff') format('woff');
font-weight: 600;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'MyCustomFont';
src: url('../fonts/opensans/bold/opensans-700.woff2') format('woff2'), url('../fonts/opensans/bold/opensans-700.woff') format('woff');
font-weight: 700;
font-style: normal;
font-display: swap
} As result when you're trying to use some custom font by changing variable I thing we need to change severity to S2 |
@magento create issue |
✔️ QA Passed Precondition: A custom theme that extends from Blank Manual testing scenario:
Before: ✖️ The text is shown in compiled CSS. ✖️ Name changed to After: ✔️ The text is shown in compiled CSS. ✔️ Name and src of the @ font-face block remain Open Sans |
@magento run all tests |
@woutk88 |
…ic-font-name-for-loading-fonts
@magento run all tests |
Hi @woutk88, thank you for your contribution! |
Description (*)
The variable
@font-family-name__base
shouldn't be used when loading the Open Sans font because it's not really something that should change, since the source will still point to the Open Sans font. Using the variable here (can) cause issues when you change the base font (e.g. in a child theme).Example 1:
If your custom theme extends from the Blank Theme and you change the base font with:
This will be the compiled CSS:
Which is already wrong, but doesn't directly lead to problems since 'Trenda' is a custom font and you'll probably do something like this in your theme:
In which case this @font-face block will be included in the compiled CSS later, and your browser will only 'use' this one. However, if you only load the font in regular font-weight here, and you want to show text in bold, the browser will show that text in Open Sans (bold).
Example 2:
If your custom theme extends from the Blank Theme and you want to switch to a 'websafe' font, for example Times New Roman:
Text won't be displayed in the real Times New Roman but in Open Sans because that is loaded under the name 'Times New Roman'.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
@font-family-name__base
to'Times New Roman'
(either temporary in Blank Theme or in a theme that extends from Blank)Questions or comments
Contribution checklist (*)
Resolved issues: