Skip to content

Commit

Permalink
Change CombiningClassFunc to return a u8
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Aug 24, 2023
1 parent 6868c97 commit 39af919
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions harfbuzz/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ pub trait GeneralCategoryFunc {

/// An object to map from code points to combining classes.
pub trait CombiningClassFunc {
/// Given a code point, return the combining class as a
/// [`hb_unicode_combining_class_t`].
fn combining_class(&self, ch: u32) -> core::ffi::c_uint;
/// Given a code point, return the combining class as a `u8` corresponding to a
/// [`hb_unicode_combining_class_t`]. Note that the
/// [Unicode stability policy](https://www.unicode.org/policies/stability_policy.html)
/// guarantees that Canonical Combining Class numeric values fit in a `u8`.
fn combining_class(&self, ch: u32) -> u8;
}

/// An object to map from code points to mirrored code points.
Expand Down
3 changes: 2 additions & 1 deletion harfbuzz/src/unicode_funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl UnicodeFuncsBuilder {
user_data: *mut c_void,
) -> hb_unicode_combining_class_t {
unsafe { &*(user_data as *mut F) }.combining_class(unicode)
as hb_unicode_combining_class_t
}
extern "C" fn destroy_combining_class<F>(user_data: *mut c_void) {
let _ = unsafe { Box::from_raw(user_data as *mut F) };
Expand Down Expand Up @@ -270,7 +271,7 @@ impl Drop for UnicodeFuncsBuilder {
/// }
///
/// impl harfbuzz::CombiningClassFunc for PropertyProvider {
/// fn combining_class(&self, ch: u32) -> core::ffi::c_uint {
/// fn combining_class(&self, ch: u32) -> u8 {
/// todo!("CombiningClassFunc")
/// }
/// }
Expand Down

0 comments on commit 39af919

Please sign in to comment.