diff --git a/Cargo.lock b/Cargo.lock index 905b8b7..3331c91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -682,15 +682,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "core_maths" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" -dependencies = [ - "libm", -] - [[package]] name = "crc32fast" version = "1.5.0" @@ -995,12 +986,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -1017,25 +1002,33 @@ dependencies = [ ] [[package]] -name = "fontique" -version = "0.6.0" +name = "font-types" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff3336bc0b87fe42305047263fa60d2eabd650d29cbe62fdeb2a66c7a0a595f9" +checksum = "0a7299a780854a6d391be2ae1c8521c9368471b559dbfd6a8dbd9f407eaff100" dependencies = [ "bytemuck", - "hashbrown 0.15.5", - "icu_locale_core", +] + +[[package]] +name = "fontique" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e04c4750a17111ebd77c3e0aea00476ce33f59235bc4d9e7f0aded5033ad3fc" +dependencies = [ + "hashbrown 0.17.1", "linebender_resource_handle", "memmap2", "objc2 0.6.4", "objc2-core-foundation", "objc2-core-text", "objc2-foundation 0.3.2", - "read-fonts", + "parlance", + "read-fonts 0.40.2", "roxmltree", "smallvec", - "windows 0.58.0", - "windows-core 0.58.0", + "windows", + "windows-core", "yeslogic-fontconfig-sys", ] @@ -1225,28 +1218,16 @@ dependencies = [ [[package]] name = "harfrust" -version = "0.3.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c020db12c71d8a12a3fe7607873cade3a01a6287e29d540c8723276221b9d8" +checksum = "f0589ddd0d2935dd2845827ac606b4081c266225d613b268ed2910f832889cab" dependencies = [ "bitflags 2.11.0", "bytemuck", - "core_maths", - "read-fonts", + "read-fonts 0.40.2", "smallvec", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" @@ -1255,7 +1236,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -1264,7 +1245,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -1400,6 +1381,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_locale" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532b11722e350ab6bf916ba6eb0efe3ee54b932666afec989465f9243fe6dd60" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_locale_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + [[package]] name = "icu_locale_core" version = "2.1.1" @@ -1414,6 +1410,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_locale_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c5f1d16b4c3a2642d3a719f18f6b06070ab0aef246a6418130c955ae08aa831" + [[package]] name = "icu_normalizer" version = "2.1.1" @@ -1462,6 +1464,8 @@ checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" dependencies = [ "displaydoc", "icu_locale_core", + "serde", + "stable_deref_trait", "writeable", "yoke", "zerofrom", @@ -1469,6 +1473,27 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_segmenter" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a807a7488f3f758629ae86d99d9d30dce24da2fb2945d74c80a4f4a62c71db73" +dependencies = [ + "icu_collections", + "icu_locale", + "icu_provider", + "icu_segmenter_data", + "potential_utf", + "utf8_iter", + "zerovec", +] + +[[package]] +name = "icu_segmenter_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ebbb7321d9e21d25f5660366cb6c08201d0175898a3a6f7a41ee9685af21c80" + [[package]] name = "idna" version = "1.1.0" @@ -2431,17 +2456,36 @@ dependencies = [ ] [[package]] -name = "parley" -version = "0.6.0" +name = "parlance" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26746861bb76dbc9bcd5ed1b0b55d2fedf291100961251702a031ab2abd2ce52" +checksum = "4b6937eda350acc1a5d05872c3cbf99fe78619c269096e2be3d4a350058639d5" + +[[package]] +name = "parley" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0478b47dd9885a5e0a4f1c0782ffc42bf6ee8c41dea0917d7a9bcee3e6585fc" dependencies = [ "fontique", "harfrust", - "hashbrown 0.15.5", + "hashbrown 0.17.1", + "icu_normalizer", + "icu_properties", + "icu_segmenter", "linebender_resource_handle", - "skrifa", - "swash", + "parlance", + "parley_data", + "skrifa 0.43.2", +] + +[[package]] +name = "parley_data" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a649e01a1acc917247ee147b56b8a1fa91824acf7117bd003b4204306d601255" +dependencies = [ + "icu_properties", ] [[package]] @@ -2566,6 +2610,8 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" dependencies = [ + "serde_core", + "writeable", "zerovec", ] @@ -2868,8 +2914,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6717cf23b488adf64b9d711329542ba34de147df262370221940dfabc2c91358" dependencies = [ "bytemuck", - "core_maths", - "font-types", + "font-types 0.10.1", +] + +[[package]] +name = "read-fonts" +version = "0.40.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487889119a5f19ff7c0a20637196bdc76b9f54ebec17e3588b5d75e4999f8773" +dependencies = [ + "bytemuck", + "font-types 0.12.2", + "once_cell", ] [[package]] @@ -3017,9 +3073,12 @@ dependencies = [ [[package]] name = "roxmltree" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" +checksum = "f1964b10c76125c36f8afe190065a4bf9a87bf324842c05701330bba9f1cacbb" +dependencies = [ + "memchr", +] [[package]] name = "rustc-hash" @@ -3302,7 +3361,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c31071dedf532758ecf3fed987cdb4bd9509f900e026ab684b4ecb81ea49841" dependencies = [ "bytemuck", - "read-fonts", + "read-fonts 0.35.0", +] + +[[package]] +name = "skrifa" +version = "0.43.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbe997d0f2480442d727488fbe2150779114cbe480ecdbadef58b33e0318ffb" +dependencies = [ + "bytemuck", + "read-fonts 0.40.2", ] [[package]] @@ -3444,7 +3513,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47846491253e976bdd07d0f9cc24b7daf24720d11309302ccbbc6e6b6e53550a" dependencies = [ - "skrifa", + "skrifa 0.37.0", "yazi", "zeno", ] @@ -4198,7 +4267,7 @@ dependencies = [ "thiserror 2.0.18", "wgpu-naga-bridge", "wgpu-types", - "windows 0.62.2", + "windows", ] [[package]] @@ -4236,16 +4305,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "windows" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" -dependencies = [ - "windows-core 0.58.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows" version = "0.62.2" @@ -4253,7 +4312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" dependencies = [ "windows-collections", - "windows-core 0.62.2", + "windows-core", "windows-future", "windows-numerics", ] @@ -4264,20 +4323,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" dependencies = [ - "windows-core 0.62.2", -] - -[[package]] -name = "windows-core" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" -dependencies = [ - "windows-implement 0.58.0", - "windows-interface 0.58.0", - "windows-result 0.2.0", - "windows-strings 0.1.0", - "windows-targets 0.52.6", + "windows-core", ] [[package]] @@ -4286,11 +4332,11 @@ version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-implement 0.60.2", - "windows-interface 0.59.3", + "windows-implement", + "windows-interface", "windows-link", - "windows-result 0.4.1", - "windows-strings 0.5.1", + "windows-result", + "windows-strings", ] [[package]] @@ -4299,22 +4345,11 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" dependencies = [ - "windows-core 0.62.2", + "windows-core", "windows-link", "windows-threading", ] -[[package]] -name = "windows-implement" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "windows-implement" version = "0.60.2" @@ -4326,17 +4361,6 @@ dependencies = [ "syn", ] -[[package]] -name = "windows-interface" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "windows-interface" version = "0.59.3" @@ -4360,7 +4384,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" dependencies = [ - "windows-core 0.62.2", + "windows-core", "windows-link", ] @@ -4371,17 +4395,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ "windows-link", - "windows-result 0.4.1", - "windows-strings 0.5.1", -] - -[[package]] -name = "windows-result" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" -dependencies = [ - "windows-targets 0.52.6", + "windows-result", + "windows-strings", ] [[package]] @@ -4393,16 +4408,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-strings" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" -dependencies = [ - "windows-result 0.2.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows-strings" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 58f478a..0a2b45e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ nohash-hasher = "0.2.0" num-traits = "0.2.19" open = "5.3.2" ordered-float = "5.0.0" -parley = "0.6.0" +parley = "0.11.0" pollster = "0.3" profiling = "1.0" puffin_http = { version = "0.16", optional = true } diff --git a/src/api/rendering.rs b/src/api/rendering.rs index 1b5e565..d2d0a28 100644 --- a/src/api/rendering.rs +++ b/src/api/rendering.rs @@ -11,7 +11,7 @@ use mlua::{ LightUserData, Lua, Result as LuaResult, UserDataRefMut, Value, ffi::{self}, }; -use parley::FontFamily; +use parley::{FontFamily, FontFamilyName}; use regex::Regex; use std::{borrow::Cow, sync::LazyLock}; @@ -483,19 +483,27 @@ fn build_layout_job<'a>( let mut font_weight = None; let mut font_style = FontStyle::default(); let font_family = match font_type { - PoBFontType::Fixed => FontFamily::Named(Cow::Borrowed("Bitstream Vera Sans Mono")), - PoBFontType::Var => FontFamily::Named(Cow::Borrowed("Liberation Sans")), + PoBFontType::Fixed => FontFamily::Single(FontFamilyName::Named(Cow::Borrowed( + "Bitstream Vera Sans Mono", + ))), + PoBFontType::Var => { + FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Liberation Sans"))) + } PoBFontType::VarBold => { font_weight = Some(700.0); - FontFamily::Named(Cow::Borrowed("Liberation Sans")) + FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Liberation Sans"))) + } + PoBFontType::Fontin => FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin"))), + PoBFontType::FontinItalic => { + FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin"))) + } + PoBFontType::FontinSmallcaps => { + FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin SmallCaps"))) } - PoBFontType::Fontin => FontFamily::Named(Cow::Borrowed("Fontin")), - PoBFontType::FontinItalic => FontFamily::Named(Cow::Borrowed("Fontin")), - PoBFontType::FontinSmallcaps => FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")), PoBFontType::FontinSmallcapsItalic => { font_style = FontStyle::Italic; // use regular Smallcaps with "faux italics" - FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")) + FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin SmallCaps"))) } }; diff --git a/src/fonts.rs b/src/fonts.rs index 3eefcef..1be51ef 100644 --- a/src/fonts.rs +++ b/src/fonts.rs @@ -10,8 +10,8 @@ use crate::{ use ahash::HashMap; use ordered_float::OrderedFloat; use parley::{ - FontContext, FontFamily, FontStack, FontWeight, GenericFamily, LayoutContext, StyleProperty, - TextStyle, fontique::Blob, + FontContext, FontFamily, FontFamilyName, FontWeight, GenericFamily, LayoutContext, + StyleProperty, TextStyle, fontique::Blob, }; use std::sync::Arc; @@ -122,21 +122,21 @@ impl Fonts { self.preload_text( &common_chars, font_size, - FontFamily::Generic(GenericFamily::Monospace), + FontFamily::Single(FontFamilyName::Generic(GenericFamily::Monospace)), None, parley::FontStyle::Normal, ); self.preload_text( &common_chars, font_size, - FontFamily::Generic(GenericFamily::SansSerif), + FontFamily::Single(FontFamilyName::Generic(GenericFamily::SansSerif)), None, parley::FontStyle::Normal, ); self.preload_text( &common_chars, font_size, - FontFamily::Generic(GenericFamily::SansSerif), + FontFamily::Single(FontFamilyName::Generic(GenericFamily::SansSerif)), Some(FontWeight::BOLD), parley::FontStyle::Normal, ); @@ -153,7 +153,7 @@ impl Fonts { profiling::scope!("preload_text"); let style = TextStyle { - font_stack: FontStack::Single(font_family), + font_family, font_weight: font_weight.unwrap_or(FontWeight::NORMAL), font_style, font_size, @@ -200,7 +200,7 @@ impl Fonts { let default_style = TextStyle::default(); let style = TextStyle { - font_stack: parley::FontStack::Single(job.font_family), + font_family: job.font_family, font_size: job.font_size.into(), line_height: parley::LineHeight::Absolute(job.line_height.into()), font_weight: job @@ -239,7 +239,7 @@ impl Fonts { parley::Alignment::End } }; - parley_layout.align(None, alignment, parley::AlignmentOptions::default()); + parley_layout.align(alignment, parley::AlignmentOptions::default()); } let mut layout_rows = Vec::new(); diff --git a/src/fonts/layout.rs b/src/fonts/layout.rs index 879d8d8..669be8c 100644 --- a/src/fonts/layout.rs +++ b/src/fonts/layout.rs @@ -1,6 +1,6 @@ use crate::{color::Srgba, dpi::LogicalPoint, fonts::rasterizer::RasterizedGlyph}; use ordered_float::OrderedFloat; -use parley::FontFamily; +use parley::{FontFamily, FontFamilyName}; #[derive(Copy, Clone, Default, Debug, Hash, PartialEq)] pub enum Alignment { @@ -72,12 +72,27 @@ impl std::hash::Hash for LayoutJob<'_> { fn hash(&self, state: &mut H) { self.segments.hash(state); match &self.font_family { - FontFamily::Named(cow) => { + FontFamily::Single(FontFamilyName::Named(cow)) => { cow.hash(state); } - FontFamily::Generic(generic_family) => { + FontFamily::Single(FontFamilyName::Generic(generic_family)) => { generic_family.hash(state); } + FontFamily::Source(cow) => { + cow.hash(state); + } + FontFamily::List(cow) => { + for name in cow.iter() { + match name { + FontFamilyName::Named(cow) => { + cow.hash(state); + } + FontFamilyName::Generic(generic_family) => { + generic_family.hash(state); + } + } + } + } } self.font_size.hash(state); self.line_height.hash(state); diff --git a/src/installer.rs b/src/installer.rs index 070b651..8268605 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -12,7 +12,7 @@ use crate::{ renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive}, util::replace_in_matching_lines, }; -use parley::{FontFamily, GenericFamily}; +use parley::{FontFamily, FontFamilyName, GenericFamily}; use regex::Regex; use std::{ fs, @@ -111,7 +111,7 @@ impl InstallMode { app_state: &mut AppState, ) -> Box> { let mut job = LayoutJob::new( - FontFamily::Generic(GenericFamily::SansSerif), + FontFamily::Single(FontFamilyName::Generic(GenericFamily::SansSerif)), 32.0, 34.0, Some(Alignment::Center),