Skip to content

Commit

Permalink
Fix RTL text handling (#133)
Browse files Browse the repository at this point in the history
Closes #132
  • Loading branch information
LaurenzV authored Sep 12, 2024
1 parent f5a23d3 commit 71e33a0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/hb/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,9 @@ impl hb_buffer_t {
}

let mut start = 0;
let mut i = 1;

for i in 1..self.len {
while i < self.len {
if !group(&self.info[i - 1], &self.info[i]) {
if merge_clusters {
self.merge_clusters(start, i);
Expand All @@ -593,14 +594,16 @@ impl hb_buffer_t {
start = i;
}

if merge_clusters {
self.merge_clusters(start, i);
}

self.reverse_range(start, i);
i += 1;
}

self.reverse();
if merge_clusters {
self.merge_clusters(start, i);
}

self.reverse_range(start, i);

self.reverse();
}

pub fn group_end<F>(&self, mut start: usize, group: F) -> usize
Expand Down
2 changes: 1 addition & 1 deletion src/hb/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ mod tests {
fn check_unicode_version() {
assert_eq!(unicode_bidi_mirroring::UNICODE_VERSION, (15, 1, 0));
assert_eq!(unicode_ccc::UNICODE_VERSION, (15, 0, 0));
assert_eq!(unicode_properties::UNICODE_VERSION, (15, 0, 0));
assert_eq!(unicode_properties::UNICODE_VERSION, (15, 1, 0));
assert_eq!(unicode_script::UNICODE_VERSION, (15, 1, 0));
assert_eq!(crate::hb::unicode_norm::UNICODE_VERSION, (15, 0, 0));
}
Expand Down
1 change: 1 addition & 0 deletions tests/custom/bugs.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/fonts/rb_custom/NotoSansCJK.subset1.otf;--direction rtl;U+4F60,U+597D,U+FF0C;
Binary file added tests/fonts/rb_custom/NotoSansCJK.subset1.otf
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/shaping/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

use crate::shape;

#[test]
fn bugs_001() {
assert_eq!(
shape(
"tests/fonts/rb_custom/NotoSansCJK.subset1.otf",
"\u{4F60}\u{597D}\u{FF0C}",
"--direction rtl",
),
"gid6=2+1000|\
gid3=1+1000|\
gid1=0+1000"
);
}

#[test]
fn fuzzer_001() {
assert_eq!(
Expand Down
3 changes: 1 addition & 2 deletions tests/shaping/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ fn macos_121() {

#[cfg(target_os = "macos")]
#[test]
fn macos_122() {
fn macos_123() {
assert_eq!(
shape(
"/System/Library/Fonts/Supplemental/Malayalam MN.ttc",
Expand All @@ -2359,4 +2359,3 @@ fn macos_122() {
C=2+1589"
);
}

2 changes: 1 addition & 1 deletion tests/shaping/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod custom;
mod in_house;
mod macos;
mod text_rendering_tests;
#[cfg(feature="wasm-shaper")]
#[cfg(feature = "wasm-shaper")]
mod wasm;

use std::str::FromStr;
Expand Down

0 comments on commit 71e33a0

Please sign in to comment.