且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何添加自定义字体到Rails应用程序?

更新时间:2023-11-24 13:35:46

Checkout http://www.css3.info/preview/web -fonts-with-font-face /

Checkout http://www.css3.info/preview/web-fonts-with-font-face/

更大的例子,假设它们直接在assets下解析dir

Larger example, assuming they're resolved directly under the assets dir

@font-face {
  font-family: 'Nokia Pure Headline';    
  src: url('/assets/nokiapureheadlinerg-webfont.eot');
  src: url('/assets/nokiapureheadlinerg-webfont.eot?iefix') format('eot'),
  url('/assets/nokiapureheadlinerg-webfont.woff') format('woff'),
  url('/assets/nokiapureheadlinerg-webfont.ttf') format('truetype'),
  url('/assets/nokiapureheadlinerg-webfont.svg#webfont3AwWkQXK') format('svg');
  font-weight: normal;
  font-style: normal;
}

对不起,我不知道LESS

Im sorry I dont know LESS

对于资产管道的配置,我们使用的资产/字体的内容也可以使用:

Also for the config of the assets pipeline to have the contents of assets/fonts available under we use:

# Enable the asset pipeline
config.assets.enabled = true
config.assets.paths << Rails.root.join('/app/assets/fonts')