Icon font from fontello not working with Meteor js

梦想的初衷 提交于 2019-12-02 07:09:17

问题


I have downloaded a custom icon font from fontello and intend to use it in my meteor app. I tried the demo that comes with the downloaded package and the fonts display fine. Here is my css:

@font-face {
 font-family: 'fontello';
 src: url('fonts/fontello.eot?98991264');
 src: url('fonts/fontello.eot?98991264#iefix') format('embedded-opentype'),
   url('fonts/fontello.woff?98991264') format('woff'),
   url('fonts/fontello.ttf?98991264') format('truetype'),
   url('fonts/fontello.svg?98991264#fontello') format('svg');
font-weight: normal;
font-style: normal;
}

[class^="icon-"]:before, [class*=" icon-"]:before {
 font-family: "fontello";
 font-style: normal;
 font-weight: normal;
 speak: none;
 display: inline-block;
 text-decoration: inherit;
 width: 1em;
 margin-right: .2em;
 text-align: center;

 /* For safety - reset parent styles, that can break glyph codes*/
 font-variant: normal;
 text-transform: none;

 /* fix buttons height, for twitter bootstrap */
 line-height: 1em;

}

.icon-twitter:before { content: '\e805'; } /* '' */
.icon-github-circled:before { content: '\e804'; } /* '' */
.icon-pencil:before { content: '\e801'; } /* '' */
.icon-cancel:before { content: '\e802'; } /* '' */
.icon-chat:before { content: '\e800'; } /* '' */

My folder structure is like so /client/css/styles.css and for the fonts /client/css/fonts/

In my html I have added this markup <i class="icon-twitter"></i> and unfortunately all i see when I view the page this is all I see

Any help would be great. Thanks

回答1:


If you want to reference your fonts at your.domain.com/fonts/font_name.x, you should move your fonts directory to a directory labeled public. You can then access them using the path /fonts/font_name.x.

Take a look at the Unofficial Meteor FAQ found here: https://github.com/oortcloud/unofficial-meteor-faq#where-should-i-put-my-files

public/ # <- static files, such as images, that are served directly.

Or the Meteor documentation directly: http://docs.meteor.com/#structuringyourapp

Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.




回答2:


Try using absolute paths:

@font-face {
 font-family: 'fontello';
 src: url('/client/css/fonts/fontello.eot?98991264');
 src: url('/client/css/fonts/fonts/fontello.eot?98991264#iefix') format('embedded-opentype'),
   url('/client/css/fonts/fontello.woff?98991264') format('woff'),
   url('/client/css/fonts/fontello.ttf?98991264') format('truetype'),
   url('/client/css/fonts/fontello.svg?98991264#fontello') format('svg');
font-weight: normal;
font-style: normal;
}

Also it might be better to store fonts in /public as in production mode /client wont work anymore and you'll get those squares again & you could use /fonts/ instead (to map to /public/fonts)




回答3:


I had the same issue and the way I solved was by using these absolute paths:

@font-face {
    font-family: 'icomoon';
    src:url('/fonts/icomoon.eot');
    src:url('/fonts/icomoon.eot?#iefix') format('embedded-opentype'),
      url('/fonts/icomoon.woff') format('woff'),
      url('/fonts/icomoon.ttf') format('truetype'),
      url('/fonts/icomoon.svg#icomoon') format('svg');
    font-weight: normal;
    font-style: normal;
 }

Directly on the public/fonts/ directory. I guess that MeteorJS is smart enough to guess the paths.



来源:https://stackoverflow.com/questions/16937918/icon-font-from-fontello-not-working-with-meteor-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!