Move font matching to Attrs
This commit is contained in:
parent
324c8837fd
commit
085231c153
2 changed files with 17 additions and 15 deletions
|
|
@ -45,4 +45,12 @@ impl<'a> Attrs<'a> {
|
|||
self.weight = weight;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn matches(&self, face: &fontdb::FaceInfo) -> bool {
|
||||
face.style == self.style &&
|
||||
face.weight == self.weight &&
|
||||
face.stretch == self.stretch &&
|
||||
//TODO: smarter way of including emoji
|
||||
(face.monospaced == self.monospaced || face.post_script_name.contains("Emoji"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,25 +104,19 @@ impl<'a> FontSystem<'a> {
|
|||
}
|
||||
|
||||
pub fn matches_attrs(&'a 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"))
|
||||
};
|
||||
self.matches(|face| {
|
||||
let matched = attrs.matches(face);
|
||||
|
||||
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
|
||||
face.id,
|
||||
face.family,
|
||||
face.post_script_name,
|
||||
face.style,
|
||||
face.weight,
|
||||
face.stretch,
|
||||
face.monospaced
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue