Fontkit currently needs an absolute file path (or a Buffer) to load a font.
It would be useful to pass a family name like "Helvetica" and have Fontkit locate the file automatically, similar to how browsers and GUI toolkits work.
Example API:
const font = await fontkit.openSystem('Helvetica', {
weight: 400,
style: 'normal'
});
this means that all font family name use should be installed on the system first.
Without built-in lookup, each project has to:
- Scan OS font directories (
/System/Library/Fonts, /usr/share/fonts, C:\Windows\Fonts, etc.)
- Handle platform quirks (macOS
.ttc bundles, Windows registry, Linux fontconfig)
- Reimplement matching logic for weight/style/fallback
This logic is duplicated across many projects and is easy to get wrong.
Use libraries like font-manager or system-fonts to resolve paths, then open in Fontkit. Works, but adds dependencies and complexity.
Happy to help with a PR and cross-platform tests if maintainers are open to it.
Fontkit currently needs an absolute file path (or a Buffer) to load a font.
It would be useful to pass a family name like
"Helvetica"and have Fontkit locate the file automatically, similar to how browsers and GUI toolkits work.Example API:
this means that all font family name use should be installed on the system first.
Without built-in lookup, each project has to:
/System/Library/Fonts,/usr/share/fonts,C:\Windows\Fonts, etc.).ttcbundles, Windows registry, Linux fontconfig)This logic is duplicated across many projects and is easy to get wrong.
Use libraries like
font-managerorsystem-fontsto resolve paths, then open in Fontkit. Works, but adds dependencies and complexity.Happy to help with a PR and cross-platform tests if maintainers are open to it.