Remove monospaced from attrs
This commit is contained in:
parent
521acb64e0
commit
3c7dc1f657
5 changed files with 17 additions and 29 deletions
|
|
@ -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 {
|
||||
self.attrs = self.attrs.family(if monospaced {
|
||||
cosmic_text::Family::Monospace
|
||||
} else {
|
||||
cosmic_text::Family::SansSerif
|
||||
})
|
||||
.monospaced(monospaced);
|
||||
});
|
||||
|
||||
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:"),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
15
src/attrs.rs
15
src/attrs.rs
|
|
@ -93,7 +93,6 @@ pub struct Attrs<'a> {
|
|||
//TODO: should this be an option?
|
||||
pub color_opt: Option<Color>,
|
||||
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<Color>,
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue