-
Notifications
You must be signed in to change notification settings - Fork 45
Replace fontkit with fontkitten #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b72d8d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Just released the v1 of fontkitten and updated this PR with it, so should be ready for review when someone has time! |
| } | ||
|
|
||
| if (font !== null && 'fonts' in font && Array.isArray(font.fonts)) { | ||
| if (font !== null && font.isCollection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isCollection is a new property added in fontkitten to make it easier to quickly distinguish between fonts and font collections.
| export const fromFile = async ( | ||
| path: string, | ||
| options?: Options, | ||
| ): Promise<Font> => { | ||
| const buffer = await readFile(path); | ||
| return _fromBuffer(buffer, 'fromFile', 'path', options); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we’re not using Fontkit’s open() method, I refactored this to just reuse the _fromBuffer function.
| import { XMLParser } from 'fast-xml-parser'; | ||
| import sortKeys from 'sort-keys'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__dirname is not available in ES modules, so now that this package is marked as ESM with "type": "module" in package.json, this is needed to provide the same value.
This is a draft PR replacing the
fontkitdependency withfontkittenin theunpackpackage, reducing install size by ~16x (I haven’t measured forunpackspecifically yet, but this should also reduce bundle size by ~3x). It would in theory close #236 eventually.Because
fontkittenis ESM-only, this PR also makesunpackESM-only (it is currently shipped as a dual CJS+ESM package).