Update cosmic-text to 0.12.1

This commit is contained in:
Joscha 2025-02-22 16:13:03 +01:00
parent 772fcb69eb
commit e9ed7d6eaa
3 changed files with 55 additions and 19 deletions

62
Cargo.lock generated
View file

@ -546,21 +546,21 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-text" name = "cosmic-text"
version = "0.11.2" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c578f2b9abb4d5f3fbb12aba4008084d435dc6a8425c195cfe0b3594bfea0c25" checksum = "59fd57d82eb4bfe7ffa9b1cec0c05e2fd378155b47f255a67983cb4afe0e80c2"
dependencies = [ dependencies = [
"bitflags 2.8.0", "bitflags 2.8.0",
"fontdb", "fontdb",
"libm",
"log", "log",
"rangemap", "rangemap",
"rayon",
"rustc-hash", "rustc-hash",
"rustybuzz", "rustybuzz 0.14.1",
"self_cell", "self_cell",
"swash", "swash",
"sys-locale", "sys-locale",
"ttf-parser", "ttf-parser 0.21.1",
"unicode-bidi", "unicode-bidi",
"unicode-linebreak", "unicode-linebreak",
"unicode-script", "unicode-script",
@ -853,7 +853,7 @@ dependencies = [
"memmap2", "memmap2",
"slotmap", "slotmap",
"tinyvec", "tinyvec",
"ttf-parser", "ttf-parser 0.20.0",
] ]
[[package]] [[package]]
@ -1844,7 +1844,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e0f8ad4c197db38125b880c3c44544788665c7d5f4c42f5a35da44bca1a712" checksum = "e2e0f8ad4c197db38125b880c3c44544788665c7d5f4c42f5a35da44bca1a712"
dependencies = [ dependencies = [
"ttf-parser", "ttf-parser 0.20.0",
] ]
[[package]] [[package]]
@ -2247,14 +2247,30 @@ name = "rustybuzz"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0ae5692c5beaad6a9e22830deeed7874eae8a4e3ba4076fb48e12c56856222c" checksum = "f0ae5692c5beaad6a9e22830deeed7874eae8a4e3ba4076fb48e12c56856222c"
dependencies = [
"bitflags 2.8.0",
"bytemuck",
"smallvec",
"ttf-parser 0.20.0",
"unicode-bidi-mirroring 0.1.0",
"unicode-ccc 0.1.2",
"unicode-properties",
"unicode-script",
]
[[package]]
name = "rustybuzz"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfb9cf8877777222e4a3bc7eb247e398b56baba500c38c1c46842431adc8b55c"
dependencies = [ dependencies = [
"bitflags 2.8.0", "bitflags 2.8.0",
"bytemuck", "bytemuck",
"libm", "libm",
"smallvec", "smallvec",
"ttf-parser", "ttf-parser 0.21.1",
"unicode-bidi-mirroring", "unicode-bidi-mirroring 0.2.0",
"unicode-ccc", "unicode-ccc 0.2.0",
"unicode-properties", "unicode-properties",
"unicode-script", "unicode-script",
] ]
@ -2907,6 +2923,12 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]]
name = "ttf-parser"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8"
[[package]] [[package]]
name = "two-face" name = "two-face"
version = "0.3.0" version = "0.3.0"
@ -2967,7 +2989,7 @@ dependencies = [
"rayon", "rayon",
"regex", "regex",
"roxmltree 0.19.0", "roxmltree 0.19.0",
"rustybuzz", "rustybuzz 0.12.1",
"serde", "serde",
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
@ -2977,7 +2999,7 @@ dependencies = [
"syntect", "syntect",
"time", "time",
"toml", "toml",
"ttf-parser", "ttf-parser 0.20.0",
"two-face", "two-face",
"typed-arena", "typed-arena",
"typst-assets", "typst-assets",
@ -3024,7 +3046,7 @@ dependencies = [
"resvg", "resvg",
"roxmltree 0.19.0", "roxmltree 0.19.0",
"tiny-skia", "tiny-skia",
"ttf-parser", "ttf-parser 0.20.0",
"typst", "typst",
"typst-macros", "typst-macros",
"typst-timing", "typst-timing",
@ -3097,12 +3119,24 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56d12260fb92d52f9008be7e4bca09f584780eb2266dc8fecc6a192bec561694" checksum = "56d12260fb92d52f9008be7e4bca09f584780eb2266dc8fecc6a192bec561694"
[[package]]
name = "unicode-bidi-mirroring"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23cb788ffebc92c5948d0e997106233eeb1d8b9512f93f41651f52b6c5f5af86"
[[package]] [[package]]
name = "unicode-ccc" name = "unicode-ccc"
version = "0.1.2" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1" checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1"
[[package]]
name = "unicode-ccc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df77b101bcc4ea3d78dafc5ad7e4f58ceffe0b2b16bf446aeb50b6cb4157656"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.17" version = "1.0.17"
@ -3220,7 +3254,7 @@ dependencies = [
"fontdb", "fontdb",
"kurbo", "kurbo",
"log", "log",
"rustybuzz", "rustybuzz 0.12.1",
"unicode-bidi", "unicode-bidi",
"unicode-script", "unicode-script",
"unicode-vo", "unicode-vo",

View file

@ -11,7 +11,7 @@ anyhow = "1.0.96"
axum = "0.8.1" axum = "0.8.1"
clap = { version = "4.5.30", features = ["derive", "deprecated"] } clap = { version = "4.5.30", features = ["derive", "deprecated"] }
comemo = "0.4.0" comemo = "0.4.0"
cosmic-text = "0.11.2" cosmic-text = "0.12.1"
escpos = "0.12.2" escpos = "0.12.2"
image = "0.25.1" image = "0.25.1"
mark.git = "https://github.com/Garmelon/mark.git" mark.git = "https://github.com/Garmelon/mark.git"

View file

@ -121,7 +121,7 @@ impl Text {
pub fn widget<C: HasFontStuff>(self, font_stuff: &mut FontStuff) -> impl Widget<C> + use<C> { pub fn widget<C: HasFontStuff>(self, font_stuff: &mut FontStuff) -> impl Widget<C> + use<C> {
let fs = &mut font_stuff.font_system; let fs = &mut font_stuff.font_system;
let mut buffer = Buffer::new_empty(self.metrics); let mut buffer = Buffer::new_empty(self.metrics);
buffer.set_size(fs, f32::INFINITY, f32::INFINITY); buffer.set_size(fs, None, None);
let spans = self let spans = self
.chunks .chunks
@ -161,12 +161,13 @@ impl<C: HasFontStuff> Widget<C> for TextWidget {
}); });
let fs = &mut ctx.font_stuff().font_system; let fs = &mut ctx.font_stuff().font_system;
self.buffer.set_size(fs, width, f32::INFINITY); self.buffer.set_size(fs, Some(width), None);
self.buffer.shape_until_scroll(fs, false); self.buffer.shape_until_scroll(fs, false);
let runs = self.buffer.layout_runs(); let runs = self.buffer.layout_runs().collect::<Vec<_>>();
let height = runs.len() as f32 * self.buffer.metrics().line_height; let height = runs.len() as f32 * self.buffer.metrics().line_height;
let width = runs let width = runs
.into_iter()
.map(|run| run.line_w) .map(|run| run.line_w)
.max_by(|a, b| a.partial_cmp(b).unwrap()) .max_by(|a, b| a.partial_cmp(b).unwrap())
.unwrap_or(0.0); .unwrap_or(0.0);
@ -193,7 +194,8 @@ impl<C: HasFontStuff> Widget<C> for TextWidget {
swash_cache: sc, swash_cache: sc,
} = ctx.font_stuff(); } = ctx.font_stuff();
self.buffer.set_size(fs, size.x as f32, size.y as f32); self.buffer
.set_size(fs, Some(size.x as f32), Some(size.y as f32));
self.buffer.shape_until_scroll(fs, true); self.buffer.shape_until_scroll(fs, true);
let color = color::to_text_color(self.color); let color = color::to_text_color(self.color);