Local Google Fonts

外掛說明

在伺服器本機上代管網站所使用的 Google Fonts 網頁字型,讓網站更符合 GDPR 規範 💯。

有超過 5 千萬個網站 (資料來源) 使用 Google Fonts 網頁字型,而德國法院於 2022 年 1 月判定使用 Google Fonts 網頁字型的網站違反歐盟的 GDPR (一般資料保護規定)。

詳情請參考 wptavern.com 的報導。

安裝方式

  1. 將完整的 local-google-fonts 資料夾上傳至 /wp-content/plugins/ 目錄。
  2. 在 WordPress 管理後台的 [外掛] 選單中啟用外掛。
  3. 前往 [設定]→[Google Fonts 網頁字型] 並選取要變更為伺服器本機載入的網頁字型。

常見問題集

這個外掛是否會自動載入 Google Fonts 網頁字型?

網站管理員如果啟用 [自動載入字型] 設定,便會自動載入字型;如果並未啟用這項設定,則必須手動觸發載入字型。

在自有伺服器本機代管 Google Fonts 所提供的網頁字型是否合法?

合法。Google Fonts 提供的開源網頁字型,無論是商業使用或個人使用,其授權允許網站管理員將這些網頁字型使用於任何網站。

如果檢查網站是否有載入 Google Fonts 網頁字型?

如果要確認網站是否載入第三方 (亦即站外) 來源的字型 (請查看上方第 2 張螢幕擷圖),檢查方式非常簡單:

  1. 開啟瀏覽器的開發人員工具 (在 macOS 為 Cmd + Opt + I,在 Windows 為 F12 或 Ctrl + Shift + I)。
  2. 前往 [網路] 分頁,然後選取 [字型] 類型。
  3. 重新載入頁面便能查看網站上載入的全部字型。
  4. 查看 [網域] 欄位 (有可能需要手動啟用) 是否包含第三方網域 (亦即站外)。Google Fonts 網頁字型使用的網域為 fonts.gstatic.com。

如果使用 Local Google Fonts 在伺服器本機上代管網站所使用的 Google Fonts 網頁字型,生效後就不該有從 Google 伺服器載入的網頁字型。

網站所使用的網頁字型並未顯示於設定頁面,網站管理員該如何處理?

只要使用網頁字型就可以偵測到。請試著先瀏覽網站前端,然後返回設定頁面。

網站使用的網頁字型並未替換,網站管理員該如何處理?

這個外掛目前僅能檢查透過 wp_enqueue_style 函式嵌入的網頁字型,如果網站採用 @import 呼叫 Google Fonts 網頁字型,必須先變更呼叫方式。

使用這個外掛後,Divi 佈景主題仍自行載入 Google 伺服器的 Google Fonts 網頁字型。

Divi 佈景主題針對載入 Google Fonts 網頁字型有其專屬的自訂改善方式。使用的 Divi 佈景主題的網站如需採用 Local Google Fonts 外掛,請在 Divi 的 [Performance Settings] (效能設定) 頁面中停用 [Improve Google Fonts Loading] (改善 Google Fonts 網頁字型載入)。

為什麼僅載入 woff2 格式的字型檔案?

woff2 是 woff 的後續格式,提供比原始 woff 更多 3 成的壓縮率。目前有超過 96% 的瀏覽器 (資料來源) 支援 woff2 格式。

如何在伺服器本機代管 Slider Revolution 載入的字型?

Slider Revolution 使用專屬方式載入 Google Fonts 網頁字型,因此 Local Google Fonts 無法處理,但 Slider Revolution 已為投影片輪播內建相關功能。

  1. 前往 [Slider Revolution]。
  2. 點擊頁面頂端導覽列的 [Global] (全域)。
  3. 尋找 [Fonts] (字型) 區段並在 [Enable Google Fonts download] (啟用 Google Fonts 網頁字型下載) 中選取 [Cache Fonts Local] 在網站主機快取字型。
  4. 儲存設定。

為什麼某些字元使用遞補字型顯示?

網站載入了不包含必要字元的字型子集,請在外掛設定頁面選取其他字型子集,然後重新載入字型。

