Home > Back-end >  How to add font family using .ttf file
How to add font family using .ttf file

Time:12-25

I am a website editor and I know some HTMLs, I also know how to change to fonts using .css, but some fonts are not supported so I downloaded a ttf file (a font file) but I do not know how to use it and how to connect it to css/html

CodePudding user response:

Try

@font-face {
    font-family: "font_name";
    src: url("file_name.ttf") format("truetype");
}

CodePudding user response:

Here (but better is using woff2 font)

@font-face { 
   font-family: "your_font";
   font-style: normal;
   src: local("your_font"), /* full name */
        local("your_font"), /* postscript */
        url("./fonts/your_font.ttf") format("truetype"), /* your ttf font here */
        url("./fonts/your_font.woff2") format("woff2"); /* better than ttf */
}

body {
   font-family: your_font;
  • Related