diff --git a/src/fontations/Cargo.lock b/src/fontations/Cargo.lock new file mode 100644 index 000000000..c46a522ab --- /dev/null +++ b/src/fontations/Cargo.lock @@ -0,0 +1,332 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "bytemuck" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cc" +version = "1.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +dependencies = [ + "shlex", +] + +[[package]] +name = "clap" +version = "4.5.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.143" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "050906babad73f9b32a91cecc3063ff1e2235226dd2367dd839fd6fbc941c68a" +dependencies = [ + "cc", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash", + "link-cplusplus", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.143" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3062da294104183e1c34ea9887941d4d8c74f6195ce9fbb430ac4b5290ede" +dependencies = [ + "clap", + "codespan-reporting", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.143" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4b358173a166833ddef75fe468579f71727c789b8082d4cc77c38d08f656c59" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.143" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9531217f3b5f7728244d2b7312bc6660f6b3e4cdbc118f4f1fbce48cb401a0f" +dependencies = [ + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + +[[package]] +name = "font-types" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3971f9a5ca983419cdc386941ba3b9e1feba01a0ab888adf78739feb2798492" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "harfbuzz-fontations" +version = "0.1.0" +dependencies = [ + "bytemuck", + "bytemuck_derive", + "cxx", + "font-types", + "libc", + "read-fonts", + "skrifa", +] + +[[package]] +name = "libc" +version = "0.2.170" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" + +[[package]] +name = "link-cplusplus" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6f6da007f968f9def0d65a05b187e2960183de70c160204ecfccf0ee330212" +dependencies = [ + "cc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "read-fonts" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a252609f83421102bf1b7f08936f5a24e4f9568256e2015fbd027790caf3dcb" +dependencies = [ + "bytemuck", + "font-types", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "skrifa" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69a99d1c6428e12bcf538d34fd4b78a4e6a4556db29f319a1cecfc33f466e64c" +dependencies = [ + "bytemuck", + "read-fonts", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/src/fontations/Cargo.toml b/src/fontations/Cargo.toml new file mode 100644 index 000000000..77c9d9a16 --- /dev/null +++ b/src/fontations/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "harfbuzz-fontations" +version = "0.1.0" +edition = "2021" + +[dependencies] +read-fonts = { version = "0.23", features = [ "experimental_traverse" ]} +font-types = { version = "0.7", features = ["bytemuck"]} +skrifa = "0.24" +bytemuck = { version = "1.19.0" , features = [ 'derive', 'min_const_generics'] } +bytemuck_derive = "1" +cxx = "1.0" +libc = "0.2" + +[lib] +name = "harfbuzz_fontations" +path = "lib.rs" +crate-type = ["cdylib"] diff --git a/src/fontations/lib.rs b/src/fontations/lib.rs index c6946e45b..2e980bce3 100644 --- a/src/fontations/lib.rs +++ b/src/fontations/lib.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] -include!(concat!(env!("BUILD_ROOT"), "/src", "/hb.rs")); +include!(concat!(env!("OUT_DIR"), "/hb.rs")); use std::os::raw::{c_void}; use std::ptr::{null_mut}; @@ -12,7 +12,7 @@ use std::ptr::{null_mut}; // A struct for storing your “fontations” data #[repr(C)] -pub struct FontationsData { +struct FontationsData { // e.g. storing an owned font buffer, or read-fonts handles: // font_bytes: Vec, // font_ref: Option>, @@ -21,7 +21,7 @@ pub struct FontationsData { // A destructor for the user_data #[no_mangle] -pub extern "C" fn fontations_data_destroy(ptr: *mut c_void) { +extern "C" fn fontations_data_destroy(ptr: *mut c_void) { if !ptr.is_null() { unsafe { let _ = Box::from_raw(ptr as *mut FontationsData); } } @@ -29,7 +29,7 @@ pub extern "C" fn fontations_data_destroy(ptr: *mut c_void) { // Our callback: get glyph horizontal advance #[no_mangle] -pub extern "C" fn hb_fontations_get_glyph_h_advance( +extern "C" fn _hb_fontations_get_glyph_h_advance( _font: *mut hb_font_t, font_data: *mut c_void, glyph: hb_codepoint_t, @@ -45,13 +45,13 @@ pub extern "C" fn hb_fontations_get_glyph_h_advance( } #[no_mangle] -pub extern "C" fn _hb_fontations_font_funcs_create() -> *mut hb_font_funcs_t { +extern "C" fn _hb_fontations_font_funcs_create() -> *mut hb_font_funcs_t { let ffuncs = unsafe { hb_font_funcs_create() }; unsafe { hb_font_funcs_set_glyph_h_advance_func( ffuncs, - Some(hb_fontations_get_glyph_h_advance), + Some(_hb_fontations_get_glyph_h_advance), null_mut(), None ); diff --git a/src/meson.build b/src/meson.build index 2bc5c6216..d92363929 100644 --- a/src/meson.build +++ b/src/meson.build @@ -696,8 +696,9 @@ endif libharfbuzz_fontations_dep = null_dep if get_option('fontations').enabled() + subdir('fontations') + hb_fontations_sources = [ - 'fontations/lib.rs', ] hb_fontations_headers = [ @@ -706,10 +707,8 @@ if get_option('fontations').enabled() libharfbuzz_fontations = library('harfbuzz-fontations', hb_fontations_sources, include_directories: incconfig, - link_with: [libharfbuzz], - cpp_args: cpp_args + extra_hb_cpp_args, - rust_args: ['-Z', 'unstable-options', - '--env-set', 'BUILD_ROOT='+meson.build_root()], + link_with: [libharfbuzz, cargo_build], + dependencies: [harfbuzz_fontations_dep], soversion: hb_so_version, version: version, rust_abi: 'c', @@ -738,16 +737,6 @@ if get_option('fontations').enabled() subdirs: [meson.project_name()], version: meson.project_version(), ) - - rust = import('unstable-rust') - - generated = rust.bindgen( - input : 'hb.h', - output : 'hb.rs', - include_directories: incsrc, - args : ['--allowlist-function=hb_.*', '--allowlist-type=hb_.*'], - #args : ['--no-rustfmt-bindings'], - ) endif if get_option('tests').enabled() diff --git a/util/meson.build b/util/meson.build index e1a43d8be..4e326f1fa 100644 --- a/util/meson.build +++ b/util/meson.build @@ -19,7 +19,7 @@ hb_subset_cli_sources = [ 'helper-subset.hh', ] -util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep, libharfbuzz_fontations_dep] +util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep, harfbuzz_fontations_dep] if conf.get('HAVE_GLIB', 0) == 1 if conf.get('HAVE_CAIRO', 0) == 1