फ़ॉन्ट-फेस कमांड

@font-face कमांड एक कस्टम फ़ॉन्ट को परिभाषित करने की अनुमति देती है, जिसका स्रोत एक फ़ाइल में संग्रहीत होता है। इस फ़ॉन्ट को बाद में font-family गुण का उपयोग करके जोड़ा जा सकता है।

सिंटैक्स

css@font-face {
  फ़ॉन्ट का नाम;
  फ़ॉन्ट स्रोत;
}

उदाहरण

आइए हम अपने लोकल कंप्यूटर पर एक फ़ॉन्ट ढूंढते हैं:

html<body>
  This is Montserrat SemiBold.
</body>
css@font-face {
  font-family: "Montserrat SemiBold";
  src: local("Montserrat SemiBold");
}
  
body {
  font-family: "Montserrat SemiBold";
}

#elem {
  animation: anim 3s infinite;
  border: 1px solid black;
  width: 50px;
  height: 50px;
}

Результат:

उदाहरण

और अब फ़ॉन्ट को खोजने के लिए एक रिमोट सर्वर का पता निर्दिष्ट करते हैं:

html<body>
  This is Bitstream Vera Serif Bold.
</body>
css@font-face {
  font-family: "Bitstream Vera Serif Bold";
  src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf");
}
  
body {
  font-family: "Bitstream Vera Serif Bold", serif;
}

#elem {
  animation: anim 3s infinite;
  border: 1px solid black;
  width: 50px;
  height: 50px;
}

Результат: