refactor deps so that window can depend on wezterm-font
I want to use this to render the font in the title bar
This commit is contained in:
1 parent
d04486f30a
commit
e69869efa7
13 files changed
+71
-18
No files matched your search
Generated
+11
-1
@@ -694,6 +694,13 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color-types"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
@@ -4790,6 +4797,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"allsorts",
|
||||
"anyhow",
|
||||
"color-types",
|
||||
"config",
|
||||
"core-foundation 0.9.1",
|
||||
"core-text",
|
||||
@@ -4814,10 +4822,10 @@ dependencies = [
|
||||
"unicode-general-category 0.3.0",
|
||||
"unicode-segmentation",
|
||||
"walkdir",
|
||||
"wezterm-input-types",
|
||||
"wezterm-term",
|
||||
"wezterm-toast-notification",
|
||||
"winapi 0.3.9",
|
||||
"window",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5138,6 +5146,7 @@ dependencies = [
|
||||
"clipboard",
|
||||
"clipboard-win",
|
||||
"cocoa",
|
||||
"color-types",
|
||||
"config",
|
||||
"core-foundation 0.7.0",
|
||||
"core-graphics 0.19.2",
|
||||
@@ -5167,6 +5176,7 @@ dependencies = [
|
||||
"wayland-client",
|
||||
"wayland-egl",
|
||||
"wayland-protocols",
|
||||
"wezterm-font",
|
||||
"wezterm-input-types",
|
||||
"wgpu",
|
||||
"winapi 0.3.9",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "color-types"
|
||||
version = "0.1.0"
|
||||
authors = ["Wez Furlong"]
|
||||
edition = "2018"
|
||||
repository = "https://github.com/wez/wezterm"
|
||||
description = "Types for working with colors"
|
||||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
lazy_static = "1.4"
|
||||
File renamed without changes.
@@ -10,6 +10,7 @@ edition = "2018"
|
||||
allsorts = { git = "https://github.com/yeslogic/allsorts.git", rev="3947164a201ab5e15d5f23204faaaaaad52531aa" }
|
||||
anyhow = "1.0"
|
||||
config = { path = "../config" }
|
||||
color-types = { path = "../color-types" }
|
||||
enum-display-derive = "0.1"
|
||||
euclid = "0.22"
|
||||
freetype = { path = "../deps/freetype" }
|
||||
@@ -27,9 +28,9 @@ tinyvec = "1.1" # Note: constrained by the allsorts crate
|
||||
unicode-segmentation = "1.7"
|
||||
unicode-general-category = "0.3"
|
||||
walkdir = "2"
|
||||
wezterm-input-types = { path = "../wezterm-input-types" }
|
||||
wezterm-term = { path = "../term", features=["use_serde"] }
|
||||
wezterm-toast-notification = { path = "../wezterm-toast-notification" }
|
||||
window = { path = "../window" }
|
||||
|
||||
[target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
|
||||
fontconfig = { path = "../deps/fontconfig" }
|
||||
|
||||
@@ -16,7 +16,6 @@ use std::time::Duration;
|
||||
use thiserror::Error;
|
||||
use wezterm_term::CellAttributes;
|
||||
use wezterm_toast_notification::ToastNotification;
|
||||
use window::default_dpi;
|
||||
|
||||
mod hbwrap;
|
||||
|
||||
@@ -186,10 +185,9 @@ pub struct FontConfiguration {
|
||||
|
||||
impl FontConfigInner {
|
||||
/// Create a new empty configuration
|
||||
pub fn new(config: Option<ConfigHandle>) -> anyhow::Result<Self> {
|
||||
pub fn new(config: Option<ConfigHandle>, dpi: usize) -> anyhow::Result<Self> {
|
||||
let config = config.unwrap_or_else(|| configuration());
|
||||
let locator = new_locator(config.font_locator);
|
||||
let dpi = config.dpi.unwrap_or_else(|| default_dpi()) as usize;
|
||||
Ok(Self {
|
||||
fonts: RefCell::new(HashMap::new()),
|
||||
locator,
|
||||
@@ -552,8 +550,8 @@ impl FontConfigInner {
|
||||
|
||||
impl FontConfiguration {
|
||||
/// Create a new empty configuration
|
||||
pub fn new(config: Option<ConfigHandle>) -> anyhow::Result<Self> {
|
||||
let inner = Rc::new(FontConfigInner::new(config)?);
|
||||
pub fn new(config: Option<ConfigHandle>, dpi: usize) -> anyhow::Result<Self> {
|
||||
let inner = Rc::new(FontConfigInner::new(config, dpi)?);
|
||||
Ok(Self { inner })
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::units::*;
|
||||
use crate::{ftwrap, RasterizedGlyph};
|
||||
use ::freetype::{FT_GlyphSlotRec_, FT_Glyph_Format, FT_Matrix};
|
||||
use anyhow::bail;
|
||||
use color_types::linear_u8_to_srgb8;
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
use std::slice;
|
||||
use window::color::linear_u8_to_srgb8;
|
||||
|
||||
pub struct FreeTypeRasterizer {
|
||||
has_color: bool,
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub type PixelUnit = window::PixelUnit;
|
||||
pub type PixelUnit = wezterm_input_types::PixelUnit;
|
||||
pub type PixelLength = euclid::Length<f64, PixelUnit>;
|
||||
pub type IntPixelLength = isize;
|
||||
@@ -419,7 +419,10 @@ pub fn run_ls_fonts(config: config::ConfigHandle, cmd: &LsFontsCommand) -> anyho
|
||||
// a fully baked GUI environment running
|
||||
config::assign_error_callback(|err| eprintln!("{}", err));
|
||||
|
||||
let font_config = wezterm_font::FontConfiguration::new(Some(config.clone()))?;
|
||||
let font_config = wezterm_font::FontConfiguration::new(
|
||||
Some(config.clone()),
|
||||
config.dpi.unwrap_or_else(|| ::window::default_dpi()) as usize,
|
||||
)?;
|
||||
|
||||
if let Some(text) = &cmd.text {
|
||||
let line = Line::from_text(text, &CellAttributes::default());
|
||||
|
||||
@@ -331,9 +331,15 @@ mod test {
|
||||
};
|
||||
config.font_rules.clear();
|
||||
config.compute_extra_defaults(None);
|
||||
config::use_this_configuration(config);
|
||||
config::use_this_configuration(config.clone());
|
||||
|
||||
let fonts = Rc::new(FontConfiguration::new(None).unwrap());
|
||||
let fonts = Rc::new(
|
||||
FontConfiguration::new(
|
||||
None,
|
||||
config.dpi.unwrap_or_else(|| ::window::default_dpi()) as usize,
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
let render_metrics = RenderMetrics::new(&fonts).unwrap();
|
||||
let mut glyph_cache = GlyphCache::new_in_memory(&fonts, 128, &render_metrics).unwrap();
|
||||
|
||||
@@ -376,7 +382,16 @@ mod test {
|
||||
let bench_result = benchmarking::measure_function(move |measurer| {
|
||||
let text: String = (0..n).map(|_| ' ').collect();
|
||||
|
||||
let fonts = Rc::new(FontConfiguration::new(None).unwrap());
|
||||
let fonts = Rc::new(
|
||||
FontConfiguration::new(
|
||||
None,
|
||||
config::configuration()
|
||||
.dpi
|
||||
.unwrap_or_else(|| ::window::default_dpi())
|
||||
as usize,
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
let style = TextStyle::default();
|
||||
let font = fonts.resolve_font(&style).unwrap();
|
||||
let line = Line::from_text(&text, &CellAttributes::default());
|
||||
@@ -400,11 +415,18 @@ mod test {
|
||||
.is_test(true)
|
||||
.filter_level(log::LevelFilter::Trace)
|
||||
.try_init();
|
||||
if !config::configuration().experimental_shape_post_processing {
|
||||
let config = config::configuration();
|
||||
if !config.experimental_shape_post_processing {
|
||||
return;
|
||||
}
|
||||
|
||||
let fonts = Rc::new(FontConfiguration::new(None).unwrap());
|
||||
let fonts = Rc::new(
|
||||
FontConfiguration::new(
|
||||
None,
|
||||
config.dpi.unwrap_or_else(|| ::window::default_dpi()) as usize,
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
let render_metrics = RenderMetrics::new(&fonts).unwrap();
|
||||
let mut glyph_cache = GlyphCache::new_in_memory(&fonts, 128, &render_metrics).unwrap();
|
||||
|
||||
|
||||
@@ -392,7 +392,10 @@ impl TermWindow {
|
||||
|
||||
let window_background = load_background_image(&config);
|
||||
|
||||
let fontconfig = Rc::new(FontConfiguration::new(Some(config.clone()))?);
|
||||
let fontconfig = Rc::new(FontConfiguration::new(
|
||||
Some(config.clone()),
|
||||
config.dpi.unwrap_or_else(|| ::window::default_dpi()) as usize,
|
||||
)?);
|
||||
let mux = Mux::get().expect("to be main thread with mux running");
|
||||
let size = match mux.get_active_tab_for_window(mux_window_id) {
|
||||
Some(tab) => tab.get_size(),
|
||||
|
||||
@@ -235,7 +235,10 @@ impl super::TermWindow {
|
||||
pub fn reset_font_and_window_size(&mut self) -> anyhow::Result<()> {
|
||||
let config = &self.config;
|
||||
let size = config.initial_size();
|
||||
let fontconfig = Rc::new(FontConfiguration::new(Some(config.clone()))?);
|
||||
let fontconfig = Rc::new(FontConfiguration::new(
|
||||
Some(config.clone()),
|
||||
config.dpi.unwrap_or_else(|| ::window::default_dpi()) as usize,
|
||||
)?);
|
||||
let render_metrics = RenderMetrics::new(&fontconfig)?;
|
||||
|
||||
let terminal_size = PtySize {
|
||||
|
||||
@@ -24,6 +24,7 @@ async-task = "4.0"
|
||||
async-trait = "0.1"
|
||||
anyhow = "1.0"
|
||||
config = { path = "../config" }
|
||||
color-types = { path = "../color-types" }
|
||||
thiserror = "1.0"
|
||||
bitflags = "1.0"
|
||||
euclid = "0.22"
|
||||
@@ -39,6 +40,7 @@ resize = "0.5"
|
||||
serde = {version="1.0", features = ["rc", "derive"]}
|
||||
tiny-skia = "0.5"
|
||||
glium = { version = "0.28", default-features = false}
|
||||
wezterm-font = { path = "../wezterm-font" }
|
||||
wezterm-input-types = { path = "../wezterm-input-types" }
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ use std::any::Any;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
pub mod bitmaps;
|
||||
pub mod color;
|
||||
pub use color_types as color;
|
||||
mod configuration;
|
||||
pub mod connection;
|
||||
pub mod os;
|
||||
|
||||
Reference in new issue
Block a user