I'm running into a problem with a Rails app I'm building. I'm using fontawesome to render a few icons. The rails app is running on Heroku.
The problem is that on Chrome/Win and IE8, the icons are not rendered. No box - nothing. They render in IE9, Firefox/Win, and they render on all browsers in OS X.
I have the following in my application.rb:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.precompile += %w( .svg .eot .woff .ttf )
The font files are in the assets/font directory, and the SCSS file has this:
#font-face {
font-family: 'FontAwesome';
src: url('<%= asset_path('fontawesome-webfont.eot?') %>');
src: url('<%= asset_path('fontawesome-webfont.eot?#iefix') %>') format('embedded-opentype'), url('<%= asset_path('fontawesome-webfont.woff') %>') format('woff'), url('<%= asset_path('fontawesome-webfont.ttf') %>') format('truetype');
font-weight: normal;
font-style: normal;
}
Has anyone run into similar issues? (Most posts that I've read either show boxes which is not the problem, or they revolve around issue with the font not working in Firefox.)
Include this in your header file
link rel="stylesheet" href="../css/font-awesome.min.css"
For IE7 Support pls add
link rel="stylesheet" href="../css/font-awesome.min.css"
!--[if IE 7]
link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css"
![endif]--
What are you are using less or scss for your css ?
Related
i tried to add a font from my local project to vuetify and set that for main font but it does not work.
this is my project:
main folder
public
src
assets
font's
my font
iranyekan.css
node modules
and this is my index.html in public
<style>
#font-face {
font-family: "IranYekan";
src: url("../assets/fonts/IranYekan/iranyekanwebregular.woff2") format("woff2"),
url("../assets/fonts/IranYekan/iranyekanwebregular.ttf") format("ttf"),
url("../assets/fonts/IranYekan/iranyekanwebregular.woff") format("woff");
}
</style>
but it does not work. thanks
Try change your links to use:
#/assets/fonts/IranYekan/iranyekanwebregular.ttf
or ~/assets/fonts/IranYekan/iranyekanwebregular.ttf
or ~#/assets/fonts/IranYekan/iranyekanwebregular.ttf
I don't know how is your project, but vue reference the root directory with ~ or #, so do you can try?
<style>
#font-face {
font-family: "IranYekan";
src: url("~#/assets/fonts/IranYekan/iranyekanwebregular.woff2") format("woff2"),
url("~#/assets/fonts/IranYekan/iranyekanwebregular.ttf") format("ttf"),
url("~#/assets/fonts/IranYekan/iranyekanwebregular.woff") format("woff");
}
</style>
I have installed font awesome using npm command npm i -D #fortawesome/fontawesome-free.
Then I try to import it in my scss file in 2 ways.
#import '#fortawesome/fontawesome-free/css/all';
or
#import '#fortawesome/fontawesome-free/scss/fontawesome.scss';
after this I'm only getting blank squares instead of my icons. I'm using font awesome in my scss files like
.radioStyle input[type=radio] + label:before {
content:"\f111";
font-family: "Font Awesome 5 Free";
color: $button-grey;
font-size: 24px;
padding-right: 8px;
vertical-align:middle; }
also I'm using it in my html and I tried also to replace class fa with fas or fab
and none of these is working. When I use CDN everything is working as expected.
any advice?
When this happens to me, it's because I forgot to load their JavaScript or put the font files somewhere that's accessible from the browser. Another common cause of this is the importing the font awesome core but not any styles such as solid.
SCSS/Font Docs:
https://fontawesome.com/how-to-use/on-the-web/using-with/sass#compile
Example Import
#import "variables";
#import "/node_modules/#fortawesome/fontawesome-free/scss/fontawesome";
#import "/node_modules/#fortawesome/fontawesome-free/scss/solid";
JavaScript Docs:
https://fontawesome.com/how-to-use/on-the-web/setup/using-package-managers#next
I am trying to import a web-font in a certain component in my Vue App (created with Vue cli webpack template). Inside the one of my components I try to import the fonts, by referencing a _fonts.scss within the project that has the contents:
#font-face {
font-family: 'SomeFont';
src: url('~/assets/fonts/SomeFont-Regular.woff2') format('woff2'),
url('~/assets/fonts/SomeFont-Regular.woff') format('woff');
font-weight: normal;
font-style: normal;
}
Then, when I open the app, I get this error:
Failed to decode downloaded font: http://localhost:8080/assets/fonts/SomeFont-Regular.woff2
Failed to decode downloaded font: http://localhost:8080/assets/fonts/SomeFont-Regular.woff
With this too:
OTS parsing error: invalid version tag
OTS parsing error: invalid version tag
I searched online for this problem and found nothing, or some relatable circumstances
Try to use relative path when importing fonts in url(). Without '~/fontPath'
Example
#font-face {
font-family: 'MyFont';
src: url("../assets/fonts/MyFont.woff2") format('woff2');
font-weight: normal;
font-style: normal;
}
I had the same problem and found the answer here Vue Cli 3 Local fonts not loading. In short, you have to replace ../assets with ~#/assets.
I have the latest version of videojs. Only in android tablets and mobile, I'm seeing grey boxes where the play and fullscreen buttons should be. These appear properly in other video sites like youtube on the same device. I assume it's the devices own inbuilt controls. Please can anyone tell me how to replace these grey boxes for the correct icons?
The icons in the latest version of VideoJS are now contained within an icon font, which is loaded in using an #font-face rule - this used to be an image sprite.
The reason the font isn't loading is all to do with the syntax they [VideoJS] are using:
#font-face{
font-family: 'VideoJS';
src: url('font/vjs.eot');
src: url('font/vjs.eot?#iefix') format('embedded-opentype'),
url('font/vjs.woff') format('woff'),
url('font/vjs.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Change the above in your videoJS css to:
#font-face{
font-family: 'VideoJS';
src: url('font/vjs.eot?#iefix') format('embedded-opentype'),
url('font/vjs.woff') format('woff'),
url('font/vjs.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
This different syntax however wont work with IE7 and IE8. If you need to support < IE9 i suggest using a conditionally loaded css file to load in this rule:
#font-face {
font-family: 'VideoJS';
src: url('font/vjs.eot');
}
More details can be found in these blog posts http://www.mcnab.co/blog/general/font-face-on-android/ and http://www.mcnab.co/blog/general/font-face-on-android/
I'm having a weird issue with the displaying of quotes and accents in Safari 5. I'm using a font-face font with the following code.
#font-face {
font-family: 'MendozaRomanStd-Book';
src: url('fonts/mendozaromanstd-book.eot');
src: url('fonts/mendozaromanstd-book.svg#mendozaromanstd-book') format('svg'),
url('fonts/mendozaromanstd-book.eot?#iefix') format('embedded-opentype'),
url('fonts/mendozaromanstd-book.woff') format('woff'),
url('fonts/mendozaromanstd-book.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
On Firefox, Chrome, Safari 6, iOS6 and IE the font are displayed correctly:
On Safari 5 however I'm seeing this:
Same charset, same html. I've searched everywhere for reported issues with font-face displaying under Safari 5 but there aren't any reports leading me to suspect something else is going on. Anyone have any idea what could going on here?
Turns out Safari 5 does not show accents or symbols in SVG fonts.
It does show them when using TTF or WOFF fonts, but not in SVG.
Chrome or Safari 6 do not seem to have this problem.
I ended up fixing it by defining a separate font with #font-face, and then targetting Safari 5 with browser specific CSS. So:
/* Font-face for all browsers */
#font-face {
font-family: 'MendozaRomanStd-Book';
src: url('fonts/mendozaromanstd-book.eot');
src: url('fonts/mendozaromanstd-book.svg#mendozaromanstd-book') format('svg'),
url('fonts/mendozaromanstd-book.eot?#iefix') format('embedded-opentype'),
url('fonts/mendozaromanstd-book.woff') format('woff'),
url('fonts/mendozaromanstd-book.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/* Safari5 fix */
#font-face {
font-family: 'MendozaRomanStd-Book2';
src: url('fonts/mendozaromanstd-book.ttf') format('truetype') !important;
font-weight: normal;
font-style: normal;
}
.safari5 body {
font-family: 'MendozaRomanStd-Book2', Times new roman, serif;
-webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px;
-webkit-text-stroke: rgba(255,255,255,0.01) 0.1px;
}
Please note that this code already contains a fix to enable correct rendering of webfonts in Chrome under PC. With the standard fontsquirrel generated code, this leads to horrible jaggyness and not aliased fonts. Until Google can get its act together, a fix is to elevate the SVG file to the top.