Skip to content

Commit

Permalink
make load_font_source return the font ids
Browse files Browse the repository at this point in the history
  • Loading branch information
msparkles committed Jul 3, 2024
1 parent c8ae194 commit b208879
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/yakui-widgets/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use std::cell::RefCell;
use std::rc::Rc;
use std::sync::Arc;

use cosmic_text::fontdb;

#[derive(Clone)]
pub struct Fonts {
inner: Rc<RefCell<FontsInner>>,
Expand All @@ -19,7 +17,7 @@ impl Fonts {
let mut font_system = cosmic_text::FontSystem::new_with_locale_and_db(
sys_locale::get_locale().unwrap_or(String::from("en-US")),
{
let mut database = fontdb::Database::default();
let mut database = cosmic_text::fontdb::Database::default();
database.set_serif_family("");
database.set_sans_serif_family("");
database.set_cursive_family("");
Expand All @@ -35,7 +33,9 @@ impl Fonts {

font_system
.db_mut()
.load_font_source(fontdb::Source::Binary(Arc::from(&DEFAULT_BYTES)));
.load_font_source(cosmic_text::fontdb::Source::Binary(Arc::from(
&DEFAULT_BYTES,
)));
}

let inner = Rc::new(RefCell::new(FontsInner { font_system }));
Expand All @@ -48,8 +48,12 @@ impl Fonts {
f(&mut inner.font_system)
}

pub fn load_font_source(&self, source: fontdb::Source) {
self.with_system(|font_system| font_system.db_mut().load_font_source(source));
pub fn load_font_source(
&self,
source: cosmic_text::fontdb::Source,
) -> Vec<cosmic_text::fontdb::ID> {
self.with_system(|font_system| font_system.db_mut().load_font_source(source))
.to_vec()
}

/// Sets the family that will be used by `Family::Serif`.
Expand Down

0 comments on commit b208879

Please sign in to comment.