-
Notifications
You must be signed in to change notification settings - Fork 73
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
C interface #119
Comments
I've never written a C interface in rust, and I'm unsure of the complexities involved with retro-fitting the library to support such an endeavor. I'm not sure I want to have to maintain a C interface as well. I'm open to the discussion though. |
Generally it's not too complex, and involves wrapping trait functions around in C style: |
Alright, did a little work on this and it's been pretty straightforward so far. You can keep up to date/see what's involved at the project repo. |
Have run into an issue with struct privacy: part of writing a C interface is writing C-compatible structs which can be converted to and from library-side structs. This has been largely doable, since most of the private type info is in types that allocate and hence are probably best represented as opaque The There are a couple of solutions that I can see, all of them library-side, if you wouldn't mind considering. Everything but the layout module is already working C-side, and I'd really love to be able to continue with the interface project, especially when the blockage is something so simple.
Addendum: have discussed with another person about this and it looks like it is possible to make a flat opaque type based on a transmutation of the original struct data (+ the private |
I've worked around this issue via a flattened opaque type using The complete C interface can be found here. |
Sorry I haven't replied sooner, real work has been eating my at home programming energy. In general, I'm apprehensive to make internal state public because that's committing to supporting implementation details. That being said, this bitfield is kind of unnecessary and can probably be replaced with a couple of booleans. I'm fine if you want to submit a PR to replace the bitfield with a couple of public boolean fields for what's currently encoded. If you plan on submitting a PR, please comment on #113 first. There's a license change in progress to a less restrictive triple license model. |
I'm interested in using Fontdue in a non-Rust project. WGPU provides a C interface that makes binding to it from any language easy. Fontdue seems awesome, and it'd be great to be able to do the same--I'd love to be able to use it instead of something like freetype.
Are there any plans to provide a bindable C interface? If not, I'm happy to put some effort in that direction--in which case, is there anything you can think of that might make writing an interface tricky, or any other suggestions?
The text was updated successfully, but these errors were encountered: