Optimization

This commit is contained in:
daa 2018-05-06 20:26:29 +03:00
parent ad0ea04f93
commit dfde1f46bb
2 changed files with 7 additions and 10 deletions

View File

@ -125,13 +125,13 @@ impl CellMetrics {
} }
pub struct FontFeatures { pub struct FontFeatures {
features: Option<String>, attr: Option<pango::Attribute>,
} }
impl FontFeatures { impl FontFeatures {
pub fn new() -> Self { pub fn new() -> Self {
FontFeatures { FontFeatures {
features: None, attr: None,
} }
} }
@ -141,16 +141,13 @@ impl FontFeatures {
} }
FontFeatures { FontFeatures {
features: Some(font_features) attr: sys_pango::attribute::new_features(&font_features),
} }
} }
pub fn insert_attr(&self, attr_list: &pango::AttrList, end_idx: usize) { pub fn insert_attr(&self, attr_list: &pango::AttrList) {
if let Some(ref features) = self.features { if let Some(ref attr) = self.attr {
let mut attr = sys_pango::attribute::new_features(features).unwrap(); attr_list.insert(attr.clone());
attr.set_start_index(0);
attr.set_end_index(end_idx as u32);
attr_list.insert(attr);
} }
} }
} }

View File

@ -279,7 +279,7 @@ impl StyledLine {
} }
style_attr.insert(&attr_list); style_attr.insert(&attr_list);
font_features.insert_attr(&attr_list, line_str.len()); font_features.insert_attr(&attr_list);
StyledLine { StyledLine {
line_str, line_str,