Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UnicodeFuncs with safe-to-implement traits #197

Merged
merged 26 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions harfbuzz/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use std;
use sys;

use crate::UnicodeFuncs;

use {Direction, Language};

/// A series of Unicode characters.
Expand Down Expand Up @@ -120,6 +122,13 @@ impl Buffer {
b
}

/// Sets a [`UnicodeFuncs`] instance to use with this buffer.
///
/// Note: `unicode_funcs` is reference counted by HarfBuzz.
pub fn set_unicode_funcs(&mut self, unicode_funcs: &UnicodeFuncs) {
unsafe { sys::hb_buffer_set_unicode_funcs(self.raw, unicode_funcs.as_ptr()) }
}

/// Add UTF-8 encoded text to the buffer.
pub fn add_str(&mut self, text: &str) {
unsafe {
Expand Down
18 changes: 18 additions & 0 deletions harfbuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

pub extern crate harfbuzz_sys as sys;

/// An error type for this crate
#[derive(Debug)]
pub enum HarfBuzzError {
/// Allocation failed within HarfBuzz itself
Alloc,
}
pub use HarfBuzzError as Error;

mod buffer;
pub use self::buffer::Buffer;

Expand All @@ -31,3 +39,13 @@ pub use self::language::Language;

mod blob;
pub use self::blob::Blob;

mod unicode_funcs;
pub use self::unicode_funcs::CombiningClassFunc;
pub use self::unicode_funcs::ComposeFunc;
pub use self::unicode_funcs::DecomposeFunc;
pub use self::unicode_funcs::GeneralCategoryFunc;
pub use self::unicode_funcs::MirroringFunc;
pub use self::unicode_funcs::ScriptFunc;
pub use self::unicode_funcs::UnicodeFuncs;
pub use self::unicode_funcs::UnicodeFuncsBuilder;
Loading