From 80685574682b901b529c31df388ce632f794ecae Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 4 Oct 2022 15:14:21 -0600 Subject: [PATCH] Fix indexing for RTL --- examples/text/src/main.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/text/src/main.rs b/examples/text/src/main.rs index 403eeee9..d22ad9c9 100644 --- a/examples/text/src/main.rs +++ b/examples/text/src/main.rs @@ -190,10 +190,19 @@ impl<'a> FontMatches<'a> { } // Adjust end of glyphs - for i in (1..glyphs.len()).rev() { - if glyphs[i - 1].start == glyphs[i].start { - glyphs[i - 1].end = glyphs[i].end; - } + match direction { + rustybuzz::Direction::LeftToRight => { + for i in 1..glyphs.len() { + glyphs[i - 1].end = glyphs[i].start; + } + }, + rustybuzz::Direction::RightToLeft => { + for i in 1..glyphs.len() { + glyphs[i].end = glyphs[i - 1].start; + } + }, + //TODO: other directions + _ => (), } let span = FontShapeSpan {