通过LESS在Font Bootstrap中集成Font Squirrel生成的字体

bas*_*ics 4 less font-face node.js express twitter-bootstrap

我试图使用Font Squirrel生成的字体作为Twitter Bootstrap的基本字体(从LESS文件编译).我正在使用带有Node.js的Express.js,并将字体文件包含在字体目录中,即

myapp
|_ public
    |_ stylesheets
        |_ font
Run Code Online (Sandbox Code Playgroud)

我通过更改变量来"安装"Font Awesome bootstrap.less并使其工作,所以我知道目录结构是正确的.使用font目录中的自定义字体文件,下一步该怎么做?我是否需要创建my-custom-font.less包含@font-face声明的文件,或者我是否需要在其中一个引导LESS文件中声明这个?我知道基本字体是variables.less通过@baseFontFamily属性声明的,但正如我所描述的,我不确定如何声明这是我的自定义字体系列.提前致谢.

编辑

以下是我尝试使用的代码片段:

@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');
}
Run Code Online (Sandbox Code Playgroud)

注意:这里有一些错误.

更新:

正确的声明:

@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;
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*jak 8

我会尝试这样的事情variables.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');
}
Run Code Online (Sandbox Code Playgroud)

你也可以把它font-face放到一个单独的文件然后使用@import,但我不认为这是必要的.然后你可以打电话给@cusomFontFamily@baseFontFamily,或者在任何你想要的地方使用它.