I
I
ingenerdsm2016-12-16 23:58:42
css
ingenerdsm, 2016-12-16 23:58:42

How to correctly connect googlefont to the site?

Hello, I am connecting the Lobster font to the site, which is available through googlefonts. I only need Cyrillic characters, but it is not possible to configure (uncheck) the Latin option. You can connect the font using the following method:

<style>
@import url('https://fonts.googleapis.com/css?family=Lobster&subset=cyrillic');
</style>

If you follow the link, you will be presented with a css file in which the fonts are connected:
/* cyrillic */
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  src: local('Lobster'), local('Lobster-Regular'), url(http://fonts.gstatic.com/s/lobster/v18/c28rH3kclCLEuIsGhOg7evY6323mHUZFJMgTvxaG2iE.woff2) format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* vietnamese */
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  src: local('Lobster'), local('Lobster-Regular'), url(http://fonts.gstatic.com/s/lobster/v18/RdfS2KomDWXvet4_dZQehvY6323mHUZFJMgTvxaG2iE.woff2) format('woff2');
  unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  src: local('Lobster'), local('Lobster-Regular'), url(http://fonts.gstatic.com/s/lobster/v18/9NqNYV_LP7zlAF8jHr7f1vY6323mHUZFJMgTvxaG2iE.woff2) format('woff2');
  unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  src: local('Lobster'), local('Lobster-Regular'), url(http://fonts.gstatic.com/s/lobster/v18/cycBf3mfbGkh66G5NhszPQ.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}

Maybe it's better then to connect via @font-face?
/* cyrillic */
@font-face {
  font-family: 'Lobster';
  font-style: normal;
  font-weight: 400;
  src: local('Lobster'), local('Lobster-Regular'), url(http://fonts.gstatic.com/s/lobster/v18/c28rH3kclCLEuIsGhOg7evY6323mHUZFJMgTvxaG2iE.woff2) format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sergey, 2016-12-17
@zorro76

<link href="https://fonts.googleapis.com/css?family=Lobster&amp;subset=cyrillic" rel="stylesheet">
font-family: 'Lobster', cursive;

and don't fool your head

D
dom1n1k, 2016-12-17
@dom1n1k

The fact that GF gave a css file with a bunch of languages, including Vietnamese, is normal.
The fact is that modern browsers can determine which characters from which Unicode ranges are actually in the document. And depending on this, load or not load the desired file. Therefore, manually specifying the language for them has lost its meaning. The browser just needs to give links to all available language versions, and he will figure out what to download and what not.
And GF, in turn, determines which browser the client has and gives him the version of css that is most suitable. If you go from the old browser - there will no longer be "extra", there will be only what is indicated by the link.
At one time, this feature killed me for several hours of debugging:
Why can the ruble sign not work in iOS?
This was the moment when Chrome already supported auto-selection of subsets, but Safari did not yet. Accordingly, my error appeared only on Safari and therefore seemed like a glitch.
In short, everything is fine, leave GF alone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question