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

fix: font selection regression #2747

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

andrew-spare
Copy link

@andrew-spare andrew-spare commented May 8, 2024

This recent change #2640 appears to have caused a regression where the first font used in a line of text is utilized for the entire line. This includes usage of fontFamily, fontWeight, and fontStyle.

Changes

  • Fixed pickFontFromFontStack to select from fontStack before lastFont. This should now properly prioritize fonts
  • Added unit tests: packages/layout/tests/text/fontSubstitution.test.js
  • Updated example document to include this scenario

Related

Example

<Text style={{ fontSize: 10 }}>
  The following are multiple font families, weights, and styles all on the
  same line
</Text>
<Text style={{ fontFamily: 'Roboto' }}>
  Roboto Normal{' / '}
  <Text style={{ fontWeight: 'bold' }}>Roboto Bold</Text>
  {' / '}
  <Text style={{ fontStyle: 'italic' }}>Roboto Italic</Text>
  {' / '}
  <Text style={{ fontFamily: 'Courier' }}>Courier</Text>
</Text>

Before

example-before

After

example-after

Copy link

changeset-bot bot commented May 8, 2024

⚠️ No Changeset found

Latest commit: e5f9602

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@iSilkline
Copy link

@diegomura could you please merge this?

@TomasSalas
Copy link

@diegomura Plase merge this ! i need :(

@websnacks
Copy link

Yes I am using this library as well and right now the fonts are not working correctly. This fix is what I am waiting for! Please merge!

@TomasSalas
Copy link

@websnacks Dear, when can we see the change reflected in the library? I am waiting for this change to upload a code to improve a PDF

@TomasSalas
Copy link

When are the changes going to go up? I need it @diegomura @bdkopen

@Hatko
Copy link

Hatko commented May 22, 2024

I applied these changes, but still couldn't get the bold font back. Instead, to resolve it, I forced the resolution of "@react-pdf/layout" to point to 3.11.5. We are using bun, for it you need to add:

"overrides": {
    "@react-pdf/layout": "3.11.5"
},

to your package.json

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

5 participants