diff --git a/examples/editor-libcosmic/src/main.rs b/examples/editor-libcosmic/src/main.rs index 4a8e862..e637fef 100644 --- a/examples/editor-libcosmic/src/main.rs +++ b/examples/editor-libcosmic/src/main.rs @@ -131,9 +131,7 @@ impl Application for Window { type Theme = Theme; fn new(_flags: ()) -> (Self, Command) { - 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:"), diff --git a/examples/editor-libcosmic/src/text_box.rs b/examples/editor-libcosmic/src/text_box.rs index 91c8d69..58ceb2e 100644 --- a/examples/editor-libcosmic/src/text_box.rs +++ b/examples/editor-libcosmic/src/text_box.rs @@ -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); diff --git a/examples/editor-orbclient/src/main.rs b/examples/editor-orbclient/src/main.rs index f784cee..ca82313 100644 --- a/examples/editor-orbclient/src/main.rs +++ b/examples/editor-orbclient/src/main.rs @@ -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) => { diff --git a/examples/rich-text/src/main.rs b/examples/rich-text/src/main.rs index 89bc450..f569884 100644 --- a/examples/rich-text/src/main.rs +++ b/examples/rich-text/src/main.rs @@ -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(); diff --git a/src/attrs.rs b/src/attrs.rs index aae1404..3d69db0 100644 --- a/src/attrs.rs +++ b/src/attrs.rs @@ -93,7 +93,6 @@ pub struct Attrs<'a> { //TODO: should this be an option? pub color_opt: Option, pub family: Family<'a>, - pub monospaced: bool, pub stretch: Stretch, pub style: Style, pub weight: Weight, @@ -108,7 +107,6 @@ impl<'a> Attrs<'a> { Self { color_opt: None, family: Family::SansSerif, - monospaced: false, stretch: Stretch::Normal, style: Style::Normal, weight: Weight::NORMAL, @@ -128,12 +126,6 @@ impl<'a> Attrs<'a> { self } - /// Set monospaced - pub fn monospaced(mut self, monospaced: bool) -> Self { - self.monospaced = monospaced; - self - } - /// Set [Stretch] pub fn stretch(mut self, stretch: Stretch) -> Self { self.stretch = stretch; @@ -164,14 +156,12 @@ impl<'a> Attrs<'a> { face.post_script_name.contains("Emoji") || (face.style == self.style && face.weight == self.weight - && face.stretch == self.stretch - && face.monospaced == self.monospaced) + && face.stretch == self.stretch) } /// Check if this set of attributes can be shaped with another pub fn compatible(&self, other: &Self) -> bool { self.family == other.family - && self.monospaced == other.monospaced && self.stretch == other.stretch && self.style == other.style && self.weight == other.weight @@ -184,7 +174,6 @@ pub struct AttrsOwned { //TODO: should this be an option? pub color_opt: Option, pub family_owned: FamilyOwned, - pub monospaced: bool, pub stretch: Stretch, pub style: Style, pub weight: Weight, @@ -196,7 +185,6 @@ impl AttrsOwned { Self { color_opt: attrs.color_opt, family_owned: FamilyOwned::new(attrs.family), - monospaced: attrs.monospaced, stretch: attrs.stretch, style: attrs.style, weight: attrs.weight, @@ -208,7 +196,6 @@ impl AttrsOwned { Attrs { color_opt: self.color_opt, family: self.family_owned.as_family(), - monospaced: self.monospaced, stretch: self.stretch, style: self.style, weight: self.weight,