Add text attributes
This commit is contained in:
parent
bc04887b35
commit
84f4381cdf
6 changed files with 83 additions and 88 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::ops::Deref;
|
||||
|
||||
use super::{Font, FontMatches};
|
||||
use crate::{Attrs, Font, FontMatches};
|
||||
|
||||
/// Access system fonts
|
||||
pub struct FontSystem {
|
||||
|
|
@ -81,6 +81,33 @@ impl FontSystem {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn matches_attrs(&self, attrs: Attrs) -> Option<FontMatches<'_>> {
|
||||
self.matches(|info| {
|
||||
let matched = {
|
||||
info.style == attrs.style &&
|
||||
info.weight == attrs.weight &&
|
||||
info.stretch == attrs.stretch &&
|
||||
//TODO: smarter way of including emoji
|
||||
(info.monospaced == attrs.monospaced || info.post_script_name.contains("Emoji"))
|
||||
};
|
||||
|
||||
if matched {
|
||||
log::debug!(
|
||||
"{:?}: family '{}' postscript name '{}' style {:?} weight {:?} stretch {:?} monospaced {:?}",
|
||||
info.id,
|
||||
info.family,
|
||||
info.post_script_name,
|
||||
info.style,
|
||||
info.weight,
|
||||
info.stretch,
|
||||
info.monospaced
|
||||
);
|
||||
}
|
||||
|
||||
matched
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for FontSystem {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue