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:
parent
b201e43b94
commit
f6fc1c6524
@ -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 {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user