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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@qgustavor/ass-obfuscator

v1.0.0

Published

Cursed font subsetting for .ass subtitles

Downloads

5

Readme

ASS Obfuscator

Cursed font subsetting for .ass subtitles.

It merges fonts referenced in a .ass subtitle in a single font, keeping only the glyphs used by the subtitle. Becuase fonts are merged, the glyphs need to be remapped to fit the subtitle's needs, so, "Z" might "é" if "Z" is not used in the subtitle but "é" is as in "café". As glyphs are changed it's needed to rewrite the subtitle to point to the proper glyphs, obfuscating it, thus the name "ASS obfuscator".

CLI usage

ass-obfuscator [path to subtitle] --folder [path to folder with fonts]
  • --folder: folder with fonts; can repeat; if it's not specified it will try to guess the system font folder
  • --target-dir: target file directory, defaults to current directory
  • --target-path: target subtitle path, defaults to [target dir]/[original name].min.ass
  • --font-name: name of generated merged font, defaults to a random string
  • --font-path: target font path, defaults to [target dir]/[name of target subtitle].ttf
  • --fallback-font: font to use as fallback, defaults to Arial per ASS spec

Requires FontForge installed and available either in PATH or location defined by FONTFORGE_PATH environment variable.

It will create and delete temporary files inside the current directory (temporary-fontforge-script.ff and temporary-font-*.ttf). If someone prefers using a proper temporary folder, send a PR.

Programatic usage

See cli.js, it's really small. Notice it's a ES module, you need to call const {default: obfuscate} = await import('@qgustavor/ass-obfuscator') when calling it from CommonJS.

Why?!

Why not?

Warning

That's cursed: a research was done by taking an anime episode and minifying with this tool, 1/3 of the participants said they could not watch the video. From that it's quite possible that a lot of people have issues configuring their players to load embedded fonts in videos. As a solution for this problem you can use the most cursed solution ever: just hardsub subtitles and wreck up with your encoder entropy.

Font subsetting is useful and is used by Chinese because Chinese fonts are extremely huge, so it's kinda a necessity. On the other hand merging multiple fonts into one can lead to issues and is the most cursed part. Surely, it helps reducing the total size because a lot of font metadata gets deduplicated in the process, but it's still cursed. Probably illegal too if fonts are licensed in a way they cannot be modified and/or require credits. Well, in the last case just include the font credits... maybe. If someone wish they can send a pull request removing font merging, but why? Just download the font subsetting script from the Chinese groups. It's in Chinese, but... ¯\_(ツ)_/¯