Open jlarmstrongiv opened 6 months ago
Would be ok to treat as an "array" of import instead of a single string for me.
Even if it's not a common case there's no need to keep current behavior.
We could add an extra flag to mj-font to force importing the font too but I don't think this is the right approach
On Wed, Apr 3, 2024 at 7:14 PM John L. Armstrong IV < @.***> wrote:
Describe the bug mj-font is a smart component. Perhaps too smart in some cases.
I am using fontsource to host fonts on my local website. Here is an example package:
- variable @.***/open-sans
- static @.***/open-sans
Fontsource packages for all fonts on Google Fonts, plus others fonts. They are popular for self-hosting fonts.
However, the problem with fontsource, typefaces, and other npm packages that allow local installation is that they bundle their CSS files by weight, italics, etc. without having an all or complete file for all font weights, italics, etc. So, to render noto sans with italics, you need two stylesheets:
import @./noto-sans/wght-italic.css'; import @./noto-sans';
This conflicts with mj-font, which seems to expect the name attribute to be unique. If two mj-font tags have the same name, then only the last stylesheet is emitted. Plus, if a suffix is added to the name attribute to make it unique, that font tag output will be omitted because it must be used somewhere in the email as a fontFamily attribute.
To Reproduce Steps to reproduce the behavior: See https://mjml.io/try-it-live/xuL4GmhZOp Code sample
MJML
Hello World Compiled HTML output
<!doctype html>
<style @. url(https://fonts.googleapis.com/css?family=Nunito);<style @. only screen and (min-width:480px) { .mj-column-per-100 { width:100% !important; max-width: 100%; } }
Hello WorldExpected behavior Defining mj-font with two stylesheets for the same font family name should emit two stylesheet references
MJML environment (please complete the following information):
- OS: All
- MJML Version: 4.15.3
- MJML tool used: Try it live, mjml-react
Email sending environment(for rendering issues):
- N/A
Affected email clients (for rendering issues):
- Email Client: any that support fonts
- OS: All
- Browser: All
— Reply to this email directly, view it on GitHub https://github.com/mjmlio/mjml/issues/2849, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAELHTNHPSGPXYKQHZBOWZ3Y3Q2HNAVCNFSM6AAAAABFVXK3RSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDGNBXGM4TMNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Describe the bug
mj-font
is a smart component. Perhaps too smart in some cases.I am using fontsource to host fonts on my local website. Here is an example package:
Fontsource packages for all fonts on Google Fonts, plus others fonts. They are popular for self-hosting fonts.
However, the problem with fontsource, typefaces, and other npm packages that allow local installation is that they bundle their CSS files by weight, italics, etc. without having an
all
orcomplete
file for all font weights, italics, etc. So, to render noto sans with italics, you need two stylesheets:This conflicts with
mj-font
, which seems to expect thename
attribute to be unique. If twomj-font
tags have the same name, then only the last stylesheet is emitted. Plus, if a suffix is added to the name attribute to make it unique, that font tag output will be omitted because it must be used somewhere in the email as afontFamily
attribute.To Reproduce Steps to reproduce the behavior: See https://mjml.io/try-it-live/xuL4GmhZOp
Code sample
MJML ```htmlExpected behavior Defining
mj-font
with two stylesheets for the same font family name should emit two stylesheet referencesMJML environment (please complete the following information):
Email sending environment(for rendering issues):
Affected email clients (for rendering issues):