npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xlfont/choose

v0.0.32

Published

font chooser widget for building your website

Downloads

52

Readme

@xlfont/choose

font chooser including

  • ui and library for chooser dynamics
  • tool for building meta files from fonts of your choice.

Frontend Usage

@xlfont/choose depends on @xlfont/load so you have to install both. Install by

npm install --save @xlfont/choose @xlfont/load

and include index.js and index.css under @xlfont/choose's dist folder, along with index.js in @xlfont/load.

HTML counterpart is also needed, which is available as a mixin in dist/index.pug, in pug format. @xlfont/choose is based on ldview which means UI / Logic is separated thus you can make your own chooser widget to fit your design ( while the JS Selectors are not documented so you have to check index.pug for reference. )

After installed, create a xfc instance:

chooser = new xfc( ... )

Here is a minimal working example in pug, with @plotdb/srcbuild pug extension syntax:

include @/@xlfont/choose/dist/index.pug
.ldcv: +xfc
script
  chooser = new xfc { root: '.ldcv', initRender: true }
  chooser.init!then -> ...

Check web/src/pug/index.pug for example with ldcover and @xlfont/choose.

Constructor Options

  • root: container element or selector for inserting font chooser
  • meta: metadata URL root. fallback to url set by xfc.url if omitted.
  • links: font file URL root. fallback to url set by xfc.url if omitted.
  • i18n: i18n object in i18next spec.
  • initRender: default false. when false, list should be rendered by calling render function manually.
    • font list rendering involves bounding box calculation, which may not be available when container isnt' visible.
    • in this case, user should manually call render() after container is visible.
  • order(a,b): sort font list based on given font objects where:
    • n: font name
  • upload({font, type}): optional. if provided, return state of upload font for certain type.
    • check state below for possible types.
  • state({font, type}): optional. return state of font for certain type.
    • type can be either:
      • limited: return true if this font is limited. default limited when type is omitted.
    • if implemented, should return undefined for unsupported type.

API

  • config(opt): update config, including state, order and upload option in constructor parameters.
  • render(): render font list.
  • load(opt): load a font based on the given parameter opt.
    • returns a Promise which resolves with the desired font(a xlfont object), or rejects if font is not found.
    • opt can be either:
      • a number: return the font by the given index from the font family list.
      • a string: return the font with the exact same name to opt, case insensitive.
      • a simplified font object such as {name, style, weight, mod: {file}}.
        • mod.file is an object used to load uploaded fonts.
          • it contains following fields(which will be used to call fontFromFile):
            • mandatory field:
              • blob: font file blob. mandatory. for uploaded fonts.
            • fields from File object:
              • name: font file name.
              • lastModified: timestamp of file modified time
              • size: file size
              • type: file mimetype.
          • can contains other fields depending on user spec, for example:
            • digest: file digest (e.g., md5)
            • key: file key for accessing it from a data storage.
      • the font family object itself
  • fontFromFile(opt): load a font from file. opt:
    • file: either a file object (Blob) or the mod.file object (see load(opt) above for more info)
    • name: font name. use file.name if omitted.

Class API

  • url(opt): set url hint for meta and links urls
    • opt is an object with following fields:
      • meta: suggested metadata URL root
      • links: suggested font file URL root
    • when opt is omitted, return url hint or {} if not available.

Events

  • choose: fired when a font is chosen, with an xlfont object from @xlfont/load for the chosen font.
  • load.start: fired when a font is loading. ( after user clicking a font )
  • load.end: fired when a font load ended. ( either succeeded or failed )
  • load.fail: fired when a font is failed to load.

Xlfont Extension

@xlfont/choose extends xlfont in font.ext with following fields:

  • limited: indicate that this font is limited in usage when true.
  • blob: blob for the uploaded font, if this font is uploaded by user.

Metadata Generation

To generate metadata, also install @xlfont/choose if not installed yet:

npm install --save-dev @xlfont/choose

A command (via npx) will be available after install:

npx xfc

This command generates necessary files for @xlfont/choose to list your fonts. It generates:

  • a minimized PNG for previewing fonts.
  • metadata for font information, including name, style and position in previewer PNG.
  • a directory structure recgonized by @xlfont/choose, with symbolic links to the fonts your provided.

Avilable options:

  • --link: or -l, output directory for symbolic links to font. default ./output/links.
  • --output: or -m, output directory for metadata. default ./output/meta.
  • --font-size: or -f, default font size. default 48, auto shrink if needed.

For a complete list of possible options, please run npx xfc --help directly.

Generate with Configurations

You can also generate metadata with a prepared configuration file with --config or -c option. Supported fields in this configuration file are as follow:

  • width: default 400, width of font preview box
  • height: default 50, height of font preview box
  • col: default 5,
  • padding: default 10,
  • fsize: default 48,
  • links: output directory for symboic links to font.
  • meta: output directory for metadata.
  • src: source directory for source fonts.
  • ignores: a list of regular expressions for font names to exclude.

LICENSE

MIT License.