首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让fontello玩Meteor

如何让fontello玩Meteor
EN

Stack Overflow用户
提问于 2015-02-20 09:35:28
回答 3查看 326关注 0票数 0

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

代码语言:javascript
复制
css
    fontello.css
    ...
font
    fontello.eot
    fontello.svg
    fontello.ttf
    fontello.woff

我已经修改了fontello.css路径,使其指向Meteor使用的'public‘文件夹:

代码语言:javascript
复制
@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;
}

因此,我已经将上面提到的'font‘文件夹移到了上述'public’文件夹中。

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

代码语言:javascript
复制
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");
});

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

EN

回答 3

Stack Overflow用户

发布于 2015-02-20 13:29:54

当你把你的文件放在public中时,从根文件夹访问文件就足够了(参见下面的代码),并且指向你的文件的指针有些错误,因为你把#?放在url中,而url中本不应该有这样的东西。

代码语言:javascript
复制
@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启动path,如下所示

代码语言:javascript
复制
Package.onUse(function(api) {
    api.versionsFrom('1.0.3.1');
    api.addFiles('tidee-fontello.js');  // put the location from root directory
    api.addFiles('public/font/fontello.eot', "client");
    api.addFiles('public/font/fontello.svg', "client");
    api.addFiles('public/font/fontello.ttf', "client");
    api.addFiles('public/font/fontello.woff', "client");
    api.addFiles('public/css/fontello.css', "client");
    api.addFiles('public/css/animation.css', "client");
});

希望这能有所帮助

票数 1
EN

Stack Overflow用户

发布于 2015-02-21 07:53:56

我有一个类似的设置

代码语言:javascript
复制
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“映射到"/”

票数 0
EN

Stack Overflow用户

发布于 2015-02-22 08:04:10

已修复:

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

2)不需要将任何fontello资产移动到公共文件夹。相反,fontello.css文件被更新为:

代码语言:javascript
复制
@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;
}

...and package.js文件已更新为:

代码语言:javascript
复制
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应用程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28620281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档