react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

feat: add font feature settings support

Open stefanwittwer opened this issue 1 year ago β€’ 25 comments

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:

CleanShot 2024-05-05 at 12 05 59@2x

stefanwittwer avatar May 05 '24 10:05 stefanwittwer

πŸ¦‹ 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

changeset-bot[bot] avatar May 05 '24 10:05 changeset-bot[bot]

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.

stefanwittwer avatar May 05 '24 10:05 stefanwittwer

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.

bdkopen avatar May 05 '24 18:05 bdkopen

Hi! Any news about this issue? Happy to help if needed :)

samueldrai avatar Jul 19 '24 11:07 samueldrai

Up! Any update on this? Happy to help :)

samueldrai avatar Oct 23 '24 14:10 samueldrai

I'm also happy to change anything needed for this to be merged :) Is there a process for getting this PR reviewed?

stefanwittwer avatar Oct 24 '24 06:10 stefanwittwer

If anything can be done to merge this PR, please reach out. :)

samueldrai avatar Oct 31 '24 16:10 samueldrai

Up, is there anything I can do to help this PR being merged? :)

samueldrai avatar Dec 03 '24 14:12 samueldrai

This PR would help my team. Happy to help write documentation or assist where I can if it'd help get this approved.

bnlb avatar Dec 05 '24 22:12 bnlb

Same as @bnlb. Happy to help for testing or writing docs :)

samueldrai avatar Dec 11 '24 13:12 samueldrai

@diegomura Any pointers on how to get this PR reviewed? :)

stefanwittwer avatar Dec 11 '24 15:12 stefanwittwer

Hi! Any updates on this PR being merged? As usual, feel free to reach out if you need any help :)

samueldrai avatar Dec 19 '24 13:12 samueldrai

Hi!

Happy new year :)

Any updates on this PR? As always, more than happy to help however I can!

samueldrai avatar Jan 07 '25 14:01 samueldrai

Hi! Any updates on this PR? Happy to contribute or help (docs, tests or anything else)> @diegomura @stefanwittwer

samueldrai avatar Feb 07 '25 12:02 samueldrai

Hi! Any updates on this PR? Always happy to help if needed. :)

samueldrai avatar Feb 20 '25 13:02 samueldrai

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.

stefanwittwer avatar Feb 22 '25 15:02 stefanwittwer

Hello there ! Any news regarding this PR? As always, happy to help. :)

samueldrai avatar Mar 19 '25 14:03 samueldrai

Hi! Any news? As always, please reach out if I can do anything to help :) Sam

samueldrai avatar Apr 22 '25 12:04 samueldrai

@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

stefanwittwer avatar Apr 22 '25 12:04 stefanwittwer

Of course, I'll get this done this done whenever I can @stefanwittwer :)

samueldrai avatar Apr 22 '25 12:04 samueldrai

@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.

MendyLanda avatar Jun 15 '25 14:06 MendyLanda

thank you for this PR!

MendyLanda avatar Jun 15 '25 14:06 MendyLanda

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: Dia 2025-10-20 16 40 50

@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!

stefanwittwer avatar Oct 20 '25 14:10 stefanwittwer

@wojtekmaj Ah sorryπŸ˜‚ I assumed because your GitHub bio says so haha. Thanks for reviewing!

stefanwittwer avatar Oct 22 '25 08:10 stefanwittwer

@stefanwittwer It IS true! But please do mind: https://github.com/diegomura/react-pdf#lost

wojtekmaj avatar Oct 22 '25 11:10 wojtekmaj