tectonic_bridge_harfbuzz 0.3.3

Expose the Harfbuzz C/C++ APIs to Rust/Cargo.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
#![allow(non_camel_case_types)]

use std::ptr;

const fn hb_tag(text: &[u8; 4]) -> u32 {
    u32::from_be_bytes(*text)
}

pub const HB_TAG_NONE: u32 = hb_tag(b"\0\0\0\0");
pub const HB_OT_TAG_GSUB: u32 = hb_tag(b"GSUB");
pub const HB_OT_TAG_GPOS: u32 = hb_tag(b"GPOS");

pub type hb_script_t = u32;

pub const HB_SCRIPT_INVALID: u32 = HB_TAG_NONE;

pub type hb_bool_t = libc::c_int;
pub type hb_codepoint_t = u32;
pub type hb_position_t = i32;
pub type hb_tag_t = u32;
pub type hb_mask_t = u32;
pub type hb_language_t = *mut hb_language_impl_t;
pub type hb_ot_name_id_t = libc::c_uint;

#[repr(C)]
pub struct hb_language_impl_t(());

pub type hb_destroy_func_t = unsafe extern "C" fn(user_data: *mut ());
pub type hb_font_get_nominal_glyph_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    unicode: hb_codepoint_t,
    glyph: *mut hb_codepoint_t,
    user_data: *mut (),
) -> hb_bool_t;
pub type hb_font_get_variation_glyph_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    unicode: hb_codepoint_t,
    variation_selector: hb_codepoint_t,
    glyph: *mut hb_codepoint_t,
    user_data: *mut (),
) -> hb_bool_t;
pub type hb_font_get_glyph_advance_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    glyph: hb_codepoint_t,
    user_data: *mut (),
) -> hb_position_t;
pub type hb_font_get_glyph_h_advance_func_t = hb_font_get_glyph_advance_func_t;
pub type hb_font_get_glyph_v_advance_func_t = hb_font_get_glyph_advance_func_t;
pub type hb_font_get_glyph_origin_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    glyph: hb_codepoint_t,
    x: *mut hb_position_t,
    y: *mut hb_position_t,
    user_data: *mut (),
) -> hb_bool_t;
pub type hb_font_get_glyph_h_origin_func_t = hb_font_get_glyph_origin_func_t;
pub type hb_font_get_glyph_v_origin_func_t = hb_font_get_glyph_origin_func_t;
pub type hb_font_get_glyph_kerning_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    first_glyph: hb_codepoint_t,
    second_glyph: hb_codepoint_t,
    user_data: *mut (),
) -> hb_position_t;
pub type hb_font_get_glyph_h_kerning_func_t = hb_font_get_glyph_kerning_func_t;
pub type hb_font_get_glyph_v_kerning_func_t = hb_font_get_glyph_kerning_func_t;
pub type hb_font_get_glyph_extents_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    glyph: hb_codepoint_t,
    extents: *mut hb_glyph_extents_t,
    user_data: *mut (),
) -> hb_bool_t;
pub type hb_font_get_glyph_contour_point_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    glyph: hb_codepoint_t,
    point_index: libc::c_uint,
    x: *mut hb_position_t,
    y: *mut hb_position_t,
    user_data: *mut (),
) -> hb_bool_t;
pub type hb_font_get_glyph_name_func_t = unsafe extern "C" fn(
    font: *mut hb_font_t,
    font_data: *mut (),
    glyph: hb_codepoint_t,
    name: *mut libc::c_char,
    size: libc::c_uint,
    user_data: *mut (),
) -> hb_bool_t;
pub type hb_reference_table_func_t =
    unsafe extern "C" fn(face: *mut hb_face_t, tag: hb_tag_t, user_data: *mut ()) -> *mut hb_blob_t;
pub type hb_unicode_decompose_compatibility_func_t = unsafe extern "C" fn(
    ufuncs: *mut hb_unicode_funcs_t,
    u: hb_codepoint_t,
    decomposed: *mut hb_codepoint_t,
    user_data: *mut libc::c_void,
) -> libc::c_uint;

