Remove monospaced from attrs

This commit is contained in:
Jeremy Soller 2023-03-30 08:04:52 -06:00
parent 521acb64e0
commit 3c7dc1f657
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
5 changed files with 17 additions and 29 deletions

View file

@ -131,9 +131,7 @@ impl Application for Window {
type Theme = Theme;
fn new(_flags: ()) -> (Self, Command<Self::Message>) {
let attrs = cosmic_text::Attrs::new()
.monospaced(true)
.family(cosmic_text::Family::Monospace);
let attrs = cosmic_text::Attrs::new().family(cosmic_text::Family::Monospace);
let mut editor = SyntaxEditor::new(
Buffer::new(
@ -225,14 +223,11 @@ impl Application for Window {
update_attrs(&mut *editor, self.attrs);
}
Message::Monospaced(monospaced) => {
self.attrs = self
.attrs
.family(if monospaced {
cosmic_text::Family::Monospace
} else {
cosmic_text::Family::SansSerif
})
.monospaced(monospaced);
self.attrs = self.attrs.family(if monospaced {
cosmic_text::Family::Monospace
} else {
cosmic_text::Family::SansSerif
});
let mut editor = self.editor.lock().unwrap();
update_attrs(&mut *editor, self.attrs);
@ -331,7 +326,11 @@ impl Application for Window {
Message::Italic
),
text("Monospaced:"),
toggler(None, self.attrs.monospaced, Message::Monospaced),
toggler(
None,
self.attrs.family == cosmic_text::Family::Monospace,
Message::Monospaced
),
text("Theme:"),
theme_picker,
text("Font Size:"),

View file

@ -227,7 +227,9 @@ where
// Scale metrics
let metrics = editor.buffer().metrics();
editor.buffer_mut().set_metrics(metrics.scale(style.scale_factor as f32));
editor
.buffer_mut()
.set_metrics(metrics.scale(style.scale_factor as f32));
// Set size
editor.buffer_mut().set_size(image_w as f32, image_h as f32);

View file

@ -73,7 +73,7 @@ fn main() {
.buffer_mut()
.set_size(window.width() as f32 - line_x * 2.0, window.height() as f32);
let attrs = Attrs::new().monospaced(true).family(Family::Monospace);
let attrs = Attrs::new().family(Family::Monospace);
match editor.load_text(&path, attrs) {
Ok(()) => (),
Err(err) => {

View file

@ -49,7 +49,7 @@ fn main() {
let attrs = Attrs::new();
let serif_attrs = attrs.family(Family::Serif);
let mono_attrs = attrs.monospaced(true).family(Family::Monospace);
let mono_attrs = attrs.family(Family::Monospace);
let comic_attrs = attrs.family(Family::Name("Comic Neue"));
editor.buffer_mut().lines.clear();