1#[cfg(windows)]
2pub fn init() {
3 use std::env;
4 static icudtl: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/skia/icudtl.dat"));
5
6 #[cfg(feature = "embed-icudtl")]
7 {
8 use std::sync::Mutex;
9
10 lazy_static::lazy_static!(
11 static ref MUTEX : Mutex<()> = Mutex::new(());
12 );
13
14 // Using `Once` does not work for yet unknown reasons.
15 // https://github.com/rust-skia/rust-skia/issues/566
16
17 let lock = MUTEX.lock().unwrap();
18 unsafe { crate::C_SetICU(&icudtl[0] as &'static u8 as *const u8 as _) };
19 drop(lock);
20 }
21
22 #[cfg(not(feature = "embed-icudtl"))]
23 {
24 use std::fs;
25
26 let path = env::current_exe()
27 .expect("Failed to resolve the current executable's path")
28 .parent()
29 .expect("Current executable's parent path does not point to a directory")
30 .join("icudtl.dat");
31 if path.exists() {
32 return;
33 };
34 fs::write(path, &icudtl[..])
35 .expect("Failed to write icudtl.dat into the current executable's directory");
36 }
37}
38
39#[cfg(not(windows))]
40pub fn init() {}
41