diff --git a/Cargo.lock b/Cargo.lock index fb518a303..f13b08f08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2265,12 +2265,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mint" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" - [[package]] name = "mio" version = "0.8.11" @@ -2361,7 +2355,6 @@ dependencies = [ "lazy_static", "log", "lru", - "mint", "neovide-derive", "notify-debouncer-full", "num", diff --git a/Cargo.toml b/Cargo.toml index 60c7d2dc7..153dc9251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,6 @@ lazy_static = "1.4.0" log = "0.4.16" lru = "0.12.2" neovide-derive = { path = "neovide-derive", version = "0.1.0" } -mint = "0.5.9" num = "0.4.1" nvim-rs = { version = "0.7.0", features = ["use_tokio"] } palette = "0.7.6" diff --git a/src/editor/cursor.rs b/src/editor/cursor.rs index 0b2543826..4844c6584 100644 --- a/src/editor/cursor.rs +++ b/src/editor/cursor.rs @@ -49,6 +49,8 @@ pub struct Cursor { pub grid_cell: GridCell, } +// TODO: Remove +#[allow(unused)] impl Cursor { pub fn new() -> Cursor { Cursor { diff --git a/src/editor/style.rs b/src/editor/style.rs index 9a030099c..4f04537d2 100644 --- a/src/editor/style.rs +++ b/src/editor/style.rs @@ -58,6 +58,8 @@ impl Style { } } + //TODO: Remove + #[allow(unused)] pub fn special(&self, default_colors: &Colors) -> Srgba { self.colors .special diff --git a/src/error_handling.rs b/src/error_handling.rs index 792336365..1f448c167 100644 --- a/src/error_handling.rs +++ b/src/error_handling.rs @@ -71,7 +71,7 @@ fn handle_terminal_startup_errors(err: Error) -> i32 { 1 } -fn handle_gui_startup_errors(err: Error, event_loop: EventLoop) -> i32 { +fn handle_gui_startup_errors(_err: Error, _event_loop: EventLoop) -> i32 { // show_error_window(&format_and_log_error_message(err), event_loop); 1 } diff --git a/src/renderer/cursor_renderer/blink.rs b/src/renderer/cursor_renderer/blink.rs index bc9a22658..616b4db33 100644 --- a/src/renderer/cursor_renderer/blink.rs +++ b/src/renderer/cursor_renderer/blink.rs @@ -26,6 +26,8 @@ fn is_static(cursor: &Cursor) -> bool { || cursor.blinkon.is_none() } +// TODO: Remove +#[allow(unused)] impl BlinkStatus { pub fn new() -> BlinkStatus { BlinkStatus { diff --git a/src/renderer/cursor_renderer/cursor_vfx.rs b/src/renderer/cursor_renderer/cursor_vfx.rs index 938c659dc..6207d61a2 100644 --- a/src/renderer/cursor_renderer/cursor_vfx.rs +++ b/src/renderer/cursor_renderer/cursor_vfx.rs @@ -4,9 +4,9 @@ use nvim_rs::Value; use crate::{ editor::Cursor, renderer::cursor_renderer::CursorSettings, - renderer::{animation_utils::*, grid_renderer::GridRenderer}, + renderer::grid_renderer::GridRenderer, settings::*, - units::{GridSize, PixelPos, PixelSize, PixelVec}, + units::{PixelPos, PixelSize, PixelVec}, }; pub trait CursorVfx { @@ -90,7 +90,7 @@ pub fn new_cursor_vfx(mode: &VfxMode) -> Option> { pub struct PointHighlight { t: f32, center_position: PixelPos, - mode: HighlightMode, + _mode: HighlightMode, } impl PointHighlight { @@ -98,7 +98,7 @@ impl PointHighlight { PointHighlight { t: 0.0, center_position: PixelPos::new(0.0, 0.0), - mode: mode.clone(), + _mode: mode.clone(), } } } diff --git a/src/renderer/cursor_renderer/mod.rs b/src/renderer/cursor_renderer/mod.rs index 95d47049a..79ade3ece 100644 --- a/src/renderer/cursor_renderer/mod.rs +++ b/src/renderer/cursor_renderer/mod.rs @@ -11,7 +11,7 @@ use crate::{ profiling::{tracy_plot, tracy_zone}, renderer::{animation_utils::*, GridRenderer, RenderedWindow}, settings::{ParseFromValue, SETTINGS}, - units::{GridPos, GridScale, PixelPos, PixelSize, PixelVec}, + units::{GridPos, GridScale, PixelPos, PixelSize}, window::{ShouldRender, UserEvent}, }; diff --git a/src/renderer/fonts/caching_shaper.rs b/src/renderer/fonts/caching_shaper.rs index 8024f4bf6..c2407964c 100644 --- a/src/renderer/fonts/caching_shaper.rs +++ b/src/renderer/fonts/caching_shaper.rs @@ -1,7 +1,4 @@ -use std::{num::NonZeroUsize, sync::Arc}; - -use itertools::Itertools; -use log::{debug, error, info, trace}; +use log::{debug, error}; use parley::style::{FontStack, StyleProperty}; use vide::Shaper; @@ -14,8 +11,6 @@ struct ShapeKey { pub style: CoarseStyle, } -const FONT_CACHE_SIZE: usize = 8 * 1024 * 1024; - pub struct CachingShaper { options: FontOptions, scale_factor: f32, @@ -38,19 +33,21 @@ impl CachingShaper { } } - // fn current_font_pair(&mut self) -> Arc { - // self.font_loader - // .get_or_load(&FontKey { - // font_desc: self.options.primary_font(), - // hinting: self.options.hinting.clone(), - // edging: self.options.edging.clone(), - // }) - // .unwrap_or_else(|| { - // self.font_loader - // .get_or_load(&FontKey::default()) - // .expect("Could not load default font") - // }) - // } + /* + fn current_font_pair(&mut self) -> Arc { + self.font_loader + .get_or_load(&FontKey { + font_desc: self.options.primary_font(), + hinting: self.options.hinting.clone(), + edging: self.options.edging.clone(), + }) + .unwrap_or_else(|| { + self.font_loader + .get_or_load(&FontKey::default()) + .expect("Could not load default font") + }) + } + */ pub fn current_size(&self) -> f32 { let min_font_size = 1.0; @@ -80,36 +77,38 @@ impl CachingShaper { pub fn update_font_options(&mut self, options: FontOptions) { debug!("Updating font options: {:?}", options); - // let keys = options - // .possible_fonts() - // .iter() - // .map(|desc| FontKey { - // font_desc: Some(desc.clone()), - // hinting: options.hinting.clone(), - // edging: options.edging.clone(), - // }) - // .unique() - // .collect::>(); - // - // let failed_fonts = keys - // .iter() - // .filter(|key| self.font_loader.get_or_load(key).is_none()) - // .collect_vec(); - // - // if !failed_fonts.is_empty() { - // error_msg!( - // "Font can't be updated to: {:#?}\n\ - // Following fonts couldn't be loaded: {}", - // options, - // failed_fonts.iter().join(",\n"), - // ); - // } - // - // if failed_fonts.len() != keys.len() { - // debug!("Font updated to: {:?}", options); - // self.options = options; - // self.reset_font_loader(); - // } + /* + let keys = options + .possible_fonts() + .iter() + .map(|desc| FontKey { + font_desc: Some(desc.clone()), + hinting: options.hinting.clone(), + edging: options.edging.clone(), + }) + .unique() + .collect::>(); + + let failed_fonts = keys + .iter() + .filter(|key| self.font_loader.get_or_load(key).is_none()) + .collect_vec(); + + if !failed_fonts.is_empty() { + error_msg!( + "Font can't be updated to: {:#?}\n\ + Following fonts couldn't be loaded: {}", + options, + failed_fonts.iter().join(",\n"), + ); + } + + if failed_fonts.len() != keys.len() { + debug!("Font updated to: {:?}", options); + self.options = options; + self.reset_font_loader(); + } + */ } pub fn update_linespace(&mut self, linespace: f32) { @@ -134,17 +133,19 @@ impl CachingShaper { fn reset_font_loader(&mut self) { tracy_zone!("reset_font_loader"); - // self.font_info = None; - // let font_size = self.current_size(); - // - // self.font_loader = FontLoader::new(font_size); - // let (_, font_width) = self.info(); - // info!( - // "Reset Font Loader: font_size: {:.2}px, font_width: {:.2}px", - // font_size, font_width - // ); - // - // self.blob_cache.clear(); + /* + self.font_info = None; + let font_size = self.current_size(); + + self.font_loader = FontLoader::new(font_size); + let (_, font_width) = self.info(); + info!( + "Reset Font Loader: font_size: {:.2}px, font_width: {:.2}px", + font_size, font_width + ); + + self.blob_cache.clear(); + */ } pub fn font_names(&self) -> Vec { @@ -152,51 +153,54 @@ impl CachingShaper { Vec::new() } - // fn info(&mut self) -> (Metrics, f32) { - // if let Some(info) = self.font_info { - // return info; - // } - // - // let font_pair = self.current_font_pair(); - // let size = self.current_size(); - // let mut shaper = self - // .shape_context - // .builder(font_pair.swash_font.as_ref()) - // .size(size) - // .build(); - // shaper.add_str("M"); - // let metrics = shaper.metrics(); - // let mut advance = metrics.average_width; - // shaper.shape_with(|cluster| { - // advance = cluster - // .glyphs - // .first() - // .map_or(metrics.average_width, |g| g.advance); - // }); - // self.font_info = Some((metrics, advance)); - // (metrics, advance) - // } - // - // fn metrics(&mut self) -> Metrics { - // tracy_zone!("font_metrics"); - // self.info().0 - // } + /* + fn info(&mut self) -> (Metrics, f32) { + if let Some(info) = self.font_info { + return info; + } + + let font_pair = self.current_font_pair(); + let size = self.current_size(); + let mut shaper = self + .shape_context + .builder(font_pair.swash_font.as_ref()) + .size(size) + .build(); + shaper.add_str("M"); + let metrics = shaper.metrics(); + let mut advance = metrics.average_width; + shaper.shape_with(|cluster| { + advance = cluster + .glyphs + .first() + .map_or(metrics.average_width, |g| g.advance); + }); + self.font_info = Some((metrics, advance)); + (metrics, advance) + } + + fn metrics(&mut self) -> Metrics { + tracy_zone!("font_metrics"); + self.info().0 + } + */ pub fn font_base_dimensions(&mut self) -> PixelSize { - // let (metrics, glyph_advance) = self.info(); - // - // let bare_font_height = metrics.ascent + metrics.descent + metrics.leading; - // // assuming that linespace is checked on receive for validity - // let font_height = (bare_font_height + self.linespace).ceil(); - // let font_width = glyph_advance + self.options.width; - // - // (font_width, font_height).into() + /* + let (metrics, glyph_advance) = self.info(); - (11.487181, 23.0).into() + let bare_font_height = metrics.ascent + metrics.descent + metrics.leading; + // assuming that linespace is checked on receive for validity + let font_height = (bare_font_height + self.linespace).ceil(); + let font_width = glyph_advance + self.options.width; + + (font_width, font_height).into() + */ - //(8.205129, 17.0).into() + (11.487181, 23.0).into() } + /* pub fn underline_position(&mut self) -> f32 { self.baseline_offset() } @@ -204,14 +208,17 @@ impl CachingShaper { pub fn stroke_size(&mut self) -> f32 { 1.0 } + */ pub fn baseline_offset(&mut self) -> f32 { - //let metrics = self.metrics(); - // NOTE: leading is also called linegap and should be equally distributed on the top and - // bottom, so it's centered like our linespace settings. That's how it works on the web, - // but some desktop applications only use the top according to: - // https://googlefonts.github.io/gf-guide/metrics.html#8-linegap-values-must-be-0 - ////////////////metrics.ascent + (metrics.leading + self.linespace) / 2.0 + /* + let metrics = self.metrics(); + NOTE: leading is also called linegap and should be equally distributed on the top and + bottom, so it's centered like our linespace settings. That's how it works on the web, + but some desktop applications only use the top according to: + https://googlefonts.github.io/gf-guide/metrics.html#8-linegap-values-must-be-0 + metrics.ascent + (metrics.leading + self.linespace) / 2.0 + */ 0.0 } } diff --git a/src/renderer/fonts/font_loader.rs b/src/renderer/fonts/font_loader.rs deleted file mode 100644 index ffe0710d3..000000000 --- a/src/renderer/fonts/font_loader.rs +++ /dev/null @@ -1,193 +0,0 @@ -use std::{ - fmt::{Display, Formatter}, - num::NonZeroUsize, - sync::Arc, -}; - -use log::trace; -use lru::LruCache; -use skia_safe::{font::Edging as SkiaEdging, Data, Font, FontHinting as SkiaHinting, FontMgr}; - -use crate::{ - profiling::tracy_zone, - renderer::fonts::{ - font_options::{CoarseStyle, FontDescription, FontEdging, FontHinting}, - swash_font::SwashFont, - }, -}; - -static DEFAULT_FONT: &[u8] = include_bytes!("../../../assets/fonts/FiraCodeNerdFont-Regular.ttf"); -static LAST_RESORT_FONT: &[u8] = include_bytes!("../../../assets/fonts/LastResort-Regular.ttf"); - -pub struct FontPair { - pub key: FontKey, - pub skia_font: Font, - pub swash_font: SwashFont, -} - -impl FontPair { - fn new(key: FontKey, mut skia_font: Font) -> Option { - skia_font.set_subpixel(true); - skia_font.set_baseline_snap(true); - skia_font.set_hinting(font_hinting(&key.hinting)); - skia_font.set_edging(font_edging(&key.edging)); - - let typeface = skia_font.typeface(); - let (font_data, index) = typeface.to_font_data()?; - // Only the lower 16 bits are part of the index, the rest indicates named instances. But we - // don't care about those here, since we are just loading the font, so ignore them - let index = index & 0xFFFF; - let swash_font = SwashFont::from_data(font_data, index)?; - - Some(Self { - key, - skia_font, - swash_font, - }) - } -} - -impl PartialEq for FontPair { - fn eq(&self, other: &Self) -> bool { - self.swash_font.key == other.swash_font.key - } -} - -#[derive(Debug, Default, Hash, PartialEq, Eq, Clone)] -pub struct FontKey { - // TODO(smolck): Could make these private and add constructor method(s)? - // Would theoretically make things safer I guess, but not sure . . . - pub font_desc: Option, - pub hinting: FontHinting, - pub edging: FontEdging, -} - -pub struct FontLoader { - font_mgr: FontMgr, - cache: LruCache>, - font_size: f32, - last_resort: Option>, -} - -impl Display for FontKey { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!( - f, - "FontKey {{ font_desc: {:?}, hinting: {:?}, edging: {:?} }}", - self.font_desc, self.hinting, self.edging - ) - } -} - -impl FontLoader { - pub fn new(font_size: f32) -> FontLoader { - FontLoader { - font_mgr: FontMgr::new(), - cache: LruCache::new(NonZeroUsize::new(20).unwrap()), - font_size, - last_resort: None, - } - } - - fn load(&mut self, font_key: FontKey) -> Option { - tracy_zone!("load_font"); - trace!("Loading font {:?}", font_key); - if let Some(desc) = &font_key.font_desc { - let (family, style) = desc.as_family_and_font_style(); - let typeface = self.font_mgr.match_family_style(family, style)?; - FontPair::new(font_key, Font::from_typeface(typeface, self.font_size)) - } else { - let data = Data::new_copy(DEFAULT_FONT); - let typeface = self.font_mgr.new_from_data(&data, 0)?; - FontPair::new(font_key, Font::from_typeface(typeface, self.font_size)) - } - } - - pub fn get_or_load(&mut self, font_key: &FontKey) -> Option> { - if let Some(cached) = self.cache.get(font_key) { - return Some(cached.clone()); - } - - let loaded_font = self.load(font_key.clone())?; - let font_arc = Arc::new(loaded_font); - self.cache.put(font_key.clone(), font_arc.clone()); - - Some(font_arc) - } - - pub fn load_font_for_character( - &mut self, - coarse_style: CoarseStyle, - character: char, - ) -> Option> { - let font_style = coarse_style.into(); - let typeface = - self.font_mgr - .match_family_style_character("", font_style, &[], character as i32)?; - - let font_key = FontKey { - font_desc: Some(FontDescription { - family: typeface.family_name(), - style: coarse_style.name().map(str::to_string), - }), - hinting: FontHinting::default(), - edging: FontEdging::default(), - }; - - let font_pair = Arc::new(FontPair::new( - font_key.clone(), - Font::from_typeface(typeface, self.font_size), - )?); - - self.cache.put(font_key, font_pair.clone()); - - Some(font_pair) - } - - pub fn get_or_load_last_resort(&mut self) -> Option> { - if self.last_resort.is_some() { - self.last_resort.clone() - } else { - let font_key = FontKey::default(); - let data = Data::new_copy(LAST_RESORT_FONT); - - let typeface = self.font_mgr.new_from_data(&data, 0)?; - let font_pair = Arc::new(FontPair::new( - font_key, - Font::from_typeface(typeface, self.font_size), - )?); - - self.last_resort = Some(font_pair.clone()); - Some(font_pair) - } - } - - pub fn loaded_fonts(&self) -> Vec> { - self.cache.iter().map(|(_, v)| v.clone()).collect() - } - - pub fn refresh(&mut self, font_pair: &FontPair) { - self.cache.get(&font_pair.key); - } - - pub fn font_names(&self) -> Vec { - self.font_mgr.family_names().collect() - } -} - -fn font_hinting(hinting: &FontHinting) -> SkiaHinting { - match hinting { - FontHinting::Full => SkiaHinting::Full, - FontHinting::Slight => SkiaHinting::Slight, - FontHinting::Normal => SkiaHinting::Normal, - FontHinting::None => SkiaHinting::None, - } -} - -fn font_edging(edging: &FontEdging) -> SkiaEdging { - match edging { - FontEdging::AntiAlias => SkiaEdging::AntiAlias, - FontEdging::Alias => SkiaEdging::Alias, - FontEdging::SubpixelAntiAlias => SkiaEdging::SubpixelAntiAlias, - } -} diff --git a/src/renderer/fonts/font_options.rs b/src/renderer/fonts/font_options.rs index eb9beffed..f7252d45f 100644 --- a/src/renderer/fonts/font_options.rs +++ b/src/renderer/fonts/font_options.rs @@ -44,6 +44,8 @@ pub struct CoarseStyle { italic: bool, } +// TODO: Remove +#[allow(unused)] impl CoarseStyle { /// Returns the textual name of this style. pub fn name(&self) -> Option<&'static str> { @@ -68,16 +70,18 @@ impl CoarseStyle { } } -// impl From for FontStyle { -// fn from(CoarseStyle { bold, italic }: CoarseStyle) -> Self { -// match (bold, italic) { -// (true, true) => FontStyle::bold_italic(), -// (true, false) => FontStyle::bold(), -// (false, true) => FontStyle::italic(), -// (false, false) => FontStyle::normal(), -// } -// } -// } +/* +impl From for FontStyle { + fn from(CoarseStyle { bold, italic }: CoarseStyle) -> Self { + match (bold, italic) { + (true, true) => FontStyle::bold_italic(), + (true, false) => FontStyle::bold(), + (false, true) => FontStyle::italic(), + (false, false) => FontStyle::normal(), + } + } +} +*/ impl From<&editor::Style> for CoarseStyle { fn from(fine_style: &editor::Style) -> Self { @@ -95,6 +99,7 @@ impl From<&Arc> for CoarseStyle { } } +// TODO: Remove #[derive(Clone, Debug)] pub struct FontOptions { pub normal: Vec, @@ -129,6 +134,7 @@ impl FontFeature { } } +#[allow(unused)] impl FontOptions { pub fn parse(guifont_setting: &str) -> Result { let mut font_options = FontOptions::default(); @@ -348,48 +354,50 @@ pub fn points_to_pixels(value: f32) -> f32 { pixels } +/* impl FontDescription { - // pub fn as_family_and_font_style(&self) -> (&str, FontStyle) { - // // support font weights: - // // Thin, ExtraLight, Light, Normal, Medium, SemiBold, Bold, ExtraBold, Black, ExtraBlack - // // W{weight} - // // support font slants: - // // Upright, Italic, Oblique - // - // let style = if let Some(style) = &self.style { - // let mut weight = Weight::NORMAL; - // let mut slant = Slant::Upright; - // - // for part in style.split_whitespace() { - // match part { - // "Thin" => weight = Weight::THIN, - // "ExtraLight" => weight = Weight::EXTRA_LIGHT, - // "Light" => weight = Weight::LIGHT, - // "Normal" => weight = Weight::NORMAL, - // "Medium" => weight = Weight::MEDIUM, - // "SemiBold" => weight = Weight::SEMI_BOLD, - // "Bold" => weight = Weight::BOLD, - // "ExtraBold" => weight = Weight::EXTRA_BOLD, - // "Black" => weight = Weight::BLACK, - // "ExtraBlack" => weight = Weight::EXTRA_BLACK, - // "Italic" => slant = Slant::Italic, - // "Oblique" => slant = Slant::Oblique, - // _ => { - // if let Some(rest) = part.strip_prefix('W') { - // if let Ok(weight_value) = rest.parse::() { - // weight = Weight::from(weight_value); - // } - // } - // } - // } - // } - // FontStyle::new(weight, Width::NORMAL, slant) - // } else { - // FontStyle::default() - // }; - // (self.family.as_str(), style) - // } + pub fn as_family_and_font_style(&self) -> (&str, FontStyle) { + // support font weights: + // Thin, ExtraLight, Light, Normal, Medium, SemiBold, Bold, ExtraBold, Black, ExtraBlack + // W{weight} + // support font slants: + // Upright, Italic, Oblique + + let style = if let Some(style) = &self.style { + let mut weight = Weight::NORMAL; + let mut slant = Slant::Upright; + + for part in style.split_whitespace() { + match part { + "Thin" => weight = Weight::THIN, + "ExtraLight" => weight = Weight::EXTRA_LIGHT, + "Light" => weight = Weight::LIGHT, + "Normal" => weight = Weight::NORMAL, + "Medium" => weight = Weight::MEDIUM, + "SemiBold" => weight = Weight::SEMI_BOLD, + "Bold" => weight = Weight::BOLD, + "ExtraBold" => weight = Weight::EXTRA_BOLD, + "Black" => weight = Weight::BLACK, + "ExtraBlack" => weight = Weight::EXTRA_BLACK, + "Italic" => slant = Slant::Italic, + "Oblique" => slant = Slant::Oblique, + _ => { + if let Some(rest) = part.strip_prefix('W') { + if let Ok(weight_value) = rest.parse::() { + weight = Weight::from(weight_value); + } + } + } + } + } + FontStyle::new(weight, Width::NORMAL, slant) + } else { + FontStyle::default() + }; + (self.family.as_str(), style) + } } +*/ impl fmt::Display for FontDescription { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/src/renderer/fonts/mod.rs b/src/renderer/fonts/mod.rs index 9e5e5644e..79a528401 100644 --- a/src/renderer/fonts/mod.rs +++ b/src/renderer/fonts/mod.rs @@ -1,7 +1,4 @@ mod caching_shaper; -//pub mod font_loader; pub mod font_options; -//mod font_manager; -//mod swash_font; pub use caching_shaper::CachingShaper; diff --git a/src/renderer/fonts/swash_font.rs b/src/renderer/fonts/swash_font.rs deleted file mode 100644 index 39c91cf4a..000000000 --- a/src/renderer/fonts/swash_font.rs +++ /dev/null @@ -1,23 +0,0 @@ -use swash::{CacheKey, FontRef}; - -pub struct SwashFont { - data: Vec, - offset: u32, - pub key: CacheKey, -} - -impl SwashFont { - pub fn from_data(data: Vec, index: usize) -> Option { - let font = FontRef::from_index(&data, index)?; - let (offset, key) = (font.offset, font.key); - Some(Self { data, offset, key }) - } - - pub fn as_ref(&self) -> FontRef { - FontRef { - data: &self.data, - offset: self.offset, - key: self.key, - } - } -} diff --git a/src/renderer/grid_renderer.rs b/src/renderer/grid_renderer.rs index 538235e71..c6d4465bd 100644 --- a/src/renderer/grid_renderer.rs +++ b/src/renderer/grid_renderer.rs @@ -2,16 +2,16 @@ use std::sync::Arc; use log::trace; -use palette::{named, Hsv, IntoColor, LinSrgba, Srgba, WithAlpha}; -use parley::style::{FontStack, StyleProperty}; -use vide::{Layer, Quad, Scene, Shaper}; +use palette::{named, Hsv, IntoColor, Srgba, WithAlpha}; +use parley::style::StyleProperty; +use vide::{Layer, Quad, Scene}; use crate::{ - editor::{Colors, Style, UnderlineStyle}, + editor::{Colors, Style}, profiling::tracy_zone, renderer::{fonts::CachingShaper, RendererSettings}, settings::*, - units::{GridPos, GridScale, GridSize, PixelPos, PixelRect, PixelVec}, + units::{GridPos, GridScale, GridSize, PixelRect, PixelVec}, }; use super::fonts::font_options::FontOptions; @@ -145,23 +145,23 @@ impl GridRenderer { &mut self, text: &str, grid_position: GridPos, - cell_width: i32, + _cell_width: i32, transform: PixelVec, style: &Option>, scene: &mut Scene, ) -> bool { tracy_zone!("draw_foreground"); let pos = grid_position * self.grid_scale + transform; - let size = GridSize::new(cell_width, 0) * self.grid_scale; - let width = size.width; + // let size = GridSize::new(cell_width, 0) * self.grid_scale; + //let width = size.width; let style = style.as_ref().unwrap_or(&self.default_style); let mut drawn = false; // We don't want to clip text in the x position, only the y so we add a buffer of 1 // character on either side of the region so that we clip vertically but not horizontally. - let clip_position = (grid_position.x.saturating_sub(1), grid_position.y).into(); - let region = self.compute_text_region(clip_position, cell_width + 2); + // let clip_position = (grid_position.x.saturating_sub(1), grid_position.y).into(); + //let region = self.compute_text_region(clip_position, cell_width + 2); // TODO: Draw underline if let Some(_underline_style) = style.underline { @@ -196,13 +196,10 @@ impl GridRenderer { if !trimmed.is_empty() { tracy_zone!("draw_text_blob"); let pos = pos + adjustment; - // TODO: The text is not in linear srgba for some reason - //let color: LinSrgba = color.into_color(); let layout = self.shaper.shaper.layout_with(trimmed, |builder| { builder.push_default(&StyleProperty::Brush(color)); }); scene.add_text_layout(layout, pos.cast()); - //canvas.draw_text_blob(blob, to_skia_point(pos + adjustment), &paint); drawn = true; } @@ -222,6 +219,7 @@ impl GridRenderer { drawn } + /* fn draw_underline( &self, style: &Arc