Subset fonts

subset-font for Edge Scripting for bunny.net 🐰

NPM Version

Introduction

Subset fonts is a convenience module for reducing the character set and variation space in a font.

This package only works with otf and ttf font formats. Use another package to convert to and from the woff2 format for web font support.

Example

import * as BunnySDK from 'https://esm.sh/@bunny.net/edgescript-sdk@0.11.2'import { initSubset } from 'https://cdn.jsdelivr.net/npm/bunny-subset@0.0.2/dist/index.js'let subsetBunnySDK.net.http.serve(async (request: Request): Promise<Response> => {  // keep script startup time under 500ms  if (!subset) {    subset = await initSubset()  }  // fetch font  const fontResponse = await fetch(    'https://cdn.jsdelivr.net/gh/google/fonts@main/ofl/bungeetint/BungeeTint-Regular.ttf',  )  const fontBytes = await fontResponse.bytes()  // subset font  const fontSubset = subset(fontBytes, 'Hello, world!')  // return font response  return new Response(fontSubset, {    headers: {      'Content-Type': 'application/font-ttf',    },  })})