設定字體(Font)
在 Zensical 中,你可以使用 Google Fonts 或 自訂字體 來更改網站的字型。以下是設定方法。
使用 Google Fonts(簡單設定)
Zensical 內建支援 Google Fonts,你可以直接在 zensical.toml 設定:
📌 常見 Google Fonts
Roboto(常見預設)InterNoto SansLatoOpen SansSource Sans ProFira Code/JetBrains Mono(適合程式碼)
停用 Google Fonts
如果基於隱私不想從 Google 載入字型,改用系統字型:
使用自訂字體(本地字型)
如果你有自己的 字體檔案(.woff2 / .ttf),可以手動加入:
步驟 1:將字體檔案放入 docs/assets/fonts/
docs/
├── assets/
│ ├── fonts/
│ │ ├── custom-font.woff2
│ │ ├── custom-font.ttf
├── css/
│ └── extra.css
步驟 2:在 extra.css 設定
@font-face {
font-family: "MyCustomFont";
src: url("../assets/fonts/custom-font.woff2") format("woff2"),
url("../assets/fonts/custom-font.ttf") format("truetype");
}
:root {
--md-text-font: "MyCustomFont";
--md-code-font: "Fira Code";
}
Warning
請用 CSS 變數 --md-text-font / --md-code-font,不要直接改 font-family,否則會關掉系統字型後備方案。
步驟 3:在 zensical.toml 啟用
總結
| 方法 | 設定方式 |
|---|---|
| 內建 Google Fonts | font.text = "Roboto" |
| 停用遠端字型 | font = false |
| 本地字體(自訂字型) | @font-face + --md-text-font |
這樣你就能輕鬆在 Zensical 設定字體!