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 a new safe harfbuzz crate. #105

Merged
merged 1 commit into from Mar 6, 2018
Merged

Conversation

@waywardmonkeys
Copy link
Collaborator

waywardmonkeys commented Feb 20, 2018

There is an orphaned crate, https://crates.io/crates/harfbuzz. This was previously published by the Servo project, but now the Servo project really only maintains harfbuzz-sys which doesn't present a safe API.

This is proposing adding back a harfbuzz crate that could be used by Servo and other projects, but would be safe and have somewhat better ergonomics.

This also would address my question from issue #90 about using enum and bit flags.

Thoughts?


This change is Reviewable

text.as_ptr() as *const std::os::raw::c_char,
text.len() as std::os::raw::c_int,
0,
text.len() as std::os::raw::c_int,

This comment has been minimized.

@khaledhosny

khaledhosny Feb 20, 2018

The item_offset and item_length are crucial for proper use of HarfBuzz (e.g. shaping a sub-run of the text) and should be exposed in the API.

This comment has been minimized.

@waywardmonkeys

waywardmonkeys Feb 20, 2018

Author Collaborator

I was thinking of exposing that via a separate function so that someone that just wants to layout a single piece of text can via something like add_substr instead of add_str. Does that make sense? IIRC, the servo code is not currently shaping substrings in a way that needs this.

This comment has been minimized.

@waywardmonkeys

waywardmonkeys Feb 20, 2018

Author Collaborator

Also, thanks for the feedback! It is very helpful! I hope that the Rust binding can be easier to use than the C API with solid docs.

This comment has been minimized.

@khaledhosny

khaledhosny Feb 21, 2018

I don’t speak rust, but someway to expose this should be fine I think.

}

/// Throw away text stored in the buffer, but maintain the
/// currently configured options like direction and script.

This comment has been minimized.

@khaledhosny

khaledhosny Feb 20, 2018

hb_buffer_clear_contents actually clears the segment properties as well.

This comment has been minimized.

@waywardmonkeys

waywardmonkeys Feb 20, 2018

Author Collaborator

Looking at the harfbuzz code, I see that the difference is that reset resets the unicode functions (which I haven't exposed yet), the buffer flags (which I don't yet understand well), and the replacement character, which isn't needed from Rust in the current API as a &str will be valid UTF-8 and shouldn't need the replacement character.

This probably also means that I should submit a patch upstream to improve the harfbuzz docs on this point.

@waywardmonkeys
Copy link
Collaborator Author

waywardmonkeys commented Feb 27, 2018

@jdm / @mbrubeck Any thoughts or comments on this?

@mbrubeck
Copy link
Contributor

mbrubeck commented Feb 27, 2018

This looks generally good to me.

Since Servo is not (yet?) using this crate, would you like to be the primary maintainer of it? We can add you to the "reviewers" list for this repository in our homu config and as an owner on crates.io, and you could feel free to approve any pull requests that only touch the new crate (including your own PRs, if you choose). That might help you iterate faster if you plan to keep evolving this code. It would also be great to have you as an additional reviewer for harfbuzz-sys PRs.

@waywardmonkeys
Copy link
Collaborator Author

waywardmonkeys commented Feb 27, 2018

@mbrubeck That sounds good to me!

I figured that once this crate was further along (and published), I'd submit a PR to update servo to use it rather than the unsafe code directly using harfbuzz-sys.

@waywardmonkeys waywardmonkeys force-pushed the waywardmonkeys:harfbuzz-crate branch from d48c9a8 to bb2b63a Mar 1, 2018
@waywardmonkeys
Copy link
Collaborator Author

waywardmonkeys commented Mar 6, 2018

@mbrubeck Do you need anything from me to move forward on this?

@jdm
Copy link
Member

jdm commented Mar 6, 2018

This looks like a fine start to me.

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Mar 6, 2018

📌 Commit bb2b63a has been approved by jdm

bors-servo added a commit that referenced this pull request Mar 6, 2018
Add a new safe harfbuzz crate.

There is an orphaned crate, https://crates.io/crates/harfbuzz. This was previously published by the Servo project, but now the Servo project really only maintains `harfbuzz-sys` which doesn't present a safe API.

This is proposing adding back a `harfbuzz` crate that could be used by Servo and other projects, but would be safe and have somewhat better ergonomics.

This also would address my question from issue #90 about using `enum` and bit flags.

Thoughts?

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-harfbuzz/105)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 6, 2018

Testing commit bb2b63a with merge 9bfc6b7...

@bors-servo
Copy link
Contributor

bors-servo commented Mar 6, 2018

💔 Test failed - status-travis

@bors-servo
Copy link
Contributor

bors-servo commented Mar 6, 2018

☀️ Test successful - status-travis
Approved by: jdm
Pushing 9bfc6b7 to master...

@bors-servo bors-servo merged commit bb2b63a into servo:master Mar 6, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
bors-servo added a commit to servo/saltfs that referenced this pull request Mar 6, 2018
Make waywardmonkeys a reviewer for harfbuzz.

Per servo/rust-harfbuzz#105 (comment).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/809)
<!-- Reviewable:end -->
@waywardmonkeys waywardmonkeys deleted the waywardmonkeys:harfbuzz-crate branch Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.