Replies: 3 comments 3 replies
-
|
See |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
It's too complicated to explain everything. In |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
I was able to make it work using the let font_size = 22.0;
let mut text = "ABCD";
ui.scope(|ui| {
// In this UI scope we overwrite the font size
ui.style_mut().text_styles.insert(
egui::TextStyle::Monospace,
egui::FontId::new(font_size, egui::FontFamily::Monospace),
);
// Set up the layouter
let mut layouter =
|ui: &egui::Ui, buf: &dyn egui::TextBuffer, wrap_width: f32| {
let mut layout_job = egui_extras::syntax_highlighting::highlight(
ui.ctx(),
ui.style(),
&CodeTheme::dark(0.0), // This number doesn't seem to change anything (?)
buf.as_str(),
"xml",
);
layout_job.wrap.max_width = wrap_width;
ui.fonts_mut(|f| f.layout_job(layout_job))
};
// Add the textedit widget with the layouter
ui.add(egui::TextEdit::multiline(&mut text).layouter(&mut layouter));
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to be able to show a XML text file with some syntax highlighting through code_view_ui API from egui_extras but I also want to be able to resize the text font dynamically during run time. It is not super clear how this can be achieved.
Any guide will be helpful.
Beta Was this translation helpful? Give feedback.
All reactions