1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00

macos: fonts: use full list of user fallback languages

The hope was that this would find more fonts, but it doesn't actually
help for this case.

refs: https://github.com/wez/wezterm/issues/4099
This commit is contained in:
Wez Furlong 2023-08-05 17:33:59 -07:00
parent a7c6ea8c1e
commit 33187d0e79
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
4 changed files with 57 additions and 14 deletions

53
Cargo.lock generated
View File

@ -721,6 +721,37 @@ dependencies = [
"objc", "objc",
] ]
[[package]]
name = "cocoa"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
dependencies = [
"bitflags 1.3.2",
"block",
"cocoa-foundation",
"core-foundation 0.9.3",
"core-graphics 0.23.1",
"foreign-types 0.5.0",
"libc",
"objc",
]
[[package]]
name = "cocoa-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "931d3837c286f56e3c58423ce4eba12d08db2374461a785c86f672b08b5650d6"
dependencies = [
"bitflags 1.3.2",
"block",
"core-foundation 0.9.3",
"core-graphics-types",
"foreign-types 0.3.2",
"libc",
"objc",
]
[[package]] [[package]]
name = "codec" name = "codec"
version = "0.1.0" version = "0.1.0"
@ -905,14 +936,14 @@ dependencies = [
[[package]] [[package]]
name = "core-graphics" name = "core-graphics"
version = "0.22.3" version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation 0.9.3", "core-foundation 0.9.3",
"core-graphics-types", "core-graphics-types",
"foreign-types 0.3.2", "foreign-types 0.5.0",
"libc", "libc",
] ]
@ -929,13 +960,13 @@ dependencies = [
[[package]] [[package]]
name = "core-text" name = "core-text"
version = "19.2.0" version = "20.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" checksum = "02083d15989d6247553e1a63753561555a72b2038bba1e4239db70602a798742"
dependencies = [ dependencies = [
"core-foundation 0.9.3", "core-foundation 0.9.3",
"core-graphics 0.22.3", "core-graphics 0.23.1",
"foreign-types 0.3.2", "foreign-types 0.5.0",
"libc", "libc",
] ]
@ -1426,7 +1457,7 @@ dependencies = [
"backtrace", "backtrace",
"battery", "battery",
"chrono", "chrono",
"cocoa", "cocoa 0.20.2",
"color-funcs", "color-funcs",
"config", "config",
"dirs-next", "dirs-next",
@ -6008,6 +6039,7 @@ name = "wezterm-font"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cocoa 0.25.0",
"config", "config",
"core-foundation 0.9.3", "core-foundation 0.9.3",
"core-text", "core-text",
@ -6026,6 +6058,7 @@ dependencies = [
"log", "log",
"memmap2 0.2.3", "memmap2 0.2.3",
"metrics", "metrics",
"objc",
"ordered-float", "ordered-float",
"rangeset", "rangeset",
"termwiz", "termwiz",
@ -6275,7 +6308,7 @@ name = "wezterm-toast-notification"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-io", "async-io",
"cocoa", "cocoa 0.20.2",
"core-foundation 0.7.0", "core-foundation 0.7.0",
"futures-util", "futures-util",
"log", "log",
@ -6465,7 +6498,7 @@ dependencies = [
"bytes", "bytes",
"cgl", "cgl",
"clipboard-win", "clipboard-win",
"cocoa", "cocoa 0.25.0",
"config", "config",
"core-foundation 0.7.0", "core-foundation 0.7.0",
"core-graphics 0.19.2", "core-graphics 0.19.2",

View File

@ -45,8 +45,10 @@ dwrote = "0.11"
winapi = "0.3" winapi = "0.3"
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.25"
core-foundation = "0.9" core-foundation = "0.9"
core-text = "19.0" core-text = "20.0"
objc = "0.2"
[dev-dependencies] [dev-dependencies]
k9 = "0.11.0" k9 = "0.11.0"

View File

@ -2,6 +2,7 @@
use crate::locator::{FontDataSource, FontLocator, FontOrigin}; use crate::locator::{FontDataSource, FontLocator, FontOrigin};
use crate::parser::ParsedFont; use crate::parser::ParsedFont;
use cocoa::base::id;
use config::{FontAttributes, FontStretch, FontStyle, FontWeight}; use config::{FontAttributes, FontStretch, FontStyle, FontWeight};
use core_foundation::array::CFArray; use core_foundation::array::CFArray;
use core_foundation::base::TCFType; use core_foundation::base::TCFType;
@ -9,6 +10,7 @@ use core_foundation::dictionary::CFDictionary;
use core_foundation::string::CFString; use core_foundation::string::CFString;
use core_text::font::*; use core_text::font::*;
use core_text::font_descriptor::*; use core_text::font_descriptor::*;
use objc::*;
use rangeset::RangeSet; use rangeset::RangeSet;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::HashSet; use std::collections::HashSet;
@ -168,10 +170,16 @@ fn build_fallback_list() -> Vec<ParsedFont> {
fn build_fallback_list_impl() -> anyhow::Result<Vec<ParsedFont>> { fn build_fallback_list_impl() -> anyhow::Result<Vec<ParsedFont>> {
let menlo = let menlo =
new_from_name("Menlo", 0.0).map_err(|_| anyhow::anyhow!("failed to get Menlo font"))?; new_from_name("Menlo", 0.0).map_err(|_| anyhow::anyhow!("failed to get Menlo font"))?;
let lang = "en"
let user_defaults: id = unsafe { msg_send![class!(NSUserDefaults), standardUserDefaults] };
let apple_lang = "AppleLanguages"
.parse::<CFString>() .parse::<CFString>()
.map_err(|_| anyhow::anyhow!("failed to parse lang name en as CFString"))?; .map_err(|_| anyhow::anyhow!("failed to parse lang name en as CFString"))?;
let langs = CFArray::from_CFTypes(&[lang]);
let langs: CFArray<CFString> =
unsafe { msg_send![user_defaults, stringArrayForKey:apple_lang] };
let cascade = cascade_list_for_languages(&menlo, &langs); let cascade = cascade_list_for_languages(&menlo, &langs);
let mut fonts = vec![]; let mut fonts = vec![];
// Explicitly include Menlo itself, as it appears to be the only // Explicitly include Menlo itself, as it appears to be the only

View File

@ -85,7 +85,7 @@ futures-util = "0.3"
futures-lite = "1.12" futures-lite = "1.12"
[target.'cfg(target_os="macos")'.dependencies] [target.'cfg(target_os="macos")'.dependencies]
cocoa = "0.20" cocoa = "0.25"
objc = "0.2" objc = "0.2"
core-foundation = "0.7" core-foundation = "0.7"
core-graphics = "0.19" core-graphics = "0.19"