diff --git a/Cargo.toml b/Cargo.toml index 12baf78..cf3b975 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" license = "MIT OR Apache-2.0" [dependencies] -fontdb = "0.9" +fontdb = { version = "0.9", git = "https://github.com/jackpot51/fontdb" } log = "0.4" rustybuzz = "0.5" swash = { version = "0.1", optional = true } diff --git a/src/buffer.rs b/src/buffer.rs index 7b9bf46..3b838b1 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -550,7 +550,7 @@ impl<'a> TextBuffer<'a> { /// Perform a [TextAction] on the buffer pub fn action(&mut self, action: TextAction) { - let mut old_cursor = self.cursor; + let old_cursor = self.cursor; match action { TextAction::Previous => { diff --git a/src/font/matches.rs b/src/font/matches.rs index 5332c0b..e65fb59 100644 --- a/src/font/matches.rs +++ b/src/font/matches.rs @@ -3,12 +3,13 @@ use std::sync::Arc; use unicode_script::{Script, UnicodeScript}; -use super::{Font, FontShapeGlyph, FontShapeLine, FontShapeSpan, FontShapeWord}; -use super::fallback::{FontFallbackIter}; +use crate::{Font, FontShapeGlyph, FontShapeLine, FontShapeSpan, FontShapeWord}; +use crate::fallback::{FontFallbackIter}; /// Fonts that match a pattern pub struct FontMatches<'a> { pub locale: &'a str, + pub default_family: String, pub fonts: Vec>>, } @@ -127,10 +128,10 @@ impl<'a> FontMatches<'a> { &line[start_word..end_word], ); - //TODO: configure default family + let default_families = [self.default_family.as_str()]; let mut font_iter = FontFallbackIter::new( &self.fonts, - &["Fira Sans", "Fira Mono"], + &default_families, scripts, self.locale ); diff --git a/src/font/system.rs b/src/font/system.rs index e68b23e..b8fe0ec 100644 --- a/src/font/system.rs +++ b/src/font/system.rs @@ -5,7 +5,7 @@ use std::{ sync::{Arc, Mutex}, }; -use crate::{Attrs, Font, FontMatches}; +use crate::{Attrs, Family, Font, FontMatches}; /// Access system fonts pub struct FontSystem<'a> { @@ -79,6 +79,7 @@ impl<'a> FontSystem<'a> { pub fn matches bool>( &'a self, + default_family: &Family, f: F, ) -> FontMatches<'_> { let mut fonts = Vec::new(); @@ -95,12 +96,13 @@ impl<'a> FontSystem<'a> { FontMatches { locale: &self.locale, + default_family: self.db.family_name(default_family).to_string(), fonts } } pub fn matches_attrs(&'a self, attrs: &Attrs) -> FontMatches<'_> { - self.matches(|face| { + self.matches(&attrs.family, |face| { let matched = attrs.matches(face); if matched {