Skip to content

Convert harfbuzz-sys to use types from objc2#274

Open
nicoburns wants to merge 1 commit intomainfrom
objc2
Open

Convert harfbuzz-sys to use types from objc2#274
nicoburns wants to merge 1 commit intomainfrom
objc2

Conversation

@nicoburns
Copy link

This builds, but I'm not confident that it's correct. Putting it up for review / discussion.

Signed-off-by: Nico Burns <nico@nicoburns.com>
Copy link

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ABI of these is CGFont = void and *mut CGFont = CGFontRef, if that makes sense?

extern "C" {
/// This requires that the `coretext` feature is enabled.
pub fn hb_coretext_face_create(cg_font: CGFontRef) -> *mut hb_face_t;
pub fn hb_coretext_face_create(cg_font: CGFont) -> *mut hb_face_t;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn hb_coretext_face_create(cg_font: CGFont) -> *mut hb_face_t;
pub fn hb_coretext_face_create(cg_font: &CGFont) -> *mut hb_face_t;

Similar below.

pub fn hb_coretext_font_create(ct_font: CTFont) -> *mut hb_font_t;
/// This requires that the `coretext` feature is enabled.
pub fn hb_coretext_face_get_cg_font(face: *mut hb_face_t) -> CGFontRef;
pub fn hb_coretext_face_get_cg_font(face: *mut hb_face_t) -> CGFont;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn hb_coretext_face_get_cg_font(face: *mut hb_face_t) -> CGFont;
pub fn hb_coretext_face_get_cg_font(face: *mut hb_face_t) -> *mut CGFont;

Or If you want to make it easier to use, create a wrapper:

pub unsafe fn hb_coretext_face_get_cg_font(face: *mut hb_face_t) -> CFRetained<CGFont> {
    extern "C" {
        fn hb_coretext_face_get_cg_font(face: *mut hb_face_t) -> *mut CGFont;
    }
    let ptr = unsafe { hb_coretext_face_get_cg_font(face) };
    let ptr = NonNull::new(ptr).unwrap();
    unsafe { CFRetained::retain(ptr) }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants