1// Fallback on the web (decisions/F10.md, question 1A): a page is2// given no font files, so a program names fonts to fetch, served beside3// it (`fonts.fetch`); browser.web.js fetches them and keeps those that4// arrive until the fonts take them, as fallback faces for any script.56import std::ffi;7import std::option;8import std::vector;910extern al_text_fetch(url: c_pointer, length: u32);11extern al_text_fetched() -> u32;12extern al_text_take(at: c_pointer, capacity: u32);1314// Starts fetching the font at the URL, relative to the page.15pub fn start_fetch(url: &[u8]) {16 al_text_fetch(c_pointer::of(&url), url.length() to u32);17}1819// The bytes of a font fetched and not yet taken, the earliest first.20pub fn next_fetched() -> Option<Vector<u8>> {21 const size = al_text_fetched();22 if (size == 0) {23 return ::None;24 }25 var bytes = Vector<u8>::filled(0, size to u64);26 al_text_take(c_pointer::of(&bytes.view()), size);27 return ::Some(move bytes);28}