diff --git a/docs/changelog.md b/docs/changelog.md index 2e19ede50..e37aac979 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -48,6 +48,7 @@ As features stabilize some brief notes about them will accumulate here. * Workaround for fonts with broken horizontal advance metrics [#1787](https://github.com/wez/wezterm/issues/1787) * Improved mouse based selection. Thanks to [@davidrios](https://github.com/davidrios)! [#1805](https://github.com/wez/wezterm/issues/1805) [#1199](https://github.com/wez/wezterm/issues/1199) [#1386](https://github.com/wez/wezterm/issues/1386) [#354](https://github.com/wez/wezterm/issues/354) * X11 `KP_End` wasn't recognized [#1804](https://github.com/wez/wezterm/issues/1804) +* fontconfig matches now also treat `"charcell"` spacing as monospace. [#1820](https://github.com/wez/wezterm/issues/1820) ### 20220319-142410-0fcdea07 diff --git a/wezterm-font/src/fcwrap.rs b/wezterm-font/src/fcwrap.rs index 856b93862..f73e7dce2 100644 --- a/wezterm-font/src/fcwrap.rs +++ b/wezterm-font/src/fcwrap.rs @@ -8,6 +8,7 @@ use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int}; use std::{fmt, mem, ptr}; +pub const FC_CHARCELL: i32 = 110; pub const FC_MONO: i32 = 100; pub const FC_DUAL: i32 = 90; diff --git a/wezterm-font/src/locator/font_config.rs b/wezterm-font/src/locator/font_config.rs index 2390d7ad3..c80ce6bfb 100644 --- a/wezterm-font/src/locator/font_config.rs +++ b/wezterm-font/src/locator/font_config.rs @@ -3,13 +3,13 @@ use crate::locator::{FontDataHandle, FontDataSource, FontLocator, FontOrigin}; use crate::parser::ParsedFont; use anyhow::Context; use config::{FontAttributes, FontStyle, FontWeight}; -use fcwrap::{CharSet, FontSet, Pattern as FontPattern, FC_DUAL, FC_MONO}; +use fcwrap::{CharSet, FontSet, Pattern as FontPattern, FC_CHARCELL, FC_DUAL, FC_MONO}; use std::collections::HashSet; use std::convert::TryInto; -/// Allow for both monospace and dual spacing; both of these are +/// Allow for monospace, dual and charcell spacing; these are /// fixed width styles so are desirable for a terminal use case. -const SPACING: [i32; 2] = [FC_MONO, FC_DUAL]; +const SPACING: [i32; 3] = [FC_MONO, FC_DUAL, FC_CHARCELL]; /// A FontLocator implemented using the system font loading /// functions provided by font-config @@ -29,7 +29,7 @@ impl FontLocator for FontConfigFontLocator { matches .iter() .filter_map(|p| match p.get_integer("spacing") { - Ok(n) if n == FC_MONO || n == FC_DUAL => Some(p), + Ok(n) if n == FC_MONO || n == FC_DUAL || n == FC_CHARCELL => Some(p), // (probably!) no spacing defined. Assume monospace. Err(_) => Some(p), _ => None, @@ -44,7 +44,8 @@ impl FontLocator for FontConfigFontLocator { pattern.family(&attr.family)?; let matches = monospaced(pattern.list()?); log::trace!( - "listing by family took {:?} to compute and is {:?}", + "listing {:?} by family took {:?} to compute and is {:?}", + attr.family, start.elapsed(), matches ); @@ -58,7 +59,8 @@ impl FontLocator for FontConfigFontLocator { pattern.add_string("postscriptname", &attr.family)?; let matches = monospaced(pattern.list()?); log::trace!( - "listing by postscriptname took {:?} to compute and is {:?}", + "listing {:?} by postscriptname took {:?} to compute and is {:?}", + attr.family, start.elapsed(), matches );