Move font matching to Attrs

This commit is contained in:
Jeremy Soller 2022-10-25 15:51:28 -06:00
parent 324c8837fd
commit 085231c153
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
2 changed files with 17 additions and 15 deletions

View file

@ -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
);
}