harfbuzz_ft_sys/lib.rs
1// This code is dual-licensed under the Apache 2.0 License and the MIT License.
2
3//! Hand-written FFI bindings to the Harfbuzz Freetype library.
4
5use freetype::freetype::FT_Face;
6use harfbuzz_sys::{hb_destroy_func_t, hb_face_t, hb_font_t};
7use std::os::raw::c_int;
8
9#[link(name = "harfbuzz")]
10extern "C" {
11 /// Official harfbuzz documentation:
12 ///
13 /// This one creates a new hb-face for given ft-face.
14 /// When the returned hb-face is destroyed, the destroy
15 /// callback is called (if not NULL), with the ft-face passed
16 /// to it.
17 ///
18 /// The client is responsible to make sure that ft-face is
19 /// destroyed after hb-face is destroyed.
20 ///
21 /// Most often you don't want this function. You should use either
22 /// hb_ft_face_create_cached(), or hb_ft_face_create_referenced().
23 /// In particular, if you are going to pass NULL as destroy, you
24 /// probably should use (the more recent) hb_ft_face_create_referenced()
25 /// instead.
26 pub fn hb_ft_face_create(ft_face: FT_Face, destroy: hb_destroy_func_t) -> *mut hb_face_t;
27
28 /// Official harfbuzz documentation:
29 ///
30 /// This version is like hb_ft_face_create(), except that it caches
31 /// the hb-face using the generic pointer of the ft-face. This means
32 /// that subsequent calls to this function with the same ft-face will
33 /// return the same hb-face (correctly referenced).
34 ///
35 /// Client is still responsible for making sure that ft-face is destroyed
36 /// after hb-face is.
37 pub fn hb_ft_face_create_cached(ft_face: FT_Face) -> *mut hb_face_t;
38
39 /// Official harfbuzz documentation:
40 ///
41 /// This version is like hb_ft_face_create(), except that it calls
42 /// FT_Reference_Face() on ft-face, as such keeping ft-face alive
43 /// as long as the hb-face is.
44 ///
45 /// This is the most convenient version to use. Use it unless you have
46 /// very good reasons not to.
47 pub fn hb_ft_create_referenced(ft_face: FT_Face) -> *mut hb_face_t;
48
49 /// Official harfbuzz documentation:
50 ///
51 /// See notes on hb_ft_face_create(). Same issues re lifecycle-management
52 /// apply here. Use hb_ft_font_create_referenced() if you can.
53 pub fn hb_ft_font_create(ft_face: FT_Face, destroy: hb_destroy_func_t) -> *mut hb_font_t;
54
55 /// Official harfbuzz documentation:
56 ///
57 /// See notes on hb_ft_face_create_referenced() re lifecycle-management
58 /// issues.
59 pub fn hb_ft_font_create_referenced(ft_face: FT_Face) -> *mut hb_font_t;
60
61 pub fn hb_ft_font_get_face(font: *mut hb_font_t) -> FT_Face;
62
63 pub fn hb_ft_font_set_load_flags(font: *mut hb_font_t, load_flags: c_int);
64
65 pub fn hb_ft_font_get_load_flags(font: *mut hb_font_t) -> c_int;
66
67 /// Official harfbuzz documentation:
68 ///
69 /// Call when size or variations settings on underlying FT_Face change.
70 pub fn hb_ft_font_changed(font: *mut hb_font_t);
71
72 /// Official harfbuzz documentaion:
73 ///
74 /// Makes an hb_font_t use FreeType internally to implement font functions.
75 /// Note: this internally creates an FT_Face. Use it when you create your
76 /// hb_face_t using hb_face_create().
77 pub fn hb_ft_font_set_funcs(font: *mut hb_font_t);
78}