diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 090aed8a..8b3e1d47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ env: # If the compilation fails, then the version specified here needs to be bumped up to reality. # Be sure to also update the rust-version property in the workspace Cargo.toml file, # plus all the README.md files of the affected packages. - RUST_MIN_VER: "1.82" + RUST_MIN_VER: "1.85" # List of packages that will be checked with the minimum supported Rust version. # This should be limited to packages that are intended for publishing. RUST_MIN_VER_PKGS: "-p parley -p fontique" diff --git a/CHANGELOG.md b/CHANGELOG.md index 8027392d..bc9c4daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,11 @@ You can find its changes [documented below](#030---2025-02-27). ## [Unreleased] -This release has an [MSRV] of 1.82. +This release has an [MSRV] of 1.85. + +### Internals + +Switched to edition 2024. ## [0.3.0] - 2025-02-27 diff --git a/Cargo.toml b/Cargo.toml index b03264f7..6d1cad35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,10 @@ members = [ ] [workspace.package] -edition = "2021" +edition = "2024" # Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml, with the relevant README.md files # and with the MSRV in the `Unreleased` section of CHANGELOG.md. -rust-version = "1.82" +rust-version = "1.85" license = "Apache-2.0 OR MIT" repository = "https://github.com/linebender/parley" diff --git a/README.md b/README.md index 2721f682..63d73659 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Besides what the other libraries do, this involves things like determining a gly ## Minimum supported Rust Version (MSRV) -This version of Parley has been verified to compile with **Rust 1.82** and later. +This version of Parley has been verified to compile with **Rust 1.85** and later. Future versions of Parley might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. diff --git a/examples/swash_render/src/main.rs b/examples/swash_render/src/main.rs index fbe8fdfa..3df00dae 100644 --- a/examples/swash_render/src/main.rs +++ b/examples/swash_render/src/main.rs @@ -16,10 +16,10 @@ use parley::layout::{Alignment, Glyph, GlyphRun, Layout, PositionedLayoutItem}; use parley::style::{FontStack, FontWeight, StyleProperty, TextStyle}; use parley::{AlignmentOptions, FontContext, InlineBox, LayoutContext}; use std::fs::File; +use swash::FontRef; use swash::scale::image::Content; use swash::scale::{Render, ScaleContext, Scaler, Source, StrikeWith}; use swash::zeno; -use swash::FontRef; use zeno::{Format, Vector}; #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/examples/tiny_skia_render/src/main.rs b/examples/tiny_skia_render/src/main.rs index 734d4fdc..195b162f 100644 --- a/examples/tiny_skia_render/src/main.rs +++ b/examples/tiny_skia_render/src/main.rs @@ -18,10 +18,10 @@ use parley::{ Layout, LayoutContext, PositionedLayoutItem, StyleProperty, }; use skrifa::{ + GlyphId, MetadataProvider, OutlineGlyph, instance::{LocationRef, NormalizedCoord, Size}, outline::{DrawSettings, OutlinePen}, raw::FontRef as ReadFontsRef, - GlyphId, MetadataProvider, OutlineGlyph, }; use tiny_skia::{Color, FillRule, Paint, PathBuilder, Pixmap, PixmapMut, Rect, Transform}; diff --git a/examples/vello_editor/src/text.rs b/examples/vello_editor/src/text.rs index 446bd283..f57ad970 100644 --- a/examples/vello_editor/src/text.rs +++ b/examples/vello_editor/src/text.rs @@ -3,13 +3,13 @@ use accesskit::{Node, TreeUpdate}; use core::default::Default; -use parley::{editor::SplitString, layout::PositionedLayoutItem, GenericFamily, StyleProperty}; +use parley::{GenericFamily, StyleProperty, editor::SplitString, layout::PositionedLayoutItem}; use std::time::{Duration, Instant}; use vello::{ + Scene, kurbo::{Affine, Line, Stroke}, peniko::color::palette, peniko::{Brush, Fill}, - Scene, }; use winit::{ event::{Ime, Modifiers, Touch, WindowEvent}, diff --git a/fontique/README.md b/fontique/README.md index fece6302..8b5e2ffb 100644 --- a/fontique/README.md +++ b/fontique/README.md @@ -16,7 +16,7 @@ Fontique provides font enumeration and fallback. ## Minimum supported Rust Version (MSRV) -This version of Fontique has been verified to compile with **Rust 1.82** and later. +This version of Fontique has been verified to compile with **Rust 1.85** and later. Future versions of Fontique might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. diff --git a/fontique/src/backend/android.rs b/fontique/src/backend/android.rs index f122aae8..89c510c3 100644 --- a/fontique/src/backend/android.rs +++ b/fontique/src/backend/android.rs @@ -8,7 +8,7 @@ use icu_locid::LanguageIdentifier; use roxmltree::{Document, Node}; use super::{ - scan, FallbackKey, FamilyId, FamilyInfo, FamilyNameMap, GenericFamily, GenericFamilyMap, Script, + FallbackKey, FamilyId, FamilyInfo, FamilyNameMap, GenericFamily, GenericFamilyMap, Script, scan, }; // TODO: Use actual generic families here, where available, when fonts.xml is properly parsed. diff --git a/fontique/src/backend/coretext.rs b/fontique/src/backend/coretext.rs index 072bac20..3ea1d800 100644 --- a/fontique/src/backend/coretext.rs +++ b/fontique/src/backend/coretext.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use super::{ - scan, FallbackKey, FamilyId, FamilyInfo, FamilyNameMap, GenericFamily, GenericFamilyMap, + FallbackKey, FamilyId, FamilyInfo, FamilyNameMap, GenericFamily, GenericFamilyMap, scan, }; use alloc::sync::Arc; use core::ptr::{null, null_mut}; diff --git a/fontique/src/backend/dwrite.rs b/fontique/src/backend/dwrite.rs index d6c5e99c..b3fde88f 100644 --- a/fontique/src/backend/dwrite.rs +++ b/fontique/src/backend/dwrite.rs @@ -3,21 +3,21 @@ use hashbrown::HashMap; use std::{ - ffi::{c_void, OsString}, + ffi::{OsString, c_void}, os::windows::ffi::OsStringExt, path::PathBuf, sync::Arc, }; use windows::{ - core::{implement, Interface, PCWSTR}, Win32::Graphics::DirectWrite::{ - DWriteCreateFactory, IDWriteFactory, IDWriteFactory2, IDWriteFont, IDWriteFontCollection, - IDWriteFontFace, IDWriteFontFallback, IDWriteFontFamily, IDWriteFontFile, - IDWriteLocalFontFileLoader, IDWriteNumberSubstitution, IDWriteTextAnalysisSource, - IDWriteTextAnalysisSource_Impl, DWRITE_FACTORY_TYPE_SHARED, DWRITE_FONT_STRETCH_NORMAL, - DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_WEIGHT_REGULAR, DWRITE_READING_DIRECTION, - DWRITE_READING_DIRECTION_LEFT_TO_RIGHT, + DWRITE_FACTORY_TYPE_SHARED, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, + DWRITE_FONT_WEIGHT_REGULAR, DWRITE_READING_DIRECTION, + DWRITE_READING_DIRECTION_LEFT_TO_RIGHT, DWriteCreateFactory, IDWriteFactory, + IDWriteFactory2, IDWriteFont, IDWriteFontCollection, IDWriteFontFace, IDWriteFontFallback, + IDWriteFontFamily, IDWriteFontFile, IDWriteLocalFontFileLoader, IDWriteNumberSubstitution, + IDWriteTextAnalysisSource, IDWriteTextAnalysisSource_Impl, }, + core::{Interface, PCWSTR, implement}, }; use super::{ diff --git a/fontique/src/backend/mod.rs b/fontique/src/backend/mod.rs index a84e97d7..50eca38a 100644 --- a/fontique/src/backend/mod.rs +++ b/fontique/src/backend/mod.rs @@ -21,9 +21,10 @@ mod system; #[allow(unused_imports)] use super::{ + FallbackKey, FamilyId, FamilyInfo, FontInfo, GenericFamily, Script, SourceInfo, family_name::{FamilyName, FamilyNameMap}, generic::GenericFamilyMap, - scan, FallbackKey, FamilyId, FamilyInfo, FontInfo, GenericFamily, Script, SourceInfo, + scan, }; #[cfg(feature = "std")] diff --git a/fontique/src/collection/mod.rs b/fontique/src/collection/mod.rs index cd04c692..402d6026 100644 --- a/fontique/src/collection/mod.rs +++ b/fontique/src/collection/mod.rs @@ -10,6 +10,7 @@ pub use query::{Query, QueryFamily, QueryFont, QueryStatus}; use super::SourceCache; use super::{ + Blob, GenericFamily, Script, backend::SystemFonts, fallback::{FallbackKey, FallbackMap}, family::{FamilyId, FamilyInfo}, @@ -17,14 +18,13 @@ use super::{ font::FontInfo, generic::GenericFamilyMap, source::{SourceId, SourceInfo, SourceKind}, - Blob, GenericFamily, Script, }; use alloc::{string::String, sync::Arc, vec::Vec}; use core::sync::atomic::AtomicU64; use hashbrown::HashMap; use read_fonts::types::NameId; #[cfg(feature = "std")] -use std::sync::{atomic::Ordering, Mutex}; +use std::sync::{Mutex, atomic::Ordering}; type FamilyMap = HashMap>; @@ -85,7 +85,7 @@ impl Collection { /// /// If `fontique` was compiled with the `"system"` feature, then it will /// include system fonts after the registered fonts. - pub fn family_names(&mut self) -> impl Iterator + '_ + Clone { + pub fn family_names(&mut self) -> impl Iterator + Clone { self.inner.family_names() } @@ -114,7 +114,7 @@ impl Collection { pub fn generic_families( &mut self, family: GenericFamily, - ) -> impl Iterator + '_ + Clone { + ) -> impl Iterator + Clone { self.inner.generic_families(family) } @@ -142,7 +142,7 @@ impl Collection { pub fn fallback_families( &mut self, key: impl Into, - ) -> impl Iterator + '_ + Clone { + ) -> impl Iterator + Clone { self.inner.fallback_families(key) } @@ -214,7 +214,7 @@ impl Inner { /// Returns an iterator over all available family names in the collection. /// /// This includes both system and registered fonts. - pub fn family_names(&mut self) -> impl Iterator + '_ + Clone { + pub fn family_names(&mut self) -> impl Iterator + Clone { self.sync_shared(); FamilyNames { ours: self.data.family_names.iter(), @@ -286,7 +286,7 @@ impl Inner { pub fn generic_families( &mut self, family: GenericFamily, - ) -> impl Iterator + '_ + Clone { + ) -> impl Iterator + Clone { self.sync_shared(); GenericFamilies { ours: self.data.generic_families.get(family).iter().copied(), @@ -349,7 +349,7 @@ impl Inner { pub fn fallback_families( &mut self, key: impl Into, - ) -> impl Iterator + '_ + Clone { + ) -> impl Iterator + Clone { let selector = key.into(); let script = selector.script(); let lang_key = selector.locale(); diff --git a/fontique/src/font.rs b/fontique/src/font.rs index 7219286c..28369e82 100644 --- a/fontique/src/font.rs +++ b/fontique/src/font.rs @@ -5,8 +5,8 @@ use super::attributes::{FontStyle, FontWeight, FontWidth}; use super::source::{SourceInfo, SourceKind}; -use super::{source_cache::SourceCache, Blob}; -use read_fonts::{types::Tag, FontRef, TableProvider as _}; +use super::{Blob, source_cache::SourceCache}; +use read_fonts::{FontRef, TableProvider as _, types::Tag}; use smallvec::SmallVec; type AxisVec = SmallVec<[AxisInfo; 1]>; @@ -337,12 +337,12 @@ impl Synthesis { fn read_attributes(font: &FontRef<'_>) -> (FontWidth, FontStyle, FontWeight) { use read_fonts::{ + TableProvider, tables::{ head::{Head, MacStyle}, os2::{Os2, SelectionFlags}, post::Post, }, - TableProvider, }; fn width_from_width_class(width_class: u16) -> FontWidth { diff --git a/fontique/src/generic.rs b/fontique/src/generic.rs index c8c6608f..dc06bd5c 100644 --- a/fontique/src/generic.rs +++ b/fontique/src/generic.rs @@ -4,7 +4,7 @@ //! Generic font families. use super::FamilyId; -use bytemuck::{checked::CheckedBitPattern, Contiguous, NoUninit, Zeroable}; +use bytemuck::{Contiguous, NoUninit, Zeroable, checked::CheckedBitPattern}; use core::fmt; use smallvec::SmallVec; @@ -178,7 +178,7 @@ impl GenericFamilyMap { #[cfg(test)] mod tests { use crate::GenericFamily; - use bytemuck::{checked::try_from_bytes, Contiguous, Zeroable}; + use bytemuck::{Contiguous, Zeroable, checked::try_from_bytes}; use core::ptr; #[test] @@ -214,7 +214,7 @@ mod tests { let mut value = 0; while value <= GenericFamily::MAX_VALUE { // Safety: In a const context, therefore if this makes an invalid GenericFamily, that will be detected. - // When updating the MSRV to 1.82 or later, this can use `&raw const value` instead of the addr_of! + // TODO: use `&raw const value` instead of the addr_of! let it: GenericFamily = unsafe { ptr::read((core::ptr::addr_of!(value)).cast()) }; // Evaluate the enum value to ensure it actually has a valid tag if it as u8 != value { @@ -239,7 +239,7 @@ mod doctests { /// let value = GenericFamily::MAX_VALUE + 1; /// // Safety: In a const context, therefore if this makes an invalid GenericFamily, that will be detected. /// // (Indeed, we rely upon that) - /// // When updating the MSRV to 1.82 or later, this can use `&raw const value` instead of the addr_of! + /// // TODO: use `&raw const value` instead of the addr_of! /// let it: GenericFamily = unsafe { core::ptr::read((core::ptr::addr_of!(value)).cast()) }; /// // Evaluate the enum value to ensure it actually has an invalid tag /// if it as u8 != value { diff --git a/fontique/src/scan.rs b/fontique/src/scan.rs index 080643ef..46625e65 100644 --- a/fontique/src/scan.rs +++ b/fontique/src/scan.rs @@ -12,7 +12,7 @@ use super::{ }; use alloc::string::String; use hashbrown::HashMap; -use read_fonts::{tables::name, types::NameId, FileRef, FontRef, TableProvider as _}; +use read_fonts::{FileRef, FontRef, TableProvider as _, tables::name, types::NameId}; use smallvec::SmallVec; #[cfg(feature = "std")] use {super::source::SourcePathMap, std::path::Path}; diff --git a/fontique/src/script.rs b/fontique/src/script.rs index cab4dabd..d30e9091 100644 --- a/fontique/src/script.rs +++ b/fontique/src/script.rs @@ -97,11 +97,17 @@ pub const SCRIPT_SAMPLES: &[(Script, &str)] = &[ (Script(*b"Adlm"), "𞤀𞤁𞤂𞤃𞤄𞤅𞤆𞤇𞤈𞤉𞤊𞤋𞤌𞤍𞤎𞤏"), (Script(*b"Aghb"), "𐔰𐔱𐔲𐔳𐔴𐔵𐔶𐔷𐔸𐔹𐔺𐔻𐔼𐔽𐔾𐔿"), (Script(*b"Ahom"), "𑜀𑜁𑜂𑜃𑜄𑜅𑜆𑜇𑜈𑜉𑜊𑜋𑜌𑜍𑜎𑜏"), - (Script(*b"Arab"), "\u{600}\u{601}\u{602}\u{603}\u{604}؆؇؈؉؊؋؍؎؏\u{610}\u{611}"), + ( + Script(*b"Arab"), + "\u{600}\u{601}\u{602}\u{603}\u{604}؆؇؈؉؊؋؍؎؏\u{610}\u{611}", + ), (Script(*b"Armi"), "𐡀𐡁𐡂𐡃𐡄𐡅𐡆𐡇𐡈𐡉𐡊𐡋𐡌𐡍𐡎𐡏"), (Script(*b"Armn"), "ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀ"), (Script(*b"Avst"), "𐬀𐬁𐬂𐬃𐬄𐬅𐬆𐬇𐬈𐬉𐬊𐬋𐬌𐬍𐬎𐬏"), - (Script(*b"Bali"), "\u{1b00}\u{1b01}\u{1b02}\u{1b03}ᬄᬅᬆᬇᬈᬉᬊᬋᬌᬍᬎᬏ"), + ( + Script(*b"Bali"), + "\u{1b00}\u{1b01}\u{1b02}\u{1b03}ᬄᬅᬆᬇᬈᬉᬊᬋᬌᬍᬎᬏ", + ), (Script(*b"Bamu"), "ꚠꚡꚢꚣꚤꚥꚦꚧꚨꚩꚪꚫꚬꚭꚮꚯ"), (Script(*b"Bass"), "𖫐𖫑𖫒𖫓𖫔𖫕𖫖𖫗𖫘𖫙𖫚𖫛𖫜𖫝𖫞𖫟"), (Script(*b"Batk"), "ᯀᯁᯂᯃᯄᯅᯆᯇᯈᯉᯊᯋᯌᯍᯎᯏ"), @@ -144,7 +150,10 @@ pub const SCRIPT_SAMPLES: &[(Script, &str)] = &[ (Script(*b"Hani"), "今"), (Script(*b"Hano"), "ᜠᜡᜢᜣᜤᜥᜦᜧᜨᜩᜪᜫᜬᜭᜮᜯ"), (Script(*b"Hatr"), "𐣠𐣥𐣢𐣣𐣤𐣼𐣌𐣧𐣨𐣊𐣪𐣍𐣏𐣭𐣎𐣯"), - (Script(*b"Hebr"), "\u{591}\u{592}\u{593}\u{594}\u{595}\u{596}\u{597}\u{598}\u{599}\u{59a}\u{59b}\u{59c}\u{59d}\u{59e}\u{59f}\u{5a0}"), + ( + Script(*b"Hebr"), + "\u{591}\u{592}\u{593}\u{594}\u{595}\u{596}\u{597}\u{598}\u{599}\u{59a}\u{59b}\u{59c}\u{59d}\u{59e}\u{59f}\u{5a0}", + ), (Script(*b"Hira"), "ぁあぃいぅうぇえぉおかがきぎくぐ"), (Script(*b"Hluw"), "𔐀𔐁𔐂𔐃𔐄𔐅𔐆𔐇𔐈𔐉𔐊𔐋𔐌𔐍𔐎𔐏"), (Script(*b"Hmng"), "𖬀𖬁𖬂𖬃𖬄𖬅𖬆𖬇𖬈𖬉𖬊𖬋𖬌𖬍𖬎𖬏"), @@ -155,7 +164,10 @@ pub const SCRIPT_SAMPLES: &[(Script, &str)] = &[ (Script(*b"Kali"), "꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉ꤊꤋꤌꤍꤎꤏ"), (Script(*b"Kana"), "ァアィイゥウェエォオカガキギクグ"), (Script(*b"Kawi"), "\u{11f00}\u{11f01}𑼂𑼃𑼄𑼅𑼆𑼇𑼈𑼉𑼊𑼋𑼌𑼍𑼎𑼏"), - (Script(*b"Khar"), "𐨀\u{10a01}\u{10a02}\u{10a03}\u{10a05}\u{10a06}\u{10a0c}\u{10a0d}\u{10a0e}\u{10a0f}𐨐𐨑𐨒𐨓𐨕𐨖"), + ( + Script(*b"Khar"), + "𐨀\u{10a01}\u{10a02}\u{10a03}\u{10a05}\u{10a06}\u{10a0c}\u{10a0d}\u{10a0e}\u{10a0f}𐨐𐨑𐨒𐨓𐨕𐨖", + ), (Script(*b"Khmr"), "កខគឃងចឆជឈញដឋឌឍណត"), (Script(*b"Khoj"), "𑈀𑈁𑈂𑈃𑈄𑈅𑈆𑈇𑈈𑈉𑈊𑈋𑈌𑈍𑈎𑈏"), (Script(*b"Kits"), "\u{16fe4}𘬀𘬁𘬂𘬃𘬄𘬅𘬆𘬇𘬈𘬉𘬊𘬋𘬌𘬍𘬎"), @@ -182,7 +194,10 @@ pub const SCRIPT_SAMPLES: &[(Script, &str)] = &[ (Script(*b"Mero"), "𐦀𐦁𐦂𐦃𐦄𐦅𐦆𐦇𐦈𐦉𐦊𐦋𐦌𐦍𐦎𐦏"), (Script(*b"Mlym"), "\u{d00}\u{d01}ംഃഄഅആഇഈഉഊഋഌഎഏഐ"), (Script(*b"Modi"), "𑘀𑘁𑘂𑘃𑘄𑘅𑘆𑘇𑘈𑘉𑘊𑘋𑘌𑘍𑘎𑘏"), - (Script(*b"Mong"), "᠀᠁᠄᠆᠇᠈᠉᠊\u{180b}\u{180c}\u{180d}\u{180e}\u{180f}᠐᠑᠒"), + ( + Script(*b"Mong"), + "᠀᠁᠄᠆᠇᠈᠉᠊\u{180b}\u{180c}\u{180d}\u{180e}\u{180f}᠐᠑᠒", + ), (Script(*b"Mroo"), "𖩀𖩁𖩂𖩃𖩄𖩅𖩆𖩇𖩈𖩉𖩊𖩋𖩌𖩍𖩎𖩏"), (Script(*b"Mtei"), "ꍠꍥꍢꍣꍤꍼꍌꍧꍨꍊꍪꍍ\u{aaec}\u{aaed}ꍎꍯ"), (Script(*b"Mult"), "𑊀𑊁𑊂𑊃𑊄𑊅𑊆𑊈𑊊𑊋𑊌𑊍𑊏𑊐𑊑𑊒"), @@ -225,7 +240,10 @@ pub const SCRIPT_SAMPLES: &[(Script, &str)] = &[ (Script(*b"Sogd"), "𐟰𐟹𐟲𐟳𐟴𐟾𐟜𐟡𐟸𐟚𐟺𐟝𐟟𐟽𐟞𐟿"), (Script(*b"Sogo"), "𐼀𐼁𐼂𐼃𐼄𐼅𐼆𐼇𐼈𐼉𐼊𐼋𐼌𐼍𐼎𐼏"), (Script(*b"Sora"), "𑃐𑃑𑃒𑃓𑃔𑃕𑃖𑃗𑃘𑃙𑃚𑃛𑃜𑃝𑃞𑃟"), - (Script(*b"Soyo"), "𑩐\u{11a51}\u{11a52}\u{11a53}\u{11a54}\u{11a55}\u{11a56}𑩗𑩘\u{11a59}\u{11a5a}\u{11a5b}𑩜𑩝𑩞𑩟"), + ( + Script(*b"Soyo"), + "𑩐\u{11a51}\u{11a52}\u{11a53}\u{11a54}\u{11a55}\u{11a56}𑩗𑩘\u{11a59}\u{11a5a}\u{11a5b}𑩜𑩝𑩞𑩟", + ), (Script(*b"Sund"), "\u{1b80}\u{1b81}ᮂᮃᮄᮅᮆᮇᮈᮉᮊᮋᮌᮍᮎᮏ"), (Script(*b"Sylo"), "ꠀꠁ\u{a802}ꠃꠄꠅ\u{a806}ꠇꠈꠉꠊ\u{a80b}ꠌꠍꠎꠏ"), (Script(*b"Syrc"), "܀܁܂܃܄܅܆܇܈܉܊܋܌܍\u{70f}ܐ"), @@ -254,5 +272,8 @@ pub const SCRIPT_SAMPLES: &[(Script, &str)] = &[ (Script(*b"Xsux"), "𒀀𒀁𒀂𒀃𒀄𒀅𒀆𒀇𒀈𒀉𒀊𒀋𒀌𒀍𒀎𒀏"), (Script(*b"Yezi"), "𐺀𐺁𐺂𐺃𐺄𐺅𐺆𐺇𐺈𐺉𐺊𐺋𐺌𐺍𐺎𐺏"), (Script(*b"Yiii"), "ꀀꀁꀂꀃꀄꀅꀆꀇꀈꀉꀊꀋꀌꀍꀎꀏ"), - (Script(*b"Zanb"), "𑨀\u{11a01}\u{11a02}\u{11a03}\u{11a04}\u{11a05}\u{11a06}\u{11a07}\u{11a08}\u{11a09}\u{11a0a}𑨋𑨌𑨍𑨎𑨏"), + ( + Script(*b"Zanb"), + "𑨀\u{11a01}\u{11a02}\u{11a03}\u{11a04}\u{11a05}\u{11a06}\u{11a07}\u{11a08}\u{11a09}\u{11a0a}𑨋𑨌𑨍𑨎𑨏", + ), ]; diff --git a/parley/README.md b/parley/README.md index 81a32eed..79de3c96 100644 --- a/parley/README.md +++ b/parley/README.md @@ -17,7 +17,7 @@ It is backed by [Swash](https://github.com/dfrg/swash). ## Minimum supported Rust Version (MSRV) -This version of Parley has been verified to compile with **Rust 1.82** and later. +This version of Parley has been verified to compile with **Rust 1.85** and later. Future versions of Parley might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. diff --git a/parley/src/bidi.rs b/parley/src/bidi.rs index 0b1ec346..a4c55777 100644 --- a/parley/src/bidi.rs +++ b/parley/src/bidi.rs @@ -5,8 +5,8 @@ use alloc::vec::Vec; -use swash::text::{BidiClass, BracketType, Codepoint as _}; use BidiClass::*; +use swash::text::{BidiClass, BracketType, Codepoint as _}; /// Type alias for a bidirectional level. pub(crate) type BidiLevel = u8; @@ -599,11 +599,7 @@ impl BidiResolver { leading } else { // N2 - if level & 1 != 0 { - R - } else { - L - } + if level & 1 != 0 { R } else { L } }; for j in offset..limit { types[j] = resolved; @@ -643,11 +639,7 @@ impl BidiResolver { /// Returns a default bidi type for a level. pub(crate) fn type_from_level(level: BidiLevel) -> BidiClass { - if level & 1 == 0 { - L - } else { - R - } + if level & 1 == 0 { L } else { R } } /// Computes an ordering for a sequence of bidi runs based on levels. diff --git a/parley/src/builder.rs b/parley/src/builder.rs index 643ae16f..92b7640a 100644 --- a/parley/src/builder.rs +++ b/parley/src/builder.rs @@ -3,9 +3,9 @@ //! Context for layout. +use super::FontContext; use super::context::LayoutContext; use super::style::{Brush, StyleProperty, TextStyle, WhiteSpaceCollapse}; -use super::FontContext; use super::layout::Layout; diff --git a/parley/src/context.rs b/parley/src/context.rs index 2a7fc205..fca379e6 100644 --- a/parley/src/context.rs +++ b/parley/src/context.rs @@ -7,11 +7,11 @@ use alloc::{vec, vec::Vec}; use self::tree::TreeStyleBuilder; +use super::FontContext; use super::bidi; use super::builder::RangedBuilder; -use super::resolve::{tree, RangedStyle, RangedStyleBuilder, ResolveContext, ResolvedStyle}; +use super::resolve::{RangedStyle, RangedStyleBuilder, ResolveContext, ResolvedStyle, tree}; use super::style::{Brush, TextStyle}; -use super::FontContext; use swash::shape::ShapeContext; use swash::text::cluster::CharInfo; diff --git a/parley/src/layout/alignment.rs b/parley/src/layout/alignment.rs index 50c91525..aa99427b 100644 --- a/parley/src/layout/alignment.rs +++ b/parley/src/layout/alignment.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use super::{ - data::{ClusterData, LineItemData}, Alignment, BreakReason, LayoutData, + data::{ClusterData, LineItemData}, }; use crate::style::Brush; diff --git a/parley/src/layout/cluster.rs b/parley/src/layout/cluster.rs index c376bc4e..638967a5 100644 --- a/parley/src/layout/cluster.rs +++ b/parley/src/layout/cluster.rs @@ -157,7 +157,7 @@ impl<'a, B: Brush> Cluster<'a, B> { } /// Returns an iterator over the glyphs in the cluster. - pub fn glyphs(&self) -> impl Iterator + 'a + Clone { + pub fn glyphs(&self) -> impl Iterator + Clone + use<'a, B> { if self.data.glyph_len == 0xFF { GlyphIter::Single(Some(Glyph { id: self.data.glyph_offset, diff --git a/parley/src/layout/data.rs b/parley/src/layout/data.rs index 4f80c5ef..04793d2e 100644 --- a/parley/src/layout/data.rs +++ b/parley/src/layout/data.rs @@ -1,16 +1,16 @@ // Copyright 2021 the Parley Authors // SPDX-License-Identifier: Apache-2.0 OR MIT +use crate::Font; use crate::inline_box::InlineBox; use crate::layout::{ContentWidths, Glyph, LineMetrics, RunMetrics, Style}; use crate::style::Brush; use crate::util::nearly_zero; -use crate::Font; use core::cell::OnceCell; use core::ops::Range; +use swash::Synthesis; use swash::shape::Shaper; use swash::text::cluster::{Boundary, ClusterInfo}; -use swash::Synthesis; use alloc::vec::Vec; diff --git a/parley/src/layout/editor.rs b/parley/src/layout/editor.rs index 63021995..bd7e5dce 100644 --- a/parley/src/layout/editor.rs +++ b/parley/src/layout/editor.rs @@ -4,13 +4,13 @@ //! A simple plain text editor and related types. use crate::{ + FontContext, LayoutContext, Rect, StyleProperty, StyleSet, layout::{ - cursor::{Cursor, Selection}, Affinity, Alignment, AlignmentOptions, Layout, + cursor::{Cursor, Selection}, }, resolve::ResolvedStyle, style::Brush, - FontContext, LayoutContext, Rect, StyleProperty, StyleSet, }; use alloc::{borrow::ToOwned, string::String, vec::Vec}; use core::{ @@ -51,7 +51,7 @@ pub struct SplitString<'source>([&'source str; 2]); impl<'source> SplitString<'source> { /// Get the characters of this string. - pub fn chars(self) -> impl Iterator + 'source { + pub fn chars(self) -> impl Iterator + use<'source> { self.into_iter().flat_map(str::chars) } } diff --git a/parley/src/layout/line/mod.rs b/parley/src/layout/line/mod.rs index 5c7ea96f..ab4e58dc 100644 --- a/parley/src/layout/line/mod.rs +++ b/parley/src/layout/line/mod.rs @@ -64,7 +64,7 @@ impl<'a, B: Brush> Line<'a, B> { /// Returns an iterator over the runs for the line. // TODO: provide iterator over inline_boxes and items - pub fn runs(&self) -> impl Iterator> + 'a + Clone { + pub fn runs(&self) -> impl Iterator> + Clone { let copy = self.clone(); let line_items = ©.layout.data.line_items[self.data.item_range.clone()]; line_items @@ -81,7 +81,7 @@ impl<'a, B: Brush> Line<'a, B> { } /// Returns an iterator over the glyph runs for the line. - pub fn items(&self) -> impl Iterator> + 'a + Clone { + pub fn items(&self) -> impl Iterator> + Clone { GlyphRunIter { line: self.clone(), item_index: 0, @@ -186,7 +186,7 @@ impl<'a, B: Brush> GlyphRun<'a, B> { } /// Returns an iterator over the glyphs in the run. - pub fn glyphs(&'a self) -> impl Iterator + 'a + Clone { + pub fn glyphs(&'a self) -> impl Iterator + Clone { self.run .visual_clusters() .flat_map(|cluster| cluster.glyphs()) @@ -195,7 +195,7 @@ impl<'a, B: Brush> GlyphRun<'a, B> { } /// Returns an iterator over the fully positioned glyphs in the run. - pub fn positioned_glyphs(&'a self) -> impl Iterator + 'a + Clone { + pub fn positioned_glyphs(&'a self) -> impl Iterator + Clone { let mut offset = self.offset; let baseline = self.baseline; self.glyphs().map(move |mut g| { diff --git a/parley/src/layout/mod.rs b/parley/src/layout/mod.rs index 7ab63316..27e16a36 100644 --- a/parley/src/layout/mod.rs +++ b/parley/src/layout/mod.rs @@ -152,7 +152,7 @@ impl Layout { } /// Returns an iterator over the lines in the layout. - pub fn lines(&self) -> impl Iterator> + '_ + Clone { + pub fn lines(&self) -> impl Iterator> + Clone { self.data .lines .iter() diff --git a/parley/src/layout/run.rs b/parley/src/layout/run.rs index 601f6634..0f8e4ad3 100644 --- a/parley/src/layout/run.rs +++ b/parley/src/layout/run.rs @@ -112,7 +112,7 @@ impl<'a, B: Brush> Run<'a, B> { } /// Returns an iterator over the clusters in logical order. - pub fn clusters(&'a self) -> impl Iterator> + 'a + Clone { + pub fn clusters(&'a self) -> impl Iterator> + Clone { let range = self.cluster_range(); Clusters { run: self, diff --git a/parley/src/lib.rs b/parley/src/lib.rs index 42a6fc74..2964d984 100644 --- a/parley/src/lib.rs +++ b/parley/src/lib.rs @@ -120,8 +120,8 @@ pub mod style; #[cfg(test)] mod tests; -pub use peniko::kurbo::Rect; pub use peniko::Font; +pub use peniko::kurbo::Rect; pub use builder::{RangedBuilder, TreeBuilder}; pub use context::LayoutContext; diff --git a/parley/src/shape.rs b/parley/src/shape.rs index 4b6a77dc..6c99e3cd 100644 --- a/parley/src/shape.rs +++ b/parley/src/shape.rs @@ -4,11 +4,11 @@ use super::layout::Layout; use super::resolve::{RangedStyle, ResolveContext, Resolved}; use super::style::{Brush, FontFeature, FontVariation}; -use crate::util::nearly_eq; use crate::Font; +use crate::util::nearly_eq; use fontique::QueryFamily; use fontique::{self, Query, QueryFont}; -use swash::shape::{partition, Direction, ShapeContext}; +use swash::shape::{Direction, ShapeContext, partition}; use swash::text::cluster::{CharCluster, CharInfo, Token}; use swash::text::{Language, Script}; use swash::{FontRef, Synthesis}; diff --git a/parley/src/style/font.rs b/parley/src/style/font.rs index 90ac1180..b01d1e12 100644 --- a/parley/src/style/font.rs +++ b/parley/src/style/font.rs @@ -74,7 +74,7 @@ impl<'a> FontFamily<'a> { /// /// assert_eq!(parsed_families, families); /// ``` - pub fn parse_list(s: &'a str) -> impl Iterator> + 'a + Clone { + pub fn parse_list(s: &'a str) -> impl Iterator> + Clone { ParseList { source: s.as_bytes(), len: s.len(), diff --git a/parley/src/tests/test_basic.rs b/parley/src/tests/test_basic.rs index bdd671af..6ab80594 100644 --- a/parley/src/tests/test_basic.rs +++ b/parley/src/tests/test_basic.rs @@ -3,7 +3,7 @@ use peniko::kurbo::Size; -use crate::{testenv, Alignment, AlignmentOptions, InlineBox, WhiteSpaceCollapse}; +use crate::{Alignment, AlignmentOptions, InlineBox, WhiteSpaceCollapse, testenv}; #[test] fn plain_multiline_text() { diff --git a/parley/src/tests/utils/cursor_test.rs b/parley/src/tests/utils/cursor_test.rs index bde3087a..d1a16d48 100644 --- a/parley/src/tests/utils/cursor_test.rs +++ b/parley/src/tests/utils/cursor_test.rs @@ -3,7 +3,7 @@ use tiny_skia::{Color, Pixmap, PixmapPaint, Transform}; -use crate::tests::utils::renderer::{render_layout, ColorBrush, RenderingConfig}; +use crate::tests::utils::renderer::{ColorBrush, RenderingConfig, render_layout}; use crate::{Affinity, Cursor, FontContext, Layout, LayoutContext}; // Note: This module is only compiled when running tests, which requires std, diff --git a/parley/src/tests/utils/env.rs b/parley/src/tests/utils/env.rs index 549243a9..3049f861 100644 --- a/parley/src/tests/utils/env.rs +++ b/parley/src/tests/utils/env.rs @@ -1,7 +1,7 @@ // Copyright 2024 the Parley Authors // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::tests::utils::renderer::{render_layout, ColorBrush, RenderingConfig}; +use crate::tests::utils::renderer::{ColorBrush, RenderingConfig, render_layout}; use crate::{ FontContext, FontFamily, FontStack, Layout, LayoutContext, PlainEditor, PlainEditorDriver, RangedBuilder, Rect, StyleProperty, TextStyle, TreeBuilder, @@ -213,9 +213,11 @@ impl TestEnv { self.check_counter += 1; name } else { - assert!(test_case_name - .chars() - .all(|c| c == '_' || char::is_alphanumeric(c))); + assert!( + test_case_name + .chars() + .all(|c| c == '_' || char::is_alphanumeric(c)) + ); format!("{}-{}.png", self.test_name, test_case_name) } } diff --git a/parley/src/tests/utils/renderer.rs b/parley/src/tests/utils/renderer.rs index 63be234a..4571b207 100644 --- a/parley/src/tests/utils/renderer.rs +++ b/parley/src/tests/utils/renderer.rs @@ -10,10 +10,10 @@ use crate::{GlyphRun, Layout, PositionedLayoutItem}; use peniko::kurbo; use skrifa::{ + GlyphId, MetadataProvider, OutlineGlyph, instance::{LocationRef, NormalizedCoord, Size}, outline::{DrawSettings, OutlinePen}, raw::FontRef as ReadFontsRef, - GlyphId, MetadataProvider, OutlineGlyph, }; use tiny_skia::{Color, FillRule, Paint, PathBuilder, Pixmap, PixmapMut, Rect, Transform};