Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
2cefa31
denkiyagi-fork initial modification
fal-works Sep 16, 2024
90a5b52
feat: enable to get VORG properties
fal-works Sep 17, 2024
ec4352d
docs: edit comments of properties to access VORG
fal-works Sep 17, 2024
ec764eb
return null instead of undefined
fal-works Sep 17, 2024
92f787e
docs: update MODIFICATIONS
fal-works Sep 17, 2024
2968d15
feat: add TTFFont#getVertOriginYMap and use it in Glyph#vertOriginY
fal-works Sep 17, 2024
3fbe120
stop caching in Glyph#vertOriginY
fal-works Sep 17, 2024
cc29ded
minor fix in TTFFont#defaultVertOriginY
fal-works Sep 17, 2024
6a4b398
Merge pull request #1 from DenkiYagi/feat-vorg
terurou Nov 14, 2024
2e3e983
fix: wrong data type of `version` property in `vhea` table
fal-works Nov 13, 2024
913e66e
test: add test for tables
fal-works Nov 13, 2024
353faae
fix: expose ascent, descent and lineGap depending on the USE_TYPO_MET…
fal-works Nov 13, 2024
982b03e
docs: update MODIFICATIONS.md
fal-works Nov 20, 2024
c18eb18
Merge pull request #2 from DenkiYagi/fix-ascent-descent
terurou Nov 20, 2024
8ecd0ac
add @ts-check
fal-works Nov 20, 2024
c57d4bf
stop argument shifting in LayoutEngine#layout
fal-works Nov 20, 2024
b65462e
add @ts-check
fal-works Nov 20, 2024
0c9f8e7
use d.ts file for internal type definitions
fal-works Nov 20, 2024
5813f07
update jsconfig
fal-works Nov 20, 2024
8f92386
more type checks
fal-works Nov 20, 2024
51348d7
more null-checks
fal-works Nov 23, 2024
50db2e8
use named parameters for `TTFFont#layout` and `LayoutEngine#layout`
fal-works Nov 23, 2024
5598bf1
more type checks
fal-works Nov 23, 2024
5540dea
stop using static fields in Shaper classes
fal-works Nov 23, 2024
da7a70b
enable to use custom shaper in TTFFont#layout
fal-works Nov 23, 2024
4d91433
expose DefaultShaper and remove fraction features ('frac', 'numr', 'd…
fal-works Nov 23, 2024
8969b4c
move directional features ('ltra' etc.) from DefaultShaper to ArabicS…
fal-works Nov 25, 2024
48a8eef
more type checks
fal-works Nov 25, 2024
ed4b74b
enable to skip positioning per glyph
fal-works Nov 25, 2024
8ae9068
docs: update MODIFICATIONS.md
fal-works Nov 26, 2024
db3ddf4
Merge pull request #3 from DenkiYagi/improve-layout-function
terurou Nov 26, 2024
fbb39b6
refactor: `export let` -> `export const`
fal-works Nov 26, 2024
f14b9ac
add prettierrc
fal-works Nov 26, 2024
7ec3319
minor
fal-works Nov 26, 2024
f973824
fix: variable exports to getter functions
fal-works Nov 26, 2024
cdd534a
docs: update MODIFICATIONS.md
fal-works Nov 26, 2024
c1b29a7
Merge pull request #4 from DenkiYagi/fix-variable-exports
terurou Nov 27, 2024
3f76cf3
types.d.ts -> types.ts
fal-works Nov 26, 2024
9e1fc07
update dependencies
fal-works Nov 26, 2024
e5bc847
build: transpile and expose type definitions
fal-works Nov 26, 2024
e76bd12
expose some more classes
fal-works Nov 26, 2024
a4acdef
expand type TTFFont
fal-works Nov 26, 2024
36d153e
expose some more types from `types.d.ts`
fal-works Nov 26, 2024
52cc402
fix Font-like types
fal-works Nov 26, 2024
3925b7e
improve type definitions
fal-works Nov 26, 2024
39f03cf
improve Subset classes
fal-works Nov 27, 2024
73e632a
improve type definition of TTFFont classes
fal-works Nov 27, 2024
767ee74
remove re-exports.js
fal-works Nov 27, 2024
272e02f
docs: update MODIFICATIONS.md
fal-works Nov 27, 2024
db3d53c
2.0.4-mod.2024.1
fal-works Nov 27, 2024
bbab32b
remove unused type
fal-works Nov 27, 2024
e3c4c2e
style: format code
fal-works Nov 27, 2024
e854e6a
Merge pull request #5 from DenkiYagi/expose-types
terurou Nov 27, 2024
24a3dad
prepare release
fal-works Nov 27, 2024
3fb84d4
fix: keep GlyphRun#features not null
fal-works Dec 4, 2024
0dc4fea
change null-check to truthy-check
fal-works Dec 4, 2024
63d2987
Merge pull request #6 from DenkiYagi/fix-glyphrun-features-nullcheck
terurou Dec 5, 2024
78fe676
ci: script prepack instead of prepublish
fal-works Dec 29, 2024
5b3c85b
prepare instead of prepack
fal-works Dec 29, 2024
cb3888f
2.0.4-mod.2024.2
fal-works Dec 29, 2024
a846ed2
add format 14 cmap support and IVS to JP feature mapping
terurou Jun 28, 2025
00dec28
add license file
terurou Jun 28, 2025
139f07f
Improve IVS
terurou Jun 28, 2025
bb2ee07
improve IVS support
terurou Jun 28, 2025
b17a1e4
revert mapping IVS to GSUB feature
fal-works Jul 1, 2025
548d6bc
refactor getVariationSelector(), rename to lookupNonDefaultVariation()
fal-works Jul 1, 2025
a362931
test: update and integrate CMAP format 14 tests
fal-works Jul 1, 2025
d023523
feat: add TTFFont#nonDefaultUVSSet
fal-works Jul 1, 2025
21fa669
remove old file
fal-works Jul 1, 2025
5e6de9d
v2.0.4-mod.2025.1
fal-works Jul 1, 2025
63b234c
refactor: rename lookupNonDefaultVariation() -> lookupNonDefaultUVS
fal-works Jul 1, 2025
a9aa85a
Merge pull request #8 from DenkiYagi/feature/ivs
terurou Jul 2, 2025
3cd706a
perf: cache CmapProcessor.uvs.varSelectors.toArray()
Oct 22, 2025
f5d9f64
perf: cache variation selector record for each variation selector cod…
Oct 22, 2025
3282ba6
v2.0.4-mod.2025.2
Oct 22, 2025
43840c5
refactor: rename _variationSelectorRecords to _variationSelectorRecor…
Oct 22, 2025
4a15dc4
Merge pull request #9 from DenkiYagi/improvement/uvs-lookup-performance
terurou Oct 23, 2025
f57caeb
自動テスト追加 等 (#10)
falworks-dy Nov 13, 2025
86dfcdd
WOFF, WOFF2, DFont 形式の対応を削除 (#11)
falworks-dy Nov 13, 2025
9ef96e1
utility系のnpm依存 (clone, fast-deep-equal) を削除 (#12)
falworks-dy Nov 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Publish Node.js Package on GitHub Packages

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run trie
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: build-output
path: |
dist/
types/

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com/
scope: '@denkiyagi'
- uses: actions/download-artifact@v4
with:
name: build-output
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on:
push:
branches: ['denkiyagi-fork']
pull_request:
branches: ['denkiyagi-fork']

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read

strategy:
matrix:
node-version: [20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install dependencies
run: npm ci

- name: Rebuild shaping tries
run: npm run trie

- name: Run tests
run: npm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ indic.trie
indic.json
dist
.parcel-cache
/types/

.npmrc
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always"
}
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

43 changes: 43 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# AI Agent Briefing

## Mission & Scope
- `@denkiyagi/fontkit` is our maintained fork of the upstream `fontkit`, powering typography in `yagisan-reports` (and downstream `@denkiyagi/pdf-lib`).
- Versioning follows `2.0.4-mod.YYYY.N`. Every intentional divergence must land in `MODIFICATIONS.md` so downstream agents understand the API surface we guarantee.
- Recent focus areas captured in `MODIFICATIONS.md`:
- Better Unicode variation selector (UVS) handling
- Richer shaping controls
- Vertical metrics accuracy
- Predictable type definitions for consumers

## Repository Orientation
- `src/` – Main implementation, mostly ESM `.js` files with `@ts-check`. Key areas: `glyph/`, `layout/`, `opentype/` (shapers, GSUB/GPOS logic), `tables/`, `subset/`, and entrypoints `index.ts` (browser) & `node.ts` (Node/fs helpers).
- `types/` – Generated `.d.ts` output from `npm run build:types`. Never hand-edit.
- `dist/` – Parcel bundles emitted by `npm run build:js` (CJS/ESM/browser targets). Never hand-edit.
- `test/` – Mocha (ESM) regression suite plus `test/data/` font fixtures; keep fixtures stable and small.
- `MODIFICATIONS.md` – Single source of truth for fork-specific behavior; update whenever behavior changes.

## Toolchain & Commands
- Use Node 20+ and npm (repo ships `package-lock.json`). Install with `npm install`.
- Fast feedback loop:
- `npm run build:js` → Parcel build into `dist/`.
- `npm run build:types` → `tsc --project tsconfig-types.json` (follows `src/index.ts` & `src/node.ts`, pulls in JS via `allowJs`).
- `npm run mocha` → run tests without rebuilding.
- `npm test` → full build + mocha (what CI runs).
- `npm run coverage` → `c8 mocha`.
- `npm run trie:*` → regenerate shaping tries (`src/opentype/shapers/*.trie` & companion `.json`) when Unicode data/scripts change; outputs are gitignored.
- `npm run clean` removes build outputs—rerun builds before publishing or testing.

## Coding Guidelines & Pitfalls
- Preserve existing `// @ts-check` comments and JSDoc—they drive declaration output.
- Prefer editing sources under `src/`. Touch `types/` or `dist/` only via build scripts.
- When adding TS types or new exports, update `src/types.ts`, re-run `npm run build:types`, and ensure both `index.ts` and `node.ts` export the new surface.
- Keep performance-sensitive code (e.g., cmap processing, shapers) allocation-free; mimic existing patterns (caching decorators, typed arrays).

## Testing & Validation
- Run `npm run mocha` only when `npm run build:*` has already refreshed `dist/` and `types/`; otherwise use `npm test` so the build step runs first (matches CI).
- Use `npm run coverage` only when you need c8 instrumentation (slower but catches missed branches).

## Data & Fixture Workflow
- Unicode trie data (`src/opentype/shapers/*.trie` and `.json`) is generated; edit the source scripts (`generate-data.js`, `gen-use.js`, `gen-indic.js`) or `.machine` files, then re-run the matching `npm run trie:*` task locally (artifacts remain untracked per `.gitignore`).
- The repository intentionally vendors select fonts under `test/data/`; do not rename paths without updating tests.
- Avoid storing unrelated binaries in-tree—use temporary paths outside the repo for manual experiments.
48 changes: 48 additions & 0 deletions MODIFICATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Modifications

## [Unreleased]

- Remove WOFF format support
- Also removing the `tiny-inflate` dependency (the indirect dependency may remain)
- Remove WOFF2 format support
- Also removing the `brotli` dependency
- Remove DFont format support
- Simplify the published TypeScript types by inlining the concrete format exports (`TTFFont`/`TrueTypeCollection`) in place of the old aliases (`Font`/`FontCollection`).
- Remove the dependencies below by replacing them with new internal helpers (no API changes):
- `clone` (used by `TTFSubset`)
- `fast-deep-equal` (used by `CFFDict`)

## [2.0.4-mod.2025.2]

- Improve performance of `CmapProcessor#lookupNonDefaultUVS` by caching variation selector records from `cmap` format 14 subtable

## [2.0.4-mod.2025.1]

- Fix glyph mapping using the cmap format 14 subtable, improving support for UVS in methods like `TTFFont#glyphsForString`
- Add `TTFFont#nonDefaultUVSSet`


## [2.0.4-mod.2024.2]

- Add properties to get the glyph's origin Y coordinate in the vertical writing mode:
- `TTFFont#defaultVertOriginY`
- `TTFFont#getVertOriginYMap`
- `Glyph#vertOriginY`
- Fix data type of `version` property in `vhea` table
- Fix properties `ascent`, `descent` and `lineGap` in `TTFFont` class so that they refer to `OS/2` table when `USE_TYPO_METRICS` flag is ON
- Improve class `DefaultShaper` and its sub-classes
- Omit fractional features: frac, dnom, numr
- Move directional features to `ArabicShaper`: ltra, ltrm, rtla, rtlm
- Expose class `DefaultShaper` from `fontkit`
- Improve `TTFFont#layout`
- Use named parameters
- Add parameter `shaper` to override shaping process
- Add parameter `skipPerGlyphPositioning` to skip calculating `GlyphRun#positions`
- Fix fields `logErrors` and `defaultLanguage` in the top-level API
- Change to getter functions: `isLoggingErrors()`, `getDefaultLanguage()`
- Expose type definitions


## [2.0.4-mod.2024.1]

- Removed
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
**A modified version of [fontkit](https://github.com/foliojs/fontkit) for [yagisan-reports](https://denkiyagi.jp/yagisan-reports/).**

See also: [MODIFICATIONS.md](MODIFICATIONS.md)

----

# fontkit

Fontkit is an advanced font engine for Node and the browser, used by [PDFKit](https://github.com/devongovett/pdfkit). It supports many font formats, advanced glyph substitution and layout features, glyph path extraction, color emoji glyphs, font subsetting, and more.

## Features

* Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collection (.ttc), and Datafork TrueType (.dfont) font files
* Supports TrueType (.ttf), OpenType (.otf), and TrueType Collection (.ttc) font files (WOFF/WOFF2/DFont inputs have been removed)
* Supports mapping characters to glyphs, including support for ligatures and other advanced substitutions (see below)
* Supports reading glyph metrics and laying out glyphs, including support for kerning and other advanced layout features (see below)
* Advanced OpenType features including glyph substitution (GSUB) and positioning (GPOS)
Expand All @@ -22,7 +28,7 @@ Fontkit is an advanced font engine for Node and the browser, used by [PDFKit](ht
## Example

```javascript
var fontkit = require('fontkit');
var fontkit = require('@denkiyagi/fontkit');

// open a font synchronously
var font = fontkit.openSync('font.ttf');
Expand Down
4 changes: 3 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"compilerOptions": {
"strictNullChecks": true,
"target": "es2015",
"experimentalDecorators": true
}
}
}
Loading