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

Error: Multiple @font-face with the same font-family/font-style/font-weight #77

Closed
s0kil opened this issue Jan 28, 2020 · 9 comments
Closed

Comments

@s0kil
Copy link

s0kil commented Jan 28, 2020

Latest update triggers an error never seen before:

Error: Multiple @font-face with the same font-family/font-style/font-weight (maybe with different unicode-range?) is not supported yet: cera_pro_black/normal/normal
    at subsetFonts (/home/sokil/Desktop/Projects/European-Market-Web-App/node_modules/.pnpm/registry.npmjs.org/subfont/4.1.2/node_modules/subfont/lib/subsetFonts.js:685:19)
    at async subfont (/home/sokil/Desktop/Projects/European-Market-Web-App/node_modules/.pnpm/registry.npmjs.org/subfont/4.1.2/node_modules/subfont/lib/subfont.js:148:24)

This was not an issue before.

@papandreou
Copy link
Collaborator

Hmm, can you share the full set of @font-face declarations that your web site has?

@s0kil
Copy link
Author

s0kil commented Jan 28, 2020

Just one

  @font-face {
    font-family: "cera_pro_black";
    src: url("/fonts/cerapro-black-webfont.woff2") format("woff2"),
      url("/fonts/cerapro-black-webfont.woff") format("woff");
    font-weight: normal;
    font-style: normal;
  }

@s0kil
Copy link
Author

s0kil commented Jan 28, 2020

Also, probably unrelated, two Google Fonts

    <link
      href="https://fonts.googleapis.com/css?family=Lato|Merriweather&display=swap"
      crossorigin="anonymous"
      rel="stylesheet"
    />

@papandreou
Copy link
Collaborator

I tried putting that into a simple webpage, but I can't seem to reproduce it, except if I duplicate the @font-face declaration for cera_pro_black 🤷‍♂️

Which command line switches are you using? Are you running subfont on multiple pages?

Could I get you to try to make a small test case that reproduces it? You're also welcome to send me a copy of European-Market-Web-App, then I can try to narrow it down.

@s0kil
Copy link
Author

s0kil commented Jan 28, 2020

I'm using Sapper + Svelte, and it exports the page into a static site.
The cera_pro_black font face is used in the navigation which is generated for every page, but it is not defined twice on each individual page.

@papandreou
Copy link
Collaborator

Thanks! I tried building your project and ran subfont on __sapper__/export/index.html, and that reproduced the error. Then I started trimming down the document, and it still happens with just:

<link href=client/main.4118517638.css rel=stylesheet>
<link href=client/client.f63cc1a2.css rel=stylesheet>

But it makes sense, because main.4118517638.css contains:

@font-face {
  font-family: "cera_pro_black";
  src: url("/fonts/cerapro-black-webfont.woff2") format("woff2"),
    url("/fonts/cerapro-black-webfont.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

... and client.f63cc1a2.css contains:

@font-face {
  font-family: "cera_pro_black";
  src: url("/fonts/cerapro-black-webfont.woff2") format("woff2"),
    url("/fonts/cerapro-black-webfont.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

So it seems to be more of a known limitation than a bug that it happens.

Could you find a way to avoid having two @font-face declarations that declare the same font?

We should probably also make subfont more resilient so it just patches all the @font-faces in this case. It's safe in this case, but in general it would require us to verify that the url sets are the same. As the error message hints at, handling different unicode-ranges in seemingly duplicate blocks would require extra care.

@s0kil
Copy link
Author

s0kil commented Jan 30, 2020

@papandreou I think this is a problem with Sapper:
The files client/main.hash.css and client/client.hash.css are the same, I'm not sure why this happens.

The main.hash.css is for styles that apply to every page and the index.hash.css file is for index route.

@s0kil
Copy link
Author

s0kil commented Jan 30, 2020

I have created an issue for this behavior.
sveltejs/sapper#1076

@s0kil s0kil closed this as completed Jan 31, 2020
@s0kil
Copy link
Author

s0kil commented Feb 27, 2020

This issue has been fixed in Sapper 0.27.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants