Skip to content

Commit

Permalink
0.11.2: Fix glyph start and end when using shape-run-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Feb 9, 2024
1 parent cb447ea commit 0cb6eba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/),
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

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cosmic-text"
description = "Pure Rust multi-line text handling"
version = "0.11.1"
version = "0.11.2"
authors = ["Jeremy Soller <jeremy@system76.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
13 changes: 11 additions & 2 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,12 @@ fn shape_run_cached(
}
}
if let Some(cache_glyphs) = font_system.shape_run_cache.get(&key) {
// Use cached glyphs
glyphs.extend_from_slice(&cache_glyphs);
for mut glyph in cache_glyphs.iter().cloned() {
// Adjust glyph start and end to match run position
glyph.start += start_run;
glyph.end += start_run;
glyphs.push(glyph);
}
return;
}

Expand All @@ -400,6 +404,11 @@ fn shape_run_cached(
span_rtl,
);
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);
}

Expand Down

0 comments on commit 0cb6eba

Please sign in to comment.