Using a different font with twitter bootstrap - css

I want to use a different font for my website, which is not a regular webfont. I have created EOT files already. Now how can I integrate those fonts with twitter bootstrap ? Can anyone help ?
Thanks

The easiest way I've seen is to use Google Fonts.
Go to Google Fonts and choose a font, then Google will give you a link to put in your HTML.
Then add this to your custom.css:
h1, h2, h3, h4, h5, h6 {
font-family: 'Your Font' !important;
}
p, div {
font-family: 'Your Font' !important;
}
or
body {
font-family: 'Your Font' !important;
}

You can find a customizer on the official website, which allows you to set some LESS variables, as #font-family-base. Link your custom fonts in your layout, and use your custom generated bootstrap style.
Link here
For an example with the #font-face rule, using WOFF format (which is pretty good for browser compatibility), add this CSS in your app.css file and include your custom boostrap.css file.
#font-face {
font-family: 'Proxima Nova';
font-style: normal;
font-weight: 400;
src: url(link-to-proxima-nova-font.woff) format('woff');
}
Please note Proxima Nova is under a license.

Hi you can create a customized build on bootstrap, just change the font name in the following pages
Bootstrap 2.3.2
http://getbootstrap.com/2.3.2/customize.html#variables
Bootstrap 3
http://getbootstrap.com/customize/#less-variables
After that, make sure to use proper #font-face in a css file and link that to your page. Or you could use font kit generators.

you can customize twitter bootstrap css file, open the bootstrap.css file on a text editor, and change the font-family with your font name and SAVE it.
OR got to http://getbootstrap.com/customize/ and make a customized twitter bootstrap

First of all you have to include your font in your website (or your CSS, to be more specific) using an appropriate #font-face rule.
From here on there are multiple ways to proceed. One thing I would not do is to edit the bootstrap.css directly - since once you get a newer version your changes will be lost. You do however have the possibility to customize your bootstrap files (there's a customize page on their website). Just enter the name of your font with all the fallback names into the corresponding typography textbox. Of course you will have to do this whenever you get a new or updated version of your bootstrap files.
Another chance you have is to overwrite the bootstrap rules within a different stylesheet. If you do this you just have to use selectors that are as specific as (or more specific than) the bootstrap selectors.
Side note: If you care about browser support a single EOT version of your font might not be sufficient. See http://caniuse.com/eot for a support table.

Related

Tailwind/CSS using custom fonts

I have a project where I need to use custom fonts. But I have no idea how to use this in my HTML. I have searched online how to do this, but all examples use a font that is contained in one file. My font is contained in multiple files.
How do I specify which specific font of the CircularStd I want to use on each element?
This is a screenshot of my index.scss file which contains the tailwind imports and the definition of my font:
An approach to this would be creating a custom font class in your tailwindconfig.js and extending it to your default tailwind theme. For example, if you're using Google Fonts and you want to use the font Manrope for a specific header, you can extend the fontFamily variant like so:
module.exports = {
theme: {
extend: {
fontFamily: {
'manrope': 'Manrope',
}
}
}
}
Now, to use this custom class declare it in your html by following the syntax font-{fontFamily}. So in this case, we're going to use font-manrope.
<h4 class="font-manrope">I'm a header using the font Manrope</h4>
If you think that your font has many files and you need them all then why not create a #fontface for each one although this is not the best practice, you are supposed to for example to choose the file with the light and standard font and you create the #fontface based on it and include it's file the others like the bold and italics can eventually be done using CSS but the most important thing is that you have your font implemented.
so for example you will add your font:
#font-face {
font-family: myFirstFont;
src: url(sansation_light.woff);
}
and if you want it to be bold and italic use
p{
font-weight:600;
font-style: italic;
}
I hope that would help!

unable to load #font_face in my wamp localhost?

