feat: add font feature settings support
Implements #2155.
This PR adds the fontFeatureSettings style property (see MDN for the CSS equivalent). It takes a list of feature tags, which appends to the default set, or an object to turn on/off individual features, as supported by fontkit.
Why it matters
This allows users to apply any font features supported by a given font, such as tabular numbers, fractions, alternate glyphs, control over ligatures, etc.
Usage
const styles = StyleSheet.create({
numeric: {
fontFeatureSettings: ['tnum'],
}
});
Example
A full example is provided in the examples package. Here's how it looks like:
π¦ Changeset detected
Latest commit: 6430ed1a9515baae90b5c23359d3c84b9f454ed1
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 12 packages
| Name | Type |
|---|---|
| @react-pdf/textkit | Minor |
| @react-pdf/layout | Minor |
| @react-pdf/types | Minor |
| @react-pdf/render | Patch |
| @react-pdf/renderer | Patch |
| @react-pdf/font | Patch |
| @react-pdf/stylesheet | Patch |
| next-14 | Patch |
| next-15 | Patch |
| @react-pdf/vite-example | Patch |
| @react-pdf/e2e-node-cjs | Patch |
| @react-pdf/e2e-node-esm | Patch |
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
I'm of course also happy to extend the documentation site accordingly if this will be merged, I'd just need a pointer as to where I could contribute that.
I'm of course also happy to extend the documentation site accordingly if this will be merged, I'd just need a pointer as to where I could contribute that.
The website documentation is kept in the react-pdf-site repository.
Hi! Any news about this issue? Happy to help if needed :)
Up! Any update on this? Happy to help :)
I'm also happy to change anything needed for this to be merged :) Is there a process for getting this PR reviewed?
If anything can be done to merge this PR, please reach out. :)
Up, is there anything I can do to help this PR being merged? :)
This PR would help my team. Happy to help write documentation or assist where I can if it'd help get this approved.
Same as @bnlb. Happy to help for testing or writing docs :)
@diegomura Any pointers on how to get this PR reviewed? :)
Hi! Any updates on this PR being merged? As usual, feel free to reach out if you need any help :)
Hi!
Happy new year :)
Any updates on this PR? As always, more than happy to help however I can!
Hi! Any updates on this PR? Happy to contribute or help (docs, tests or anything else)> @diegomura @stefanwittwer
Hi! Any updates on this PR? Always happy to help if needed. :)
This PR was a bit out of date by now, so I integrated all latest changes into it and resolved the conflicts. Everything works again, as can be seen in the associated example.
@diegomura Just let me know there's anything else I can do to help the maintainers out here, or if there are any other blockers before it can be reviewed :)
Support for tabular numbers with this would be extremely useful for use cases where react-pdf is used to generate reports, etc. Worth noting also that everything needed here was already supported out-of-the-box by Fontkit, so this addition should not stand in the way of the goal of merging the PDFKit fork with the original.
Hello there ! Any news regarding this PR? As always, happy to help. :)
Hi! Any news? As always, please reach out if I can do anything to help :) Sam
@samueldrai It seems the layout package has been converted to TypeScript now on the main branch in #3092 and subsequent PRs. Would you be willing to help me bring my PR back to speed with all newer changes? I'm currently missing the time to do it unfortunately, but I'll accept your contribution on my fork for this PR. Hopefully that makes a path for this to get merged at some point
Of course, I'll get this done this done whenever I can @stefanwittwer :)
@samueldrai @stefanwittwer, i needed this and a few other fixes and features. idk why all these PRs are not being merged and I'm tired of waiting, so (for now at least) I forked react-pdf and republished under @rpdf/* see here https://github.com/MendyLanda/react-pdf
I don't have time for actively improving it, but reviewing and merging PRs is definitely doable.
thank you for this PR!
I've now brought this older PR up-to-date again by rebasing it onto the current master, to make sure it can be cleanly merged again. I also integrated the nice type-safety improvements that @MendyLanda added in his fork, thanks a lot!
Example is again up and running flawlessly:
@wojtekmaj @diegomura - Any pointers on how to get this PR reviewed by maintainers? It's been open for quite a while without any feedback. It certainly seems highly requested by the community judging by the previous comments in this thread :) Happy to help out where I can!
@wojtekmaj Ah sorryπ I assumed because your GitHub bio says so haha. Thanks for reviewing!
@stefanwittwer It IS true! But please do mind: https://github.com/diegomura/react-pdf#lost