Make it possible to set and use default family
This commit is contained in:
parent
d04337075a
commit
ea18576032
4 changed files with 11 additions and 8 deletions
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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<Arc<Font<'a>>>,
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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<F: Fn(&fontdb::FaceInfo) -> 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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue