0.11.2: Fix glyph start and end when using shape-run-cache

This commit is contained in:
Jeremy Soller 2024-02-09 15:12:33 -07:00
parent cb447ea8c6
commit 0cb6eba6e7
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
3 changed files with 18 additions and 3 deletions

View file

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.11.2] - 2024-02-08
### Fixed
- Fix glyph start and end when using `shape-run-cache`
## [0.11.1] - 2024-02-08 ## [0.11.1] - 2024-02-08
### Added ### Added

View file

@ -1,7 +1,7 @@
[package] [package]
name = "cosmic-text" name = "cosmic-text"
description = "Pure Rust multi-line text handling" description = "Pure Rust multi-line text handling"
version = "0.11.1" version = "0.11.2"
authors = ["Jeremy Soller <jeremy@system76.com>"] authors = ["Jeremy Soller <jeremy@system76.com>"]
edition = "2021" edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View file

@ -382,8 +382,12 @@ fn shape_run_cached(
} }
} }
if let Some(cache_glyphs) = font_system.shape_run_cache.get(&key) { if let Some(cache_glyphs) = font_system.shape_run_cache.get(&key) {
// Use cached glyphs for mut glyph in cache_glyphs.iter().cloned() {
glyphs.extend_from_slice(&cache_glyphs); // Adjust glyph start and end to match run position
glyph.start += start_run;
glyph.end += start_run;
glyphs.push(glyph);
}
return; return;
} }
@ -400,6 +404,11 @@ fn shape_run_cached(
span_rtl, span_rtl,
); );
glyphs.extend_from_slice(&cache_glyphs); glyphs.extend_from_slice(&cache_glyphs);
for glyph in cache_glyphs.iter_mut() {
// Adjust glyph start and end to remove run position
glyph.start -= start_run;
glyph.end -= start_run;
}
font_system.shape_run_cache.insert(key, cache_glyphs); font_system.shape_run_cache.insert(key, cache_glyphs);
} }