I am trying to add some custom font in my site but unable to do. I am not sure if I am using a right or wrong path. Kindly help.
#font-face {
font-family: XfinityStandard
src: url('landingpage/fonts/XfinityStandard-Light.woff2') format("woff2");
where landingpage is folder name.
There are two main ways to check:
Is the font actually working (i.e. can you see it rendering properly), and
Inspect your page (e.g. in Chrome, right-click the text you expect the font to render on, and select Inspect from the drop-down menu. In your Styles tab, at the right-hand bottom of the page, there should be a section called Rendered Fonts. If you have implemented your font correctly, it should show here (in addition to the css hierarchy applied, where your font should be listed).
If your font is not showing here, make sure you follow the following:
The #font-face rule should be added to your css before any styles
Use your rule in your css by specifying the font as XfinityStandard and provide a fall-back like sans-serif, e.g. body { font-family: 'XfinityStandard', sans-serif; }
Make sure you have wide support, so when you specify your font, add an additional source for format('woff')
As Devansh J mentioned, make sure your font is relative to the css file
If you are still having issues, maybe consider a hosted font like Google Fonts, as follows: #import url(///fonts.googleapis.com/css?family=Montserrat which you can use as body { font-family: 'Montserrat', sans-serif; }

How to add custom font in my theme?

now, i want to use Monotype Corsiva. i add the font in my theme ,then in css file using font-family:Monotype Corsiva ,but some one tips me: font used for site title and headings is not working if it's not installed on users system. You should either remove font file from theme directory or include it in css file in apropriate way.
how to include it in css file in apropriate way? thank you
You need to use #font-face with your font in either .ttf or .eot
Below is an example
#font-face {
font-family: 'RieslingRegular';
src: url('fonts/riesling.eot');
src: local('Riesling Regular'), local('Riesling'), url('fonts/riesling.ttf') format('truetype');
}
h1 {
font-family: 'RieslingRegular', Arial, sans-serif;
}
For more details, look here http://bavotasan.com/2010/embedding-fonts-web-site-css-font-face/
Monotype Corsiva is a copyrighted font. Check out http://www.fonts.com for conditions and instructions for use. They have a policy that allows a limited number of page views (25,000) for free. The instructions and procedures might be a bit confusing, but in the end you will have a script element generated by them to add to your pages, and then you will just use the font under the name they give you (it seems to be Corsiva W01).
Alternative, try and find a suitably similar free font from Google Web Fonts, for example.

Is it possible to specify custom name for a Google Font?

Here is a sample CSS
h1 {
font-family: 'header-font', arial, sans-serif;
}
p {
font-family: 'paragraph-font', arial, serif;
}
Is it possible to load any remote Google Font (let say 'Lato') so that it's family name in CSS would be 'header-font'?
Edit: The idea behind this is to be able to easily swap fonts in a WP theme. Unfortunately using variables in CSS preprocessors is not an option in my case.
I don't think you can to be honest. The Google font has a predefined name when you view the google font. See this for example: http://fonts.googleapis.com/css?family=Akronim
Its name is set as 'Akronim' and I dont think you can reference it by any other name.
Yes, very easily. Once you located the font at Google, eg.
#import url('https://fonts.googleapis.com/css?family=Lato:400&subset=latin-ext');
just direct your browser to the url specified:
https://fonts.googleapis.com/css?family=Lato:400&subset=latin-ext
What you get back is the #font-face CSS item for the font (or fonts). Simply use this verbose version in your CSS instead of the original #import specification. You can freely rename the font-family item in any of these descriptions. Yes, you have to make sure there are no clashes with other fonts but the naming is completely up to you.
Yes, you can give any name you want when you define the font family in the #font-face style declaration and use that name to reference it later in the stylesheet.
#font-face
{
font-family: whateverYouWant;
src: url('example.ttf'),
url('example.eot');
... /* and so on */
}
Whatever you name the style as in the font-family property is how it will be referred to from the rest of the document. However I don't know how it competes with local font files (so if you tried to name a custom font Arial I'm not sure what you would get - the custom font or the real Arial). I don't know why you would do that anyway though.

Can browsers resolve font-face conflicts

My site uses some fonts with the #font-face CSS tag.
However I'm trying to add some temporary CSS styling to my site for a holiday or season...
I'd like to change an accent font to a different font. I was wondering if it was possible to leave the original CSS and just let my seasons.css file override it. Can browsers resolve #font-face conflicts?
My original CSS would be like:
#font-face {
Font-family: 'accentfont2';
Src: url(example/font.ttf);
}
And then my seasonal CSS which will be positioned below the standard CSS will be like:
#font-face {
Font-family: 'accentfont2';
src: url(example/seasonalfont.ttf);
}
Would the browser resolve the conflict by using the seasonalfont.ttf rather than the font.ttf?
Just use !important at the end of your seasonal styles, this will override the normal ones.
so.......
#font-face {
Font-family: 'accentfont2';
src: url(example/seasonalfont.ttf) !important;
}
You would want to comment out the seasonal ones when you didn't want them though by putting /* at the start of the seasonal code and / at the end, this will make them so they are ignored until you uncomment them by removing the / and the */ .
One alternative would just be to comment out the normal font css and uncomment the seasonal one when you want to use it.
Option 3 would just be to replace the font file with the other one each season, this way you wouldn't need to dive into the css at all, just change it via ftp.
They can... all I had to do was type the normal CSS and it worked. This question was looking for a recommendation/condemnation but whatever

Resources