mirror of
https://github.com/wez/wezterm.git
synced 2024-11-26 08:25:50 +03:00
fonts: treat "charcell" spacing as monospace
Some versions of fontconfig classify some fonts as having charcell spacing. We need to consider those as monospace as well. refs: https://github.com/wez/wezterm/issues/1820
This commit is contained in:
parent
a0ce1f9526
commit
1b0f5cf256
@ -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)
|
* 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)
|
* 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)
|
* 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
|
### 20220319-142410-0fcdea07
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use std::ffi::{CStr, CString};
|
|||||||
use std::os::raw::{c_char, c_int};
|
use std::os::raw::{c_char, c_int};
|
||||||
use std::{fmt, mem, ptr};
|
use std::{fmt, mem, ptr};
|
||||||
|
|
||||||
|
pub const FC_CHARCELL: i32 = 110;
|
||||||
pub const FC_MONO: i32 = 100;
|
pub const FC_MONO: i32 = 100;
|
||||||
pub const FC_DUAL: i32 = 90;
|
pub const FC_DUAL: i32 = 90;
|
||||||
|
|
||||||
|
@ -3,13 +3,13 @@ use crate::locator::{FontDataHandle, FontDataSource, FontLocator, FontOrigin};
|
|||||||
use crate::parser::ParsedFont;
|
use crate::parser::ParsedFont;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use config::{FontAttributes, FontStyle, FontWeight};
|
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::collections::HashSet;
|
||||||
use std::convert::TryInto;
|
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.
|
/// 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
|
/// A FontLocator implemented using the system font loading
|
||||||
/// functions provided by font-config
|
/// functions provided by font-config
|
||||||
@ -29,7 +29,7 @@ impl FontLocator for FontConfigFontLocator {
|
|||||||
matches
|
matches
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|p| match p.get_integer("spacing") {
|
.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.
|
// (probably!) no spacing defined. Assume monospace.
|
||||||
Err(_) => Some(p),
|
Err(_) => Some(p),
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -44,7 +44,8 @@ impl FontLocator for FontConfigFontLocator {
|
|||||||
pattern.family(&attr.family)?;
|
pattern.family(&attr.family)?;
|
||||||
let matches = monospaced(pattern.list()?);
|
let matches = monospaced(pattern.list()?);
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"listing by family took {:?} to compute and is {:?}",
|
"listing {:?} by family took {:?} to compute and is {:?}",
|
||||||
|
attr.family,
|
||||||
start.elapsed(),
|
start.elapsed(),
|
||||||
matches
|
matches
|
||||||
);
|
);
|
||||||
@ -58,7 +59,8 @@ impl FontLocator for FontConfigFontLocator {
|
|||||||
pattern.add_string("postscriptname", &attr.family)?;
|
pattern.add_string("postscriptname", &attr.family)?;
|
||||||
let matches = monospaced(pattern.list()?);
|
let matches = monospaced(pattern.list()?);
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"listing by postscriptname took {:?} to compute and is {:?}",
|
"listing {:?} by postscriptname took {:?} to compute and is {:?}",
|
||||||
|
attr.family,
|
||||||
start.elapsed(),
|
start.elapsed(),
|
||||||
matches
|
matches
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user