feat: font selection with three bundled fonts

- Add FontDef registry (思源黑体 bundled, 霞鹜文楷 + 思源宋体 runtime)
- Runtime font loading from fonts/ dir with fallback to bundled default
- ComboBox in toolbar to switch fonts
- Persist font_name in settings
- Download LXGW WenKai Lite (13MB) and Source Han Serif SC (23MB)
This commit is contained in:
Developer
2026-05-16 22:07:52 +08:00
parent f2b5be312c
commit f76c59b6cf
7 changed files with 112 additions and 33 deletions

View File

@@ -165,6 +165,7 @@ pub struct ReaderAction {
pub toggle_bookmark: bool,
pub switch_bg: Option<BgType>,
pub switch_to_profile: Option<String>,
pub switch_font: Option<String>,
pub page_next: bool,
pub page_prev: bool,
}
@@ -181,6 +182,7 @@ pub fn reading_view(
_file_path: &str,
profile_names: &[String],
bookmarks: &[crate::theme::Bookmark],
current_font: &str,
) -> (ReaderAction, Option<usize>) {
let mut action = ReaderAction {
go_back: false,
@@ -188,6 +190,7 @@ pub fn reading_view(
toggle_bookmark: false,
switch_bg: None,
switch_to_profile: None,
switch_font: None,
page_next: false,
page_prev: false,
};
@@ -279,6 +282,17 @@ egui::ComboBox::from_id_salt("bg_type_selector")
}
}
});
egui::ComboBox::from_id_salt("font_selector")
.width(100.0)
.selected_text(current_font)
.show_ui(ui, |ui| {
for name in crate::font::font_display_names() {
let selected = name == current_font;
if ui.selectable_label(selected, &name).clicked() {
action.switch_font = Some(name);
}
}
});
if ui.button("").on_hover_text("打开/关闭目录").clicked() {
*sidebar_open = !*sidebar_open;
}