使用者評論

2025 年 1 月 8 日
It works like a charm. All who got problems getting it working:In settings > Google Fonts, tick the “Load Fonts automatically” checkbox and click on the “Reload Fonts” button. Then save the changes. That’s it. You will see in your browsers inspector > Network that the fonts are hosted locally (at least here it is)
2024 年 10 月 21 日
Lors de mes premiers essais, il y a quelques mois, l’extension ne fonctionnait pas. Aujourd’hui elle semble marcher parfaitement. Très efficace, merci au concepteur !
2024 年 7 月 12 日 1 則留言
Easy Google Fonts with same logo work perfectly. But this plugin useless and unclear why.
2023 年 11 月 26 日 1 則留言
I couldn’t find any documentations about what to do first with this plugin. Also I couldn’t find nothing on the Setting page. How do I make it work? Furthermore, it is outdated now.
閱讀全部 81 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Local Google Fonts〉的開發相關工作。

參與者

〈Local Google Fonts〉外掛目前已有 11 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將〈Local Google Fonts〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

0.23.0

  • Update WordPress ‘Tested up to’ version to 6.7
  • Don’t show admin message when plugin is network-activated

0.22.0

  • fixed: missing $user_agent variable
  • fixed: missing $tmp_file variable

0.21.0

  • fixed: issue downloading fonts with WordPress 6.2 caused by the download_url method

0.20.0

  • make sure files are loaded via https if requested
  • new filter lgf_folder_urland lgf_folder
  • always append timestamp to prevent caching

0.19

  • please reload fonts manually if you encounter problems after the update
  • completely rewriting the way fonts are loaded which to drop the need for a third party API and support more (deprecated) fonts.
  • better support for multi site (thanks @ravanh)
  • the original style sheet is used for better compatibility
  • added Settings link on the plugins list page
  • added button to manually fetch homepage for used fonts
  • only woff2 fonts are now loaded for better subset support
  • removed unused seed variable

0.18

  • do not use remove_query_arg to strip args as it can break some URLs

0.17

  • remove ver query argument from URLs as they are added by WordPress. Please review settings as fonts may have to be reloaded
  • introduced upgrade class for future updates
  • added: welcome message after plugin activation
  • added Codeable banner
  • fixed: PHP warning on missing key

0.16

  • using absolute path to support Google Fonts in Mailster.

0.15

  • using custom mirror to prevent down times

0.14

0.13

  • improved: better explanations on errors.
  • improved: Higher propriety for wp_resource_hints to catch them all. Fixes #8
  • implemented an alias method for no longer supported fonts.
  • fixed: Syntax error on older PHP versions

0.12

  • Do not handle fonts sources with more than 30 families (why would you need that?)
  • Add option to choose subsets for each font family
  • Disable functionality in the customizer

0.11

  • fixed: problem on customizer in Neve theme
  • fixed wrong domain on translations
  • update F.A.Q. for DIVI theme

0.10

  • fixed: rending issue on some fonts (please reload fonts if you use one of these: “exo-2”, “inter”, “jost” or “montserrat”)
  • fixed: some styles are not recognized and therefore not loaded.
  • improved: info about loaded font files on the admin screen
  • added timestamp to loaded font files to prevent cached fonts get loaded.

0.9

  • new: options to load fonts automatically

0.8

  • updated required WP version to 4.6
  • remove Text Domain header
  • added missing translatable strings

0.7

  • better handling of multiple “family” arguments in the URL

0.6

  • loading all variants if none explicit are requested
  • cache API requests
  • respect font-display
  • removes DNS prefetch and preconnect to Google server from page header

0.5

  • added option to flush everything

0.4

  • you may have to reload fonts so please check the settings page
  • improved handling of fonts
  • only loading required font files
  • supports now different types of variant declarations
  • add variants to list only if available in the source
  • added some css to improve settings page
  • you may have to reload fonts so please check the settings page

0.3

  • add explanation info on settings page

0.2

  • show info when no font is found
  • better handling of translated strings

0.1

  • initial release