2014-10-22 57 views
1

我的指南針目錄看起來是這樣的:指南針@字體面無法找到字體文件

root_of_directory 
    sass 
    screen.scss 
    stylesheets 
    fonts 
     goudysto.ttf 
    screen.css 

,然後混入的字體面看起來是這樣的:

@include font-face("goudysto", font-files("goudysto.ttf", "truetype")); 

輸出在控制檯中這樣說:

GET file:///fonts/goudysto.ttf net::ERR_FILE_NOT_FOUND 

這是輸出的CSS

@font-face { 
    font-family: "goudysto"; 
    src: url('/fonts/goudysto.ttf') format('truetype'); 
    } 

誰能告訴我爲什麼會發生這種情況?

*更新 - config.rb *

require 'compass/import-once/activate' 
# Require any additional compass plugins here. 

# Set this to the root of your project when deployed: 
http_path = "/" 
css_dir = "stylesheets" 
sass_dir = "sass" 
images_dir = "images" 
javascripts_dir = "javascripts" 
fonts_dir = "stylesheets/fonts" 

# You can select your preferred output style here (can be overridden via the command line): 
# output_style = :expanded or :nested or :compact or :compressed 

# To enable relative paths to assets via compass helper functions. Uncomment: 
# relative_assets = true 

# To disable debugging comments that display the original location of your selectors. Uncomment: 
# line_comments = false 


# If you prefer the indented syntax, you might want to regenerate this 
# project again passing --syntax sass, or you can uncomment this: 
# preferred_syntax = :sass 
# and then run: 
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass 
+0

它將'/'預先添加到您的URL中,這意味着字體文件沒有找到,因爲它在根目錄中查找(如果項目位於項目文件夾中,那麼根深於你的項目)。你有沒有嘗試刪除開始的'/'? – somethinghere 2014-10-22 12:09:47

+0

這是添加開始/自動。我不知道如何刪除它。 – chap 2014-10-22 12:22:43

+0

首先在實際的CSS文件中刪除它,看看是否能解決它,然後至少你知道錯誤是什麼方向。 – somethinghere 2014-10-22 12:25:05

回答

0

設置fonts_dir在config.rb這樣的:

fonts_dir = "stylesheets/fonts" 

編輯:此外,如在評論中提到,確保取消註釋# relative_assets = true並在config.rb中使用相對路徑...

+0

當我將它移動到根目錄時,它提供了以下內容。 GET文件:///fonts/goudysto.ttf?1413956247 net :: ERR_FILE_NOT_FOUND index.html:1好像在附加數字。 – chap 2014-10-22 12:21:18

+0

你試過設置fonts_dir嗎? – elbblick 2014-10-22 12:22:41

+0

是的,我也試過。到目前爲止沒有運氣。 – chap 2014-10-22 12:23:50