fribidi

Crates.iofribidi
lib.rsfribidi
version0.1.2
sourcesrc
created_at2023-02-12 20:12:40.315946
updated_at2023-02-13 06:30:27.49197
descriptionfribidi bindings for Rust
homepage
repositoryhttps://github.com/rust-fribidi/rust-fribidi
max_upload_size
id783461
size39,188
Mohamed A. Elmeligy (baronleonardo)

documentation

https://docs.rs/fribidi/latest/fribidi

README

rust-fribidi

Rust binding for fribidi library (Unicode bidirectional and Arabic joining/shaping algorithms).

example

let text = U32String::from("چرمهين");

let gt = U32String::from("ﻦﻴﻬﻣﺮﭼ");
let gt_maximum_level = 2;
let gt_positions_logic_to_visual = vec![5, 4, 3, 2, 1, 0];
let gt_positions_visual_to_logic = vec![5, 4, 3, 2, 1, 0];
let gt_embedding_levels = vec![LevelType(1); 6];

let mut positions_logic_to_visual :Vec<i32> = vec![1; text.len()];
let mut positions_visual_to_logic :Vec<i32> = vec![1; text.len()];
let mut embedding_levels: Vec<LevelType> = vec![LevelType(1); text.len()];

let (res, maximum_level) = Fribidi::logic_to_visual(
    &text,
    ParagraphType::OtherNeutral,    // let fribidi detect the type
    Some(&mut positions_logic_to_visual),
    Some(&mut positions_visual_to_logic),
    Some(&mut embedding_levels)
).unwrap();

assert_eq!((res, maximum_level), (gt, gt_maximum_level));
assert_eq!(positions_logic_to_visual, gt_positions_logic_to_visual);
assert_eq!(positions_visual_to_logic, gt_positions_visual_to_logic);
assert_eq!(embedding_levels, gt_embedding_levels);

NOTE

  • fribidi library is under LGPL license.
  • this library is under MIT license.
Commit count: 32

cargo fmt