Different header sizes
This commit is contained in:
24
src/app.rs
24
src/app.rs
@ -14,8 +14,8 @@ use crate::{
|
||||
util::{GuiSender, file_mtime, log_error},
|
||||
};
|
||||
use egui::{
|
||||
Align, Button, Context, FontData, FontDefinitions, Image, Key, Modifiers, PointerButton,
|
||||
RichText, ScrollArea, Widget, include_image,
|
||||
Align, Button, Context, FontData, FontDefinitions, FontId, Image, Key, Modifiers,
|
||||
PointerButton, RichText, ScrollArea, Widget, include_image,
|
||||
};
|
||||
use eyre::eyre;
|
||||
|
||||
@ -201,6 +201,26 @@ impl App {
|
||||
|
||||
cc.egui_ctx.set_fonts(fonts);
|
||||
|
||||
// markdown font styles
|
||||
cc.egui_ctx.style_mut(|style| {
|
||||
for (name, size) in [
|
||||
("H1", 28.0),
|
||||
("H2", 26.0),
|
||||
("H3", 24.0),
|
||||
("H4", 22.0),
|
||||
("H5", 20.0),
|
||||
("H6", 18.0),
|
||||
] {
|
||||
style.text_styles.insert(
|
||||
egui::TextStyle::Name(name.into()),
|
||||
FontId {
|
||||
size,
|
||||
family: egui::FontFamily::Proportional,
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// enable features on egui_extras to add more image types
|
||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ impl FileEditor {
|
||||
|
||||
if let Some(inner) = &mut self.inner {
|
||||
while let Ok(event) = inner.file_events.try_recv() {
|
||||
match dbg!(event) {
|
||||
match event {
|
||||
FileEvent::NewFileMTime(mtime) => {
|
||||
self.file_mtime = Some(mtime);
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
use egui::text::{CCursorRange, LayoutJob};
|
||||
|
||||
use crate::markdown::Heading;
|
||||
|
||||
use super::{Item, Style, parse};
|
||||
|
||||
/// Highlight markdown, caching previous output to save CPU.
|
||||
@ -71,8 +73,15 @@ fn format_from_style(egui_style: &egui::Style, style: &Style) -> egui::text::Tex
|
||||
egui_style.visuals.text_color()
|
||||
};
|
||||
|
||||
let text_style = if style.heading.is_some() {
|
||||
TextStyle::Heading
|
||||
let text_style = if let Some(heading) = style.heading {
|
||||
match heading {
|
||||
Heading::H1 => TextStyle::Name("H1".into()),
|
||||
Heading::H2 => TextStyle::Name("H2".into()),
|
||||
Heading::H3 => TextStyle::Name("H3".into()),
|
||||
Heading::H4 => TextStyle::Name("H4".into()),
|
||||
Heading::H5 => TextStyle::Name("H5".into()),
|
||||
Heading::H6 => TextStyle::Name("H6".into()),
|
||||
}
|
||||
} else if style.code {
|
||||
TextStyle::Monospace
|
||||
} else if style.small | style.raised {
|
||||
|
||||
Reference in New Issue
Block a user