question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't load multiple fonts from google font API

See original GitHub issue
.loadFonts() when (@importGoogleFonts) {
  @import url('@{googleProtocol}fonts.googleapis.com/css?family=@{googleFontRequest}');
}
@googleFontName    : @fontName;
@importGoogleFonts : true;
@googleFontSizes   : '400,700,400italic,700italic';
@googleSubset      : 'latin';

@googleProtocol    : 'https://';
@googleFontRequest : '@{googleFontName}:@{googleFontSizes}&subset=@{googleSubset}';

If I set @fontName to multiple values, or use different fonts for @pageFont and @headerFont, the @googleFontRequest will not work.

I have checked the Google font API, a working request URL may be like this: font-1:@{googleFontSizes}|font-2:@{googleFontSizes}|font-3:@{googleFontSizes}&subset=@{googleSubset}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
eveevanscommented, Jun 7, 2017

I did it directly changing the@googleFontRequest:

@headerFont        : 'Pragati Narrow', sans-serif;
@pageFont          : 'Poppins', sans-serif;
@importGoogleFonts : true;
@googleProtocol    : 'https://';
@googleFontRequest : 'Poppins:400,500|Pragati+Narrow:400,700';

That will generate the exact line for include fonts: @import url('https://fonts.googleapis.com/css?family=Poppins:400,500|Pragati+Narrow:400,700');

1reaction
awgvcommented, Feb 16, 2017

Hi @tarvos21, I’m not familiar with Google Fonts, as I tend to self-host the fonts, but have you tried changing @googleFontRequest to make it look like the suggested Google Font API request?

.loadFonts() when (@importGoogleFonts) {
  @import url('@{googleProtocol}fonts.googleapis.com/css?family=@{googleFontRequestLato}|@{googleFontRequestAnotherFont}');
}

@latoFontName: 'Lato';
@latoFontSizes: '400,700,400italic,700italic';
@latoSubset: 'latin';
@googleFontRequestLato: '@{latoFontName}:@{latoFontSizes}&subset=@{latoSubset}';

@anotherFontName: 'Another Font';
@anotherFontSizes: '400,700,400italic,700italic';
@anotherFontSubset: 'latin';
@googleFontRequestAnotherFont: '@{anotherFontName}:@{anotherFontSizes}&subset=@{anotherFontSubset}';
Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading multiple Google Fonts in 1 request violates HTML ...
Of course I can separate two fonts in two requests as follow, but the load time will be doubled. <link rel="stylesheet" type="text/css" href ......
Read more >
How to Load Multiple Google Fonts in One URL Request
Loading google font is easy. If we visit Google Font page, for example Open Sans Font. we can see the instruction to add...
Read more >
Troubleshooting | Google Fonts
By default the NoScript plugin disables @font-face rules. Solution. Open the NoScript Options, go to the Embeddings tab and uncheck: Forbid @font-face. Web ......
Read more >
Loading variable fonts on the web – Fonts Knowledge
Loading variable fonts from a font delivery service ... Google Fonts because, at the time of writing, Adobe Fonts doesn't serve variable fonts...
Read more >
A Guide to Google Font API
Tip: Using too many fonts in one request may slow down page response times. So load only the fonts you need. Be conservative:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found