@fredli74/typr

中文文档
0.3.10发布于 2026/11/13MITTypeScriptCommonJS零依赖近 30 天下载 2246
原始使用文档

Typr.ts

TypeScript class wrapper for photopea/Typr.js.

Design goal was to keep the core Typr.js fork in a separate branch as close to the original as possible to make eventual merging easier.

As of May 2020, the official photopea Typr.js project switched to using HarfBuzz and threw a lot of the font format parsing out. For that reason, my fork will have to continue it's own path.

I use this library in one of my own TypeScript projects and have only added class features that I needed.

  • Typr.parse(buffer) is done through the class constructor new typr.Font(buffer)
  • Typr.U functions are members of the class font.codeToGlyph(code)

Installation

npm install @fredli74/typr --save-dev

node load example

import * as fs from "fs";
import * as typr from '@fredli74/typr';

function toArrayBuffer(buf: Buffer) {
    let ab = new ArrayBuffer(buf.length);
    let view = new Uint8Array(ab);
    for (let i = 0; i < buf.length; ++i) {
        view[i] = buf[i];
    }
    return ab;
}
const data = fs.readFileSync("filename.ttf");
const font = new typr.Font(toArrayBuffer(data));

版本与发布记录

@fredli74/typr 共发布 13 个版本,首次发布于 2018/10/26;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.3.10latest2026/11/132 天前
0.3.92024/06/202 年前
0.3.82023/06/033 年前
0.3.72022/06/054 年前
0.3.62022/06/054 年前
0.3.52022/03/124 年前

关于 @fredli74/typr 的常见问题

@fredli74/typr 是什么?

TypeScript fork of https://github.com/photopea/Typr.js

如何安装 @fredli74/typr?

在项目目录运行 npm install @fredli74/typr,或使用 pnpm add / yarn add / bun add。

@fredli74/typr 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fredli74/typr 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fredli74/typr 可以商用吗?

@fredli74/typr 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fredli74/typr 的下载量有多少?

根据 npm 官方下载统计,@fredli74/typr 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,246 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fredli74/typr 还在维护吗?

最新版本 0.3.10 发布于 2026/11/13(2 天前);至今共发布 13 个版本,其中过去 12 个月发布了 1 个;首次发布于 2018/10/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。