• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use harfbuzz_wasm::{Font, GlyphBuffer};
2 use tiny_rng::{Rand, Rng};
3 use wasm_bindgen::prelude::*;
4 
5 #[wasm_bindgen]
shape( _shape_plan: u32, font_ref: u32, buf_ref: u32, _features: u32, _num_features: u32, ) -> i326 pub fn shape(
7     _shape_plan: u32,
8     font_ref: u32,
9     buf_ref: u32,
10     _features: u32,
11     _num_features: u32,
12 ) -> i32 {
13     let mut rng = Rng::from_seed(123456);
14     let font = Font::from_ref(font_ref);
15     font.shape_with(buf_ref, "ot");
16     let mut buffer = GlyphBuffer::from_ref(buf_ref);
17     for mut item in buffer.glyphs.iter_mut() {
18         // Randomize it!
19         item.x_offset = ((rng.rand_u32() as i32) >> 24) - 120;
20         item.y_offset = ((rng.rand_u32() as i32) >> 24) - 120;
21     }
22     // Buffer is written back to HB on drop
23     1
24 }
25