W
W
weranda2020-10-20 08:58:37
css
weranda, 2020-10-20 08:58:37

How to set up inheritance fonts when using font-display: swap?

Greetings.
The styles are written like this:

body{
    font-family: 'ubuntu400',Arial,sans-serif;
    ...
}

@font-face {
    font-family: "ubuntu400";
    src: url("font/ubuntu400.eot");
    src: url("font/ubuntu400.eot?#iefix") format("embedded-opentype"),
        url("font/ubuntu400.woff2") format("woff2"),
        url("font/ubuntu400.woff") format("woff"),
        url("font/ubuntu400.ttf") format("truetype");
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "ubuntu500";
    src: url("font/ubuntu500.eot");
    src: url("font/ubuntu500.eot?#iefix") format("embedded-opentype"),
        url("font/ubuntu500.woff2") format("woff2"),
        url("font/ubuntu500.woff") format("woff"),
        url("font/ubuntu500.ttf") format("truetype");
    font-display: swap;
}


If I add a page title , then when the page is loaded, the title will not be displayed / replaced by an additional system font until the font is loaded and will be displayed with the style built into the browser like this: And logically it should be displayed in Arial font, like this : how it loads): I suspect that this is due to the fact that I did not specify an additional font for the title. Is it true? Tell me. Shouldn't the font be selected from the selectorfont-family: ubuntu500
5f8e7a0381e35222632297.png
5f8e7a3038886551670162.png
5f8e7c5d29c62821112682.png

bodyautomatically? Do any elements for which I prescribe a specific font (ubuntu500) must also prescribe fallback fonts? If so, then there are about 40 places in my file where a specific font is specified for specific elements, and adding a set of fallback fonts to each entry is bloating the file from scratch. What are the options for this case:
  1. In any case, specify fallback fonts for each element where a specific font is specified.
  2. Something other.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Тимур Худиев, 2020-10-20
@weranda

Везде, где указываете название шрифта, который будет применен, нужно прописывать запасной

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question