diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.22k stars 1.11k forks source link

Nested text styling does not work on Windows #2725

Open RKukharchuk opened 3 weeks ago

RKukharchuk commented 3 weeks ago

Describe the bug

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

Rendering this document with Roboto is messing up the formatting of next next blocks:

 <Document>
      <Page size="LETTER" wrap>
        <Text>
          <Text style={{ fontFamily: "Roboto", fontWeight: 'bold' }}>
            Should be bold
          </Text>
          <Text> Shouldn't be bold</Text>
        </Text>
      </Page>
    </Document>

Produces the following result image

Making the second part bold is doing nothing:

 <Document>
      <Page size="LETTER" wrap>
        <Text>
          <Text>
            Shouldn't be bold
          </Text>
          <Text style={{ fontFamily: "Roboto", fontWeight: 'bold' }}> Should be bold</Text>
        </Text>
      </Page>
    </Document>

Produces the following result: image

Expected behavior Text formatted according to the fontWeight.

Desktop (please complete the following information):

PS: It works perfectly on MacOS

RKukharchuk commented 3 weeks ago

After future inverstigations it looks like it's related to fonts resolution of text. Downgrading @react-pdf/layout to 3.11.5 helps to resolve the issue

Fry98 commented 2 weeks ago

@RKukharchuk Are you on Intel or Apple Silicon Mac? I'm on Macbook Air M3 and have still encountered this issue.

focux commented 1 week ago

I'm on Apple Silicon and I'm also having this issue, downgrading @react-pdf/layout made it work for me.

If anyone is wondering about how to do it, this how you do it with PNPM, update your package.json to resolve the layout version that we want:

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