Skip to content
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

@font-face: Same name with different styles #270

Open
femesq opened this issue Aug 27, 2018 · 2 comments
Open

@font-face: Same name with different styles #270

femesq opened this issue Aug 27, 2018 · 2 comments

Comments

@femesq
Copy link

femesq commented Aug 27, 2018

Looking at the sources and the docs, I couldn't be sure if using @font-face with different files for each font-style's on the same font-family would work:

@font-face {
  font-family: 'Montserrat';
  src: url('#{$media-path-fonts}/Montserrat-Bold.eot');
  src: url('#{$media-path-fonts}/Montserrat-Bold.woff2') format('woff2'),
  url('#{$media-path-fonts}/Montserrat-Bold.woff') format('woff'),
  url('#{$media-path-fonts}/Montserrat-Bold.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
}

@font-face {
  font-family: 'Montserrat';
  src: url('#{$media-path-fonts}/Montserrat-BoldItalic.eot');
  src: url('#{$media-path-fonts}/Montserrat-BoldItalic.woff2') format('woff2'),
  url('#{$media-path-fonts}/Montserrat-BoldItalic.woff') format('woff'),
  url('#{$media-path-fonts}/Montserrat-BoldItalic.ttf') format('truetype');
  font-weight: 900;
  font-style: italic;
}

... Neither if it would support deep Browser support which needs two src keys.

Anyone tried this?

Somewhat related: #236

@rtsao
Copy link
Member

rtsao commented Aug 30, 2018

I think a comma separated string for the src style object property should suffice. This mirrors how this works in CSS: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face

@femesq
Copy link
Author

femesq commented Aug 30, 2018

Yes, the two src keys aims to support IE6-8 (which actually may not make sense for React, that support IE9+...).

My question in regard of font-face's and both its font-style and font-weight was in regard of how this is cached internally.
I mean: if it is cached based on font-family name only, using the same name for multiple styles and weights wouldn't work.

Looking in the code, I found this which appears that all the block is used to create the rule, but as I'm new to the project, I'm not sure about it..
If its the case, then we are fine...

@tajo tajo closed this as completed Mar 20, 2019
@tajo tajo reopened this Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants