Skip to content

Commit

Permalink
Add HarfBuzz example (#3237)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Apr 14, 2023
1 parent c18a4b6 commit 59e370f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions experimental/harfbuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ icu_provider = { version = "1.0.0", path = "../../provider/core", features = ["m
displaydoc = { version = "0.2.3", default-features = false }
tinystr = { version = "0.7.1", path = "../../utils/tinystr", default-features = false }

[dev-dependencies]
icu_testdata = { path = "../../provider/testdata" }
harfbuzz = { version = "0.4.0" }

[features]
default = []
# TODO(#3275) Make this no_std again
Expand Down
21 changes: 21 additions & 0 deletions experimental/harfbuzz/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions experimental/harfbuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@
#![warn(missing_docs)]

//! Using ICU4X as the Unicode Database back end for HarfBuzz.
//!
//! # Examples
//!
//! ```
//! use harfbuzz::{Buffer, Direction, sys};
//! use icu_harfbuzz::new_hb_unicode_funcs_unstable;
//!
//! let mut b = Buffer::with("مساء الخير");
//!
//! let unicode_funcs = new_hb_unicode_funcs_unstable(&icu_testdata::unstable()).unwrap();
//!
//! // NOTE: This currently requires `unsafe` code. For progress toward a safe abstraction, see:
//! // <https://github.com/servo/rust-harfbuzz/pull/197>
//! unsafe {
//! harfbuzz::sys::hb_buffer_set_unicode_funcs(b.as_ptr(), unicode_funcs.as_ptr());
//! }
//!
//! b.guess_segment_properties();
//! assert_eq!(b.get_direction(), Direction::RTL);
//! assert_eq!(b.get_script(), sys::HB_SCRIPT_ARABIC);
//! ```

extern crate alloc;
mod error;
Expand Down

0 comments on commit 59e370f

Please sign in to comment.