如何让fontello与Meteor一起玩

时间:2015-02-20 01:35:28

标签: meteor fontello

我正在尝试将当前项目移植到Meteor,其中包含标准的fontello文件结构:

css
    fontello.css
    ...
font
    fontello.eot
    fontello.svg
    fontello.ttf
    fontello.woff

我已经推荐fontello.css路径指向公众' Meteor使用的文件夹:

@font-face {
  font-family: 'fontello';
  src: url('/font/fontello.eot?35453292');
  src: url('/font/fontello.eot?35453292#iefix') format('embedded-opentype'),
       url('/font/fontello.woff?35453292') format('woff'),
       url('/font/fontello.ttf?35453292') format('truetype'),
       url('/font/fontello.svg?35453292#fontello') format('svg');
  font-weight: normal;
  font-style: normal;
}
因此,我已经移动了上面提到的'字体'文件夹进入公共'文件夹中。

此外,我创建了一个新的Meteor包,其中package.js文件包含:

Package.onUse(function(api) {
    api.versionsFrom('1.0.3.1');
    api.addFiles('my-fontello.js'); 
    api.addFiles('font/fontello.eot', "client");
    api.addFiles('font/fontello.svg', "client");
    api.addFiles('font/fontello.ttf', "client");
    api.addFiles('font/fontello.woff', "client");
    api.addFiles('css/fontello.css', "client");
    api.addFiles('css/animation.css', "client");
});

我没有看到任何字体图标显示 - 有什么想法吗?

3 个答案:

答案 0 :(得分:1)

当您将文件放在public中时,使用root文件夹访问文件就足够了(请参阅下面的代码)和指向您文件的指针,因为我看到您放置#和{在网址中{1}},不应该在那里。

?

并且要在包中使用它,您需要从@font-face { font-family: 'fontello'; src: url(/font/fontello.eot); src: url(/font/fontello.eot) format('embedded-opentype'), url(/font/fontello.woff) format('woff'), url(/font/fontello.ttf) format('truetype'), url(/font/fontello.svg) format('svg'); font-weight: normal; font-style: normal; } 开始路径,如下所示

public

希望这有帮助

答案 1 :(得分:0)

我有与

类似的设置
client
  stylesheets
    fontello-social.css
public
  fonts
    fontello-social.eot
    fontello-social.svg
    fontello-social.ttf
    fontello-social.woff

我根本没有使用包文件。

在fontello-social.css中,4个文件的url路径的格式为/ fonts / filename,因为" public"映射到" /"

答案 2 :(得分:0)

修正:

1)虽然我已经创建了我的包,但实际上并没有将它添加到我的应用程序中。因此我运行了命令'sudo meteor add my-fontello'。

2)无需将任何fontello资产移动到公共文件夹。而是将fontello.css文件更新为:

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

...并且package.js文件已更新为:

Package.onUse(function(api) {
    api.versionsFrom('1.0.3.1');
    api.addFiles('my-fontello.js'); 
    api.addFiles('font/fontello.eot', "client");
    api.addFiles('font/fontello.svg', "client");
    api.addFiles('font/fontello.ttf', "client");
    api.addFiles('font/fontello.woff', "client");
    api.addFiles('css/fontello.css', "client");
    api.addFiles('css/animation.css', "client");
});

值得一提的是,为了让Meteor能够接收到这个包中的CSS文件所做的更改,我需要重新启动我的Meteor应用程序。