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

Add dual font support (#446)

This commit is contained in:
Leiser Fernández Gallo 2021-01-30 17:43:41 +01:00 committed by GitHub
parent b201e43b94
commit f6fc1c6524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -11,6 +11,7 @@ use std::ptr;
use std::sync::Mutex;
static FC_MONO: i32 = 100;
static FC_DUAL: i32 = 90;
lazy_static::lazy_static! {
/// This is hideous and gross, but we don't have a lot of choice.
@ -259,6 +260,10 @@ impl Pattern {
self.add_integer("spacing", FC_MONO)
}
pub fn dual(&mut self) -> Result<(), Error> {
self.add_integer("spacing", FC_DUAL)
}
pub fn format(&self, fmt: &str) -> Result<String, Error> {
let fmt = CString::new(fmt)?;
unsafe {

View File

@ -18,13 +18,22 @@ impl FontLocator for FontConfigFontLocator {
) -> anyhow::Result<Vec<FontDataHandle>> {
let mut fonts = vec![];
for attr in fonts_selection {
for (is_mono, attr) in fonts_selection
.iter()
.flat_map(|a| std::iter::once((true, a)).chain(std::iter::once((false, a))))
{
let mut pattern = FontPattern::new()?;
let start = std::time::Instant::now();
pattern.family(&attr.family)?;
pattern.add_integer("weight", if attr.bold { 200 } else { 80 })?;
pattern.add_integer("slant", if attr.italic { 100 } else { 0 })?;
pattern.monospace()?;
if is_mono {
pattern.monospace()?;
} else {
pattern.dual()?;
}
log::trace!("fc pattern before config subst: {:?}", pattern);
pattern.config_substitute(fcwrap::MatchKind::Pattern)?;
pattern.default_substitute();