#[repr(C)]
pub struct hb_font_t(());

#[repr(C)]
pub struct hb_font_funcs_t(());

#[repr(C)]
pub struct hb_face_t(());

#[repr(C)]
pub struct hb_blob_t(());

#[repr(C)]
pub struct hb_buffer_t(());

#[repr(C)]
pub struct hb_shape_plan_t(());

#[repr(C)]
pub struct hb_unicode_funcs_t(());

#[derive(Clone, Debug, Default)]
#[repr(C)]
pub struct hb_glyph_extents_t {
    pub x_bearing: hb_position_t,
    pub y_bearing: hb_position_t,
    pub width: hb_position_t,
    pub height: hb_position_t,
}

#[derive(Clone, Debug)]
#[repr(C)]
pub struct hb_feature_t {
    pub tag: hb_tag_t,
    pub value: u32,
    start: libc::c_uint,
    end: libc::c_uint,
}

#[repr(C)]
pub enum hb_memory_mode_t {
    Duplicate,
    ReadOnly,
    Writable,
    ReadOnlyMayMakeWritable,
}

#[repr(C)]
pub enum hb_buffer_content_type_t {
    Invalid = 0,
    Unicode,
    Glyphs,
}

#[repr(C)]
pub struct hb_glyph_info_t {
    pub codepoint: hb_codepoint_t,
    mask: hb_mask_t,
    pub cluster: u32,
    var1: hb_var_int_t,
    var2: hb_var_int_t,
}

#[repr(C)]
pub struct hb_glyph_position_t {
    pub x_advance: hb_position_t,
    pub y_advance: hb_position_t,
    pub x_offset: hb_position_t,
    pub y_offset: hb_position_t,
    var: hb_var_int_t,
}

#[repr(C)]
pub struct hb_segment_properties_t {
    pub direction: hb_direction_t,
    pub script: hb_script_t,
    pub language: hb_language_t,
    reserved1: *mut libc::c_void,
    reserved2: *mut libc::c_void,
}

impl Default for hb_segment_properties_t {
    fn default() -> Self {
        hb_segment_properties_t {
            direction: Default::default(),
            script: 0,
            language: ptr::null_mut(),
            reserved1: ptr::null_mut(),
            reserved2: ptr::null_mut(),
        }
    }
}

#[repr(C)]
pub union hb_var_int_t {
    u32: u32,
    i32: i32,
    u16: [u16; 2],
    i16: [i16; 2],
    u8: [u8; 4],
    i8: [i8; 4],
}

#[derive(Default, Debug, PartialEq)]
#[repr(C)]
pub enum hb_direction_t {
    #[default]
    Invalid = 0,
    Ltr = 4,
    Rtl,
    Ttb,
    Btt,
}

