From 0cb6eba6e708e2743313ee0016162de7a0146353 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 9 Feb 2024 15:12:33 -0700 Subject: [PATCH] 0.11.2: Fix glyph start and end when using `shape-run-cache` --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- src/shape.rs | 13 +++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b79da96808..0067d514cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Cargo.toml b/Cargo.toml index d27b165e45..bfc6d97ff7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/src/shape.rs b/src/shape.rs index 4db2d63505..c4b8504c25 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -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; } @@ -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); }