import { Font, woff2 } from "./mod.ts";

const buffer = await (await fetch("https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS-muw.woff2")).arrayBuffer();

// @ts-ignore エラー回避策
globalThis.document = {};
await woff2.init("https://raw.githubusercontent.com/kekee000/fonteditor-core/v2.1.11/woff2/woff2.wasm");

for (let i = 0; i < 5; i++) {
  Deno.bench(`read ${10 ** i} characters`, { group: "subset" }, () => {
    const font = Font.create(buffer, {
       type: 'woff2',
       subset: [...Array(10 ** i).keys()],
       // save font hinting
       hinting: true,
       // inflate function for woff
       inflate: null,
       // for svg path
       combinePath: false,
    });
    
    const subset = font.write({
        type: "woff2",
        hinting: true,
    });
  });
}