Skip to content
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

feat: add font feature settings support #2740

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stefanwittwer
Copy link

@stefanwittwer stefanwittwer commented May 5, 2024

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

Copy link

changeset-bot bot commented May 5, 2024

🦋 Changeset detected

Latest commit: 3bd1a79

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

@stefanwittwer
Copy link
Author

stefanwittwer commented May 5, 2024

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.

@bdkopen
Copy link
Contributor

bdkopen commented May 5, 2024

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.

@samueldrai
Copy link

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

@samueldrai
Copy link

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

@stefanwittwer
Copy link
Author

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

@samueldrai
Copy link

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

@samueldrai
Copy link

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

@bnlb
Copy link

bnlb commented Dec 5, 2024

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

@samueldrai
Copy link

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

@stefanwittwer
Copy link
Author

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

@samueldrai
Copy link

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

@samueldrai
Copy link

Hi!

Happy new year :)

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

@samueldrai
Copy link

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

@samueldrai
Copy link

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

Added font feature settings to TextStyle

Adapted example to new structure
@stefanwittwer
Copy link
Author

stefanwittwer commented Feb 22, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants