Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions harfbuzz-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ pkg-config = { version = "0.3" }
cc = { version = "1" }

[target.'cfg(target_vendor = "apple")'.dependencies]
core-graphics = { version = "0.23", optional = true }
core-text = { version = "20", optional = true }
foreign-types = { version = "0.5", optional = true }
objc2-core-graphics = { version = "0.3.2", default-features = false, features = ["CGFont"], optional = true }
objc2-core-text = { version = "0.3.2", default-features = false, features = ["CTFont"], optional = true }

[target.'cfg(target_family = "windows")'.dependencies.windows]
version = "0.59"
Expand All @@ -43,6 +42,6 @@ optional = true
[features]
default = ["coretext", "directwrite", "freetype"]
bundled = []
coretext = ["dep:core-graphics", "dep:core-text", "dep:foreign-types"]
coretext = ["dep:objc2-core-graphics", "dep:objc2-core-text"]
directwrite = ["dep:windows"]
freetype = ["dep:freetype-sys"]
15 changes: 6 additions & 9 deletions harfbuzz-sys/src/coretext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@

use crate::{hb_face_t, hb_font_t};

use core_graphics::font::CGFont;
use core_text::font::CTFontRef;
use foreign_types::ForeignType;

type CGFontRef = *mut <CGFont as ForeignType>::CType;
use objc2_core_graphics::CGFont;
use objc2_core_text::CTFont;

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
Copy Markdown

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.

/// This requires that the `coretext` feature is enabled.
pub fn hb_coretext_font_create(ct_font: CTFontRef) -> *mut hb_font_t;
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
Copy Markdown

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) }
}

/// This requires that the `coretext` feature is enabled.
pub fn hb_coretext_font_get_ct_font(font: *mut hb_font_t) -> CTFontRef;
pub fn hb_coretext_font_get_ct_font(font: *mut hb_font_t) -> CTFont;
}
Loading