Node.js 通过LESS将字体Squirrel生成的字体集成到Twitter引导程序中
我正在尝试使用FontSquirrel生成的字体作为Twitter引导的基本字体(从LESS文件编译)。我将Express.js与Node.js一起使用,并将字体文件包含在字体目录中,即Node.js 通过LESS将字体Squirrel生成的字体集成到Twitter引导程序中,node.js,twitter-bootstrap,express,less,font-face,Node.js,Twitter Bootstrap,Express,Less,Font Face,我正在尝试使用FontSquirrel生成的字体作为Twitter引导的基本字体(从LESS文件编译)。我将Express.js与Node.js一起使用,并将字体文件包含在字体目录中,即 myapp |_ public |_ stylesheets |_ font 我通过更改引导中的变量“安装”了Font Awesome。less并使其正常工作,因此我知道目录结构是正确的。使用font目录中的自定义字体文件,我下一步要去哪里?我需要创建一个包含@font-face声明的
myapp
|_ public
|_ stylesheets
|_ font
我通过更改引导中的变量“安装”了Font Awesome。less
并使其正常工作,因此我知道目录结构是正确的。使用font
目录中的自定义字体文件,我下一步要去哪里?我需要创建一个包含@font-face
声明的我的自定义font.less
文件,还是需要在一个无引导文件中声明?我知道基本字体是通过@baseFontFamily
属性在变量中声明的。less
,但正如我所描述的,我不确定如何将其声明为我的自定义字体系列。提前谢谢
编辑
下面是我尝试使用的代码片段:
@ChatypePath: "font";
@font-face {
font-family: 'chatypeb2.1regular';
src: url('@{ChatypePathPath}/chatypeb2.1regular-webfont.eot?v=3.0.1');
src: url('@{ChatypePathPath}/chatypeb2.1regular-webfont.eot?#iefix&v=3.0.1') format('embedded-opentype'),
url('@{ChatypePathPath}/chatypeb2.1regular-webfont.woff?v=3.0.1') format('woff'),
url('@{ChatypePathPath}/chatypeb2.1regular-webfont.ttf?v=3.0.1') format('truetype');
}
注意:这里有一些错误
更新:
正确声明:
@chatypeFontFamily: "ChatypeB2.1ThinThin", "Courier New", monospace;
@font-face {
font-family: 'ChatypeB2.1ThinThin';
src: url('font/chatypeb2.1thin-webfont.eot');
src: url('font/chatypeb2.1thin-webfont.eot?#iefix') format('embedded-opentype'),
url('font/chatypeb2.1thin-webfont.woff') format('woff'),
url('font/chatypeb2.1thin-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
我会在
变量中尝试类似的操作。less
:
@customFontFamily: "Custom", "Courier New", monospace;
/* here you should use whatever @font-face squirrel generated in the stylesheet.css */
@font-face {
font-family: 'Custom';
font-style: normal;
font-weight: 400;
src: local('Custom'), local('Custom-Regular'), url(path.to.font.file.woff) format('woff');
}
您也可以将
字体
放入一个单独的文件,然后使用@import
,但我认为没有必要这样做。然后,您可以调用@cusomfontframy
并将其用作@basefontframy
,或者在您想要的任何地方使用。执行此操作后,较少的编译似乎会中断。无需调整,我可以保存更少的文件,并编译CSS。但是,添加后,LESS文件未编译。思想?我已经添加了我正在使用的代码片段;有什么问题吗?更新:在我的字体松鼠档案中提供了3种不同的字体。显然,为原始字体提供的CSS标记不正确,因为添加正确的@font-face
属性有效。酷。。。我很高兴你成功了。这是有点傻,虽然他们会产生一个坏的CSS。当我下载一些东西进行测试运行时,它工作得很好。但无论如何,指定要加载的font-style
和font-weight
也很好。