I need to include a font (OpenSymbol) in a html file and the font file is in a local folder (I know the exact absolute path to it). If I use @font-face like this:
@font-face { font-family: "OpenSymbol"; src: url("<absolutePath>/OpenSymbol.ttf") format("truetype"); }
It works in Chrome, Opera and Safari, but not in Firefox neither IE9. Other @font-face usage works perfectly fine in all browsers.
Btw, in Chrome, I get a warning:
Resource interpreted as Font but transferred with MIME type application/octet-stream
What can I do to cleanly include a locally stored font which is not installed on the OS?
Edit:
I found out that the listing of different urls seems not to work! Chrome loads the font if I put the [...].ttf
url in the first place, but not if it's somewhere else!
2nd Edit:
I got it to work in all browsers except firefox:
@font-face { font-family: 'OpenSymbol'; src: url('file:<path>/openSymbol.ttf') format('truetype'); font-weight: normal; font-style: normal; } @font-face { font-family: 'OpenSymbolEOT'; src: url('file:<path>/openSymbol.eot') format('embedded-opentype'); font-weight: normal; font-style: normal; } ...
and then
.element { font-family: OpenType, OpenTypeEOT, [...]; }
Anyway, it does work in IE but not in eclipse, which uses IE's rendering engine... o.O
Btw, firefox has problems because of security issues: See here
@font-face { font-family: 'OpenSymbol'; src: url('file:<path>/openSymbol. ttf') format('truetype'); font-weight: normal; font-style: normal; } @font-face { font-family: 'OpenSymbolEOT'; src: url('file:<path>/openSymbol. eot') format('embedded-opentype'); font-weight: normal; font-style: normal; } ...
You should change src:url("C:/path/to/ttf"); to src:url("file:///path/to/file") . Show activity on this post. Show activity on this post. Just add bellow code before all the styling of your css file and then you can use this font family for any selector inside within your css file.
You can use a <basefont> tag to set all of your text to the same size, face, and color. The font tag is having three attributes called size, color, and face to customize your fonts. To change any of the font attributes at any time within your webpage, simply use the <font> tag.
You just need one font file in web open font format. Go to http://www.fontconverter.org to convert your OpenSymbol.tff to OpenSymbol.woff
. I am a cross-platform developer and i tested this works okay on:
This goes in the css:
/* Add the decaration on top */ @font-face { font-family: 'OpenSymbol'; src: url('font/OpenSymbol.woff') format('woff'); } /* in separate css .elements or even the whole body, edit your font properties */ body { font-family: OpenSymbol; font-weight: normal; font-style: normal; ..
No need to bother with Embedded OpenType (EOT) fontfiles, because they are only needed for IE9 (2011) and IE10 (2012). No need to bother with Scalable Vector Graphics (SVG) fonts, because they're no longer needed since iOS 5.0
Already since 2012 Web Open Font Format (WOFF) is fully supported by every known browser. Truetype Fonts (TTF) are used local on iMac and PC, and can be used local on Android and iPhone as well. That's why web developers often make this mistake, using TTF instead of WOFF for a site.
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