Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
// Embeds the bundled faces (index.json and the woff2 files beside it) as a const table for src/lib.rs.
use std::{env, fs, path::Path};
fn main() {
// read at run time, not with env!(): a build script compiled for one checkout path can be reused by cargo for
// another (worktrees sharing a target dir), and env!() would keep the first path
let dir = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).to_path_buf();
println!("cargo:rerun-if-changed={}", dir.join("index.json").display());
let index = fs::read_to_string(dir.join("index.json")).expect("index.json");
let mut out = String::from("[\n");
// a dependency-free parse of [{"family":..,"weight":..,"style":..,"file":..}, ...]
for obj in index.split('{').skip(1) {
let field = |k: &str| -> String {
let key = format!("\"{k}\":");
let i = obj.find(&key).expect("field") + key.len();
let rest = obj[i..].trim_start();
rest[1..].split('"').next().unwrap().to_string()
};
let file = dir.join(field("file"));
out.push_str(&format!(
" ({:?}, {:?}, {:?}, include_bytes!({:?}) as &[u8]),\n",
field("family"),
field("weight"),
field("style"),
file.display().to_string()
));
}
out.push(']');
fs::write(Path::new(&env::var("OUT_DIR").unwrap()).join("bundled_fonts.rs"), out).unwrap();
}