Custom Font Selection
May 11, 2026 · View on GitHub
This document describes the custom font selection feature in Ferrite, which allows users to choose their preferred fonts for the editor and configure CJK regional glyph preferences.
Overview
Ferrite supports three types of font configurations:
- Built-in Fonts: Inter (proportional) and JetBrains Mono (monospace) are bundled with the application
- Custom System Fonts: Users can select any font installed on their system
- CJK Regional Preferences: Users can prioritize specific regional variants for CJK characters
Feature Details
Built-in Fonts
- Inter: A modern, clean proportional font used for general text
- JetBrains Mono: A monospace font optimized for code and technical documents
Both fonts include bold and italic variants for proper styling.
Custom System Font Selection
Users can select any system font from Settings → Appearance → Font.
How it works:
- The system font list is enumerated using
font-kitcrate on application startup - Fonts are cached to avoid re-enumeration on each settings panel open
- Choosing Custom sets
EditorFont::Customwith an empty name until the user picks a row in the combo; font reload runs without a custom primary face until then (Inter stays active). This avoids immediately loading the first sorted family name, which can fail on some macOS setups where enumeration names do not resolve the same way asselect_best_match/ path reads (GitHub #133). - When a custom font is selected, it's loaded dynamically and added to the font fallback chain
- The custom font name is stored in
config.json
Empty custom names are normalized away when loading settings (Settings::sanitize).
Implementation detail: Custom font picker deferred load.
Limitations:
- Custom fonts don't have separate bold/italic variants loaded
- The OS may synthesize bold/italic styles depending on the font and platform
- Not all system fonts may be suitable for text editing
CJK Regional Glyph Preferences
CJK (Chinese, Japanese, Korean) fonts render the same Unicode code points differently based on regional conventions. This setting controls which regional font takes priority.
Available options:
| Option | Priority Order | Description |
|---|---|---|
| Auto | KR → SC → TC → JP | Use system locale to determine |
| Korean | KR → SC → TC → JP | Prioritize Korean glyph variants |
| Simplified Chinese | SC → TC → KR → JP | Prioritize Simplified Chinese |
| Traditional Chinese | TC → SC → KR → JP | Prioritize Traditional Chinese |
| Japanese | JP → KR → SC → TC | Prioritize Japanese glyph variants |
System fonts used:
| Region | macOS | Windows | Linux |
|---|---|---|---|
| Korean | Apple SD Gothic Neo | Malgun Gothic | Noto Sans CJK KR, NanumGothic |
| Simplified Chinese | PingFang SC | Microsoft YaHei | Noto Sans CJK SC |
| Traditional Chinese | PingFang TC | Microsoft JhengHei | Noto Sans CJK TC |
| Japanese | Hiragino Sans | Yu Gothic, Meiryo | Noto Sans CJK JP |
Implementation
Key Files
| File | Purpose |
|---|---|
src/fonts.rs | Font loading, system font enumeration, and runtime font reload |
src/config/settings.rs | EditorFont enum with Custom variant, CjkFontPreference enum |
src/ui/settings.rs | Settings UI for font picker and CJK preference dropdown |
src/app/ (central_panel.rs, mod.rs) | Font reload when settings change; startup custom load |
EditorFont Enum
pub enum EditorFont {
Inter, // Built-in proportional font
JetBrainsMono, // Built-in monospace font
Custom(String), // Custom system font name
}
CjkFontPreference Enum
pub enum CjkFontPreference {
Auto, // Use system locale
Korean, // Prioritize Korean glyphs
SimplifiedChinese, // Prioritize SC glyphs
TraditionalChinese,// Prioritize TC glyphs
Japanese, // Prioritize Japanese glyphs
}
Font Reload
Fonts are reloaded at runtime when settings change:
// In app.rs, when settings change:
if font_changed {
fonts::reload_fonts(
ctx,
custom_font.as_deref(),
settings.cjk_font_preference,
);
}
Configuration
Font settings are stored in config.json:
{
"font_family": "custom", // or "inter" or "jetbrainsmono"
"font_family": { "custom": "Arial" }, // when using custom font
"cjk_font_preference": "auto" // or "korean", "simplifiedchinese", etc.
}
Testing
- Test font picker shows system fonts
- Test selecting a custom font applies to editor
- Test CJK fonts render correct regional glyphs
- Test font settings persist across restart
- Test invalid custom font falls back gracefully
Related
- GitHub Issue: #15 - CJK regional glyph preferences
- Dependencies:
font-kit0.14.3 for system font enumeration