javascript - Cómo cambiar la fuente font-family de bootstrap.css en HTML a mi propia fuente descargada
He intentado encontrar cómo hacer eso, al menos este enlace casi me lo consigue. pero ella/él está usando un enlace para cambiar la fuente.
pero tengo mi propia fuente descargada usando un convertidor de fuentes (.eot .otf .svg .ttf .woff .woff2)
y tengo style.css como sigue:
/* font converted using font-converter.net. thank you! */
@font-face {
font-family: "CataneoBT-Regular";
src: url("./fonts/07323Cataneo.svg") format("svg"), /* Legacy iOS */
url("./fonts/07323Cataneo.ttf") format("truetype"), /* Safari, Android, iOS */
url("./fonts/07323Cataneo.woff") format("woff"), /* Modern Browsers */
url("./fonts/07323Cataneo.woff2") format("woff2"); /* Modern Browsers */
font-weight: normal;
font-style: normal;
}
Este es un fragmento de código de mi bootstrap.css html:
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
El código más similar de mi bootstrap es:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix')
format('embedded-opentype'),
url('../fonts/glyphicons-halflings-regular.woff2')
format('woff2'),
url('../fonts/glyphicons-halflings-regular.woff')
format('woff'),
url('../fonts/glyphicons-halflings-regular.ttf')
format('truetype'),
url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular')
format('svg');
}
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
pero hasta donde sé, este código es solo para mostrar algún ícono
No sé cómo cambiar ese código para mostrar mi propia fuente
Respuesta #1
Simplemente use el siguiente CSS en su archivo CSS, que debe incluirse después de bootstrap..
@font-face {
font-family: <Your-font>;
src: url(<your-font-path>);
}
html, body {
font-family: <Your-font>, sans-serif; /*Specify your font name here*/
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
Respuesta #2
En el archivo style.css necesitas enlazar la familia de fuentes, proporciona la ruta de tu fuente en src
@font-face {
font-family: 'sans-serif';
font-weight: normal;
font-style: normal;
src: url('../fonts/sans-serif.eot') format('embedded-opentype'), url('../fonts/sans-serif.woff') format('woff'), url('../fonts/sans-serif.ttf') format('truetype'), url('../fonts/sans-serif.otf') format('opentype'), url('../fonts/sans-serif.svg#sans-serif') format('svg');
}
