簡體   English   中英

@font-face 和自定義 fonts 未加載到 WordPress

[英]@font-face and custom fonts not loading on WordPress

我正在本地開發 WordPress 站點,無法正確加載 fonts。 我已將 fonts 的相同文件夾帶到一個普通的 html 網站,並且正確加載了 fonts。 我的問題似乎僅限於這個項目。

fonts 位於我的主題文件夾中的字體文件夾中。 下面的代碼寫在 sass 文件夾中的 _typography.scss 上。 Sass編譯到styles.ZC7A628CBA22E28EB17B5A56AZ文件上的主題的css文件夾中。

按照 scss 和 css 文件上的兩個文件路徑,您將找到相應的文件。

@font-face {
  font-family: "computerfontregular";
  src: url("/fonts/computer-font/computerfont-webfont.eot");
  src: url("/fonts/computer-font/computerfont-webfont.eot?#iefix")
      format("embedded-opentype"),
    url("/fonts/computer-font/computerfont-webfont.woff2") format("woff2"),
    url("/fonts/computer-font/computerfont-webfont.woff") format("woff"),
    url("/fonts/computer-font/computerfont-webfont.ttf") format("truetype"),
    url("/fonts/computer-font/computerfont-webfont.svg#computerfontregular")
      format("svg");
  font-weight: normal;
  font-style: normal;
}

第一個錯誤 GEThttp://my-xampp-IP/planet-cruiser/wp-content/themes/planet_cruiser-89/css/fonts/computer-font/computerfont-webfont.woff2 Status 404 Not Found Version HTTP/1.1 Transferred 1.62 KB (1.28 KB 大小)Referrer Policystrict-origin-when-cross-origin Request PriorityHigh

第二個錯誤可下載字體:下載失敗(字體系列:“computerfontregular”樣式:正常重量:400 拉伸:100 src 索引:1):狀態 = 2147746065 來源:http://my-xampp-IP/fonts/computer-font /computerfont-webfont.woff2

它會重復此操作,直到調用了每種類型。

任何幫助表示贊賞。

對於任何可能陷入這種困境的人,請確保您的字體文件夾已被授予讀寫權限。 我在初始設置后添加了 fonts 文件夾,這就是阻止它們加載的原因。 我還需要在路徑中添加“../”。

編輯:還要記住將這些權限授予每個單獨的字體文件夾以及它們存儲的“主”字體文件夾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM