UNPKG

dropflow

Version:

A small CSS2 document renderer built from specifications

24 lines (23 loc) 896 B
import { environment, defaultEnvironment } from './environment.js'; if (environment.registerFont === defaultEnvironment.registerFont) { environment.registerFont = function (face) { const buffer = face.getBuffer(); const domFace = new FontFace(face.uniqueFamily, buffer); document.fonts.add(domFace); return () => document.fonts.remove(domFace); }; } if (environment.resolveUrlSync === defaultEnvironment.resolveUrlSync) { environment.resolveUrlSync = function (url) { throw new Error(`Cannot load synchronously: ${url}`); }; } if (environment.resolveUrl === defaultEnvironment.resolveUrl) { environment.resolveUrl = async function (url) { const res = await fetch(url); if (!res.ok) throw new Error(res.statusText); return await res.arrayBuffer(); }; } // wasm locator must be manually configured