Skip to content

Commit

Permalink
Auto merge of #196 - zhuge:feat/directwrite, r=jdm
Browse files Browse the repository at this point in the history
Feat/directwrite

1. Export hb-directwrite functions on windows
2. Export hb-ft function when feature build-native-freetype is on
  • Loading branch information
bors-servo committed Aug 15, 2022
2 parents b92eee0 + f602d91 commit e44d6f1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
11 changes: 10 additions & 1 deletion harfbuzz-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ core-graphics = "0.22"
core-text = "19"
foreign-types = "0.3"

[target.'cfg(target_family = "windows")'.dependencies.winapi]
version = "0.3"
features = ["dwrite"]

[target.'cfg(any(target_os = "android", all(unix, not(target_vendor = "apple"))))'.dependencies]
freetype = { version = "0.7", default-features = false }

[dependencies.freetype]
version = "0.7"
default-features = false
optional = true

[features]
default = ["build-native-harfbuzz", "build-native-freetype"]
build-native-harfbuzz = ["cc", "pkg-config"]
build-native-freetype = ["freetype/freetype-sys"]
build-native-freetype = ["freetype", "freetype/freetype-sys"]
4 changes: 4 additions & 0 deletions harfbuzz-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ fn main() {
cfg.define("HAVE_CORETEXT", "1");
}

if target.contains("windows") {
cfg.define("HAVE_DIRECTWRITE", "1");
}

if target.contains("windows-gnu") {
cfg.flag("-Wa,-mbig-obj");
}
Expand Down
9 changes: 9 additions & 0 deletions harfbuzz-sys/src/directwrite.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extern crate winapi;

use hb_face_t;

use self::winapi::um::dwrite::IDWriteFontFace;

extern "C" {
pub fn hb_directwrite_face_create(font_face: *mut IDWriteFontFace) -> *mut hb_face_t;
}
7 changes: 5 additions & 2 deletions harfbuzz-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#[cfg(any(target_os = "android", all(unix, not(target_vendor = "apple"))))]
#[cfg(any(target_os = "android", all(unix, not(target_vendor = "apple")), feature="build-native-freetype"))]
extern crate freetype;

#[cfg(target_vendor = "apple")]
pub mod coretext;

#[cfg(any(target_os = "android", all(unix, not(target_vendor = "apple"))))]
#[cfg(target_family = "windows")]
pub mod directwrite;

#[cfg(any(target_os = "android", all(unix, not(target_vendor = "apple")), feature="build-native-freetype"))]
extern "C" {
pub fn hb_ft_font_create_referenced(face: freetype::freetype::FT_Face) -> *mut hb_font_t;
}
Expand Down

0 comments on commit e44d6f1

Please sign in to comment.