To install the TrueType font in Windows:Click on Start, Select, Settings and click on Control Panel. Click on Fonts, click on File in the main tool bar and select Install New Font. Select the folder where the font is located. The fonts will appear; select the desired font that is titled TrueType and click on OK.
Add a font-face section to your CSS codesrc: url('fonts/lovely_font. otf') format('opentype'); src: url('fonts/lovely_font. ttf') format('truetype'); As another optional efficiency measure, we can get the browser to check for a local copy of the font in case the user already has it.
Only providing .ttf file for webfont won't be good enough for cross-browser support. The best possible combination at present is using the combination as :
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
This code assumes you have .eot , .woff , .ttf and svg format for you webfont. To automate all this process , you can use : Transfonter.org.
Also , modern browsers are shifting towards .woff font , so you can probably do this too : :
@font-face {
font-family: 'MyWebFont';
src: url('myfont.woff') format('woff'), /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('myfont.ttf') format('truetype'); /* Chrome 4+, Firefox 3.5, Opera 10+, Safari 3—5 */
}
Read more here : http://css-tricks.com/snippets/css/using-font-face/
Look for browser support : Can I Use fontface
Did you try format?
@font-face {
font-family: 'The name of the Font Family Here';
src: URL('font.ttf') format('truetype');
}
Read this article: http://css-tricks.com/snippets/css/using-font-face/
Also, might depend on browser as well.
You can use font face like this:
@font-face {
font-family:"Name-Of-Font";
src: url("yourfont.ttf") format("truetype");
}
I know this is an old post but this solved my problem.
@font-face{
font-family: "Font Name";
src: url("../fonts/font-name.ttf") format("truetype");
}
notice src:url("../fonts/font-name.ttf");
we use two periods to go back to the root directory and then into the fonts folder or wherever your file is located.
hope this helps someone down the line:) happy coding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With