extern "C" {
    pub fn hb_font_funcs_create() -> *mut hb_font_funcs_t;
    pub fn hb_font_funcs_set_nominal_glyph_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_nominal_glyph_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_variation_glyph_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_variation_glyph_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_h_advance_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_h_advance_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_v_advance_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_v_advance_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_h_origin_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_h_origin_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_v_origin_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_v_origin_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_h_kerning_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_h_kerning_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_v_kerning_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_v_kerning_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_extents_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_extents_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_contour_point_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_contour_point_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_funcs_set_glyph_name_func(
        ffuncs: *mut hb_font_funcs_t,
        func: hb_font_get_glyph_name_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_blob_create(
        data: *mut libc::c_char,
        length: libc::c_uint,
        mode: hb_memory_mode_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    ) -> *mut hb_blob_t;
    pub fn hb_face_create_for_tables(
        reference_table_func: hb_reference_table_func_t,
        user_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    ) -> *mut hb_face_t;
    pub fn hb_face_set_index(face: *mut hb_face_t, index: libc::c_uint);
    pub fn hb_face_set_upem(face: *mut hb_face_t, upem: libc::c_uint);
    pub fn hb_face_destroy(face: *mut hb_face_t);
    pub fn hb_font_create(face: *mut hb_face_t) -> *mut hb_font_t;
    pub fn hb_font_set_funcs(
        font: *mut hb_font_t,
        klass: *mut hb_font_funcs_t,
        font_data: *mut (),
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_font_set_scale(font: *mut hb_font_t, x_scale: libc::c_int, y_scale: libc::c_int);
    pub fn hb_font_set_ppem(font: *mut hb_font_t, x_ppem: libc::c_uint, y_ppem: libc::c_uint);
    pub fn hb_font_destroy(font: *mut hb_font_t);
    pub fn hb_font_get_face(font: *mut hb_font_t) -> *mut hb_face_t;
    pub fn hb_ot_layout_table_get_script_tags(
        face: *mut hb_face_t,
        table_tag: hb_tag_t,
        start_offset: libc::c_uint,
        script_count: *mut libc::c_uint,
        script_tags: *mut hb_tag_t,
    ) -> libc::c_uint;
    pub fn hb_ot_layout_script_get_language_tags(
        face: *mut hb_face_t,
        table_tag: hb_tag_t,
        script_index: libc::c_uint,
        start_offset: libc::c_uint,
        language_count: *mut libc::c_uint,
        script_tags: *mut hb_tag_t,
    ) -> libc::c_uint;
    pub fn hb_ot_layout_table_find_script(
        face: *mut hb_face_t,
        table_tag: hb_tag_t,
        script_tag: hb_tag_t,
        script_index: *mut libc::c_uint,
    ) -> hb_bool_t;
    pub fn hb_ot_layout_script_select_language(
        face: *mut hb_face_t,
        table_tag: hb_tag_t,
        script_index: libc::c_uint,
        language_count: libc::c_uint,
        language_tags: *const hb_tag_t,
        language_index: *mut libc::c_uint,
    ) -> hb_bool_t;
    pub fn hb_ot_layout_language_get_feature_tags(
        face: *mut hb_face_t,
        table_tag: hb_tag_t,
        script_index: libc::c_uint,
        language_index: libc::c_uint,
        start_offset: libc::c_uint,
        feature_count: *mut libc::c_uint,
        feature_tags: *mut hb_tag_t,
    ) -> libc::c_uint;
    pub fn hb_graphite2_face_get_gr_face(face: *mut hb_face_t) -> *mut ();
    pub fn hb_language_from_string(str: *const libc::c_char, len: libc::c_int) -> hb_language_t;
    pub fn hb_tag_from_string(str: *const libc::c_char, len: libc::c_int) -> hb_tag_t;
    pub fn hb_ot_tag_to_language(tag: hb_tag_t) -> hb_language_t;
    pub fn hb_buffer_create() -> *mut hb_buffer_t;
    pub fn hb_buffer_destroy(buffer: *mut hb_buffer_t);
    pub fn hb_buffer_get_length(buffer: *const hb_buffer_t) -> libc::c_uint;
    pub fn hb_buffer_get_glyph_infos(
        buffer: *mut hb_buffer_t,
        length: *mut libc::c_uint,
    ) -> *mut hb_glyph_info_t;
    pub fn hb_buffer_get_glyph_positions(
        buffer: *mut hb_buffer_t,
        length: *mut libc::c_uint,
    ) -> *mut hb_glyph_position_t;
    pub fn hb_language_to_string(lang: hb_language_t) -> *const libc::c_char;
    pub fn hb_buffer_get_script(buffer: *const hb_buffer_t) -> hb_script_t;
    pub fn hb_script_get_horizontal_direction(script: hb_script_t) -> hb_direction_t;
    pub fn hb_ot_math_has_data(face: *mut hb_face_t) -> hb_bool_t;
    pub fn hb_ot_tag_to_script(tag: hb_tag_t) -> hb_script_t;
    pub fn hb_buffer_reset(buffer: *mut hb_buffer_t);
    pub fn hb_buffer_add_utf16(
        buffer: *mut hb_buffer_t,
        text: *const u16,
        text_length: libc::c_int,
        item_offset: libc::c_uint,
        item_length: libc::c_int,
    );
    pub fn hb_buffer_set_direction(buffer: *mut hb_buffer_t, direction: hb_direction_t);
    pub fn hb_buffer_set_script(buffer: *mut hb_buffer_t, script: hb_script_t);
    pub fn hb_buffer_set_language(buffer: *mut hb_buffer_t, language: hb_language_t);
    pub fn hb_buffer_guess_segment_properties(buffer: *mut hb_buffer_t);
    pub fn hb_buffer_get_segment_properties(
        buffer: *const hb_buffer_t,
        props: *mut hb_segment_properties_t,
    );
    pub fn hb_shape_plan_create(
        bufferface: *mut hb_face_t,
        props: *const hb_segment_properties_t,
        user_features: *const hb_feature_t,
        num_user_features: libc::c_uint,
        shaper_list: *const *const libc::c_char,
    ) -> *mut hb_shape_plan_t;
    pub fn hb_shape_plan_create_cached(
        face: *mut hb_face_t,
        props: *const hb_segment_properties_t,
        user_features: *const hb_feature_t,
        num_user_features: libc::c_uint,
        shaper_list: *const *const libc::c_char,
    ) -> *mut hb_shape_plan_t;
    pub fn hb_shape_plan_execute(
        shape_plan: *mut hb_shape_plan_t,
        font: *mut hb_font_t,
        buffer: *mut hb_buffer_t,
        features: *const hb_feature_t,
        num_features: libc::c_uint,
    ) -> hb_bool_t;
    pub fn hb_shape_plan_get_shaper(shape_plan: *mut hb_shape_plan_t) -> *const libc::c_char;
    pub fn hb_shape_plan_destroy(shape_plane: *mut hb_shape_plan_t);
    pub fn hb_buffer_set_content_type(
        buffer: *mut hb_buffer_t,
        content_type: hb_buffer_content_type_t,
    );
    pub fn hb_icu_get_unicode_funcs() -> *mut hb_unicode_funcs_t;
    pub fn hb_unicode_funcs_create(parent: *mut hb_unicode_funcs_t) -> *mut hb_unicode_funcs_t;
    pub fn hb_unicode_funcs_set_decompose_compatibility_func(
        ufuncs: *mut hb_unicode_funcs_t,
        func: hb_unicode_decompose_compatibility_func_t,
        user_data: *mut libc::c_void,
        destroy: Option<hb_destroy_func_t>,
    );
    pub fn hb_buffer_set_unicode_funcs(
        buffer: *mut hb_buffer_t,
        unicode_funcs: *mut hb_unicode_funcs_t,
    );
    pub fn hb_version_atleast(
        major: libc::c_uint,
        minor: libc::c_uint,
        patch: libc::c_uint,
    ) -> hb_bool_t;
    pub fn hb_font_get_ptem(font: *mut hb_font_t) -> f32;
    pub fn hb_ot_layout_get_size_params(
        face: *mut hb_face_t,
        design_size: *mut libc::c_uint,
        subfamily_id: *mut libc::c_uint,
        subfamily_name_id: *mut hb_ot_name_id_t,
        range_start: *mut libc::c_uint,
        range_end: *mut libc::c_uint,
    ) -> hb_bool_t;
    pub fn hb_font_funcs_destroy(ffuncs: *mut hb_font_funcs_t);
    pub fn hb_font_funcs_reference(ffuncs: *mut hb_font_funcs_t) -> *mut hb_font_funcs_t;
    pub fn hb_font_funcs_make_immutable(ffuncs: *mut hb_font_funcs_t);
}