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: f33ad19

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 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
@react-pdf/examples 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.

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.

None yet

2 participants