1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

win32: cut over to new font matcher

and remove the old one

refs: https://github.com/wez/wezterm/issues/655
This commit is contained in:
Wez Furlong 2021-04-07 22:36:34 -07:00
parent a8281e4984
commit e3fc0a583b
2 changed files with 2 additions and 24 deletions

View File

@ -1,6 +1,7 @@
#![cfg(windows)]
use crate::locator::{FontDataHandle, FontLocator};
use crate::parser::FontMatch;
use config::FontAttributes;
use dwrote::{FontDescriptor, FontStretch, FontStyle, FontWeight};
use std::borrow::Cow;
@ -201,7 +202,7 @@ impl FontLocator for GdiFontLocator {
) -> bool {
match crate::parser::ParsedFont::from_locator(&handle) {
Ok(parsed) => {
if crate::parser::font_info_matches(font_attr, parsed.names()) {
if parsed.matches_attributes(font_attr) != FontMatch::NoMatch {
fonts.push(handle);
loaded.insert(font_attr.clone());
true

View File

@ -221,29 +221,6 @@ pub enum FontMatch {
NoMatch,
}
pub fn font_info_matches(attr: &FontAttributes, names: &Names) -> bool {
if let Some(fam) = names.family.as_ref() {
// TODO: correctly match using family and sub-family;
// this is a pretty rough approximation
if attr.family == *fam {
match names.sub_family.as_ref().map(String::as_str) {
Some("Italic") if attr.italic && !attr.bold => return true,
Some("Bold") if attr.bold && !attr.italic => return true,
Some("Bold Italic") if attr.bold && attr.italic => return true,
Some("Medium") | Some("Regular") | None if !attr.italic && !attr.bold => {
return true
}
_ => {}
}
}
}
if attr.family == names.full_name && !attr.bold && !attr.italic {
true
} else {
false
}
}
/// Given a blob representing a True Type Collection (.ttc) file,
/// and a desired font, enumerate the collection to resolve the index of
/// the font inside that collection that matches it.