Comando font-face

El comando @font-face permite definir una fuente personalizada, cuyo archivo fuente se almacena en un archivo. Esta fuente luego se puede conectar usando la propiedad font-family.

Sintaxis

css@font-face {
  nombre de la fuente;
  fuente de búsqueda de la fuente;
}

Ejemplo

Busquemos una fuente en nuestro ordenador local:

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;
}

Результат:

Ejemplo

Y ahora especifiquemos una dirección de servidor remoto para buscar la fuente:

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;
}

Результат: