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:
parent
a8281e4984
commit
e3fc0a583b
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user