Skip to content

Local fonts doesn't loading #57

@Gr1mmz

Description

@Gr1mmz

I'm going onto your guide for local fonts but I can't see my font on dev and prod UI.

Fonts are copying by config:

new CopyWebpackPlugin({
      patterns: [
        // `shared/img` to `dist/static/img`
        {
          from: `${defines.src}/shared/img`,
          to: `${defines.dist}/${defines.static}/img`
        },

        // others:
        // `shared/fonts` to `dist/static/fonts`
        {
          from: `${defines.src}/shared/fonts`,
          to: `${defines.dist}/${defines.static}/fonts`
        },
      ]
    }),

I've copied fonts into src/shared/fonts/ and added file src/app/styles/fonts.scss:

@font-face {
  font-family: "PTRootUI";
  font-style: normal;
  font-weight: 500;
  font-stretch: 100%;
  font-display: swap;
  src: url("/static/fonts/PTRootUIMedium.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "PTRootUI";
  font-style: normal;
  font-weight: 700;
  font-stretch: 100%;
  font-display: swap;
  src: url("/static/fonts/PTRootUIBold.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

And finally I've added it in globals.scss just like in your guide:

font-family: "PTRootUI", sans-serif !important;

On web page devtools I see the name of font "PTRootUI", but it's not my font, it's just a system sans-serif font. What am I doing wrong?

All another stuff working great (styles, images, include import images in scss files etc.). Fonts are copying into build (dist folder) but I can not see it on page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions