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

Included fonts does not support fontWeight modifier for default fonts #649

Open
fizker opened this issue Jun 24, 2019 · 3 comments · May be fixed by #2338
Open

Included fonts does not support fontWeight modifier for default fonts #649

fizker opened this issue Jun 24, 2019 · 3 comments · May be fixed by #2338

Comments

@fizker
Copy link

fizker commented Jun 24, 2019

Describe the bug
It looks like react-pdf should support font weights (#535), but this does not seem to be the case for the included fonts.

To Reproduce
The snippet below creates three lines. The first is normal weight for reference, and the other two are different ways of setting font weight; The first uses the fontWeight modifier, the other explicitly references Helvetica-Bold. The second and third should look the same, since { fontFamily: 'Helvetica', fontWeight: 'bold' } should be equivalent to { fontFamily: 'Helvetica-Bold' }

REPL with the code below

const doc = (
  <Document>
    <Page size="A4">
      <View style={{ font: 'Helvetica', fontWeight: 'normal' }}>
        <Text>Section #1 (normal text)</Text>
        <Text style={{ fontFamily: 'Helvetica', fontWeight: 'bold' }}>Section #1 (fontWeight only)</Text>
        <Text style={{ fontFamily: 'Helvetica-Bold' }}>Section #1 (explicit fontFamily)</Text>      
      </View>
    </Page>
  </Document>
);

ReactPDF.render(doc);

Expected behavior
{ fontFamily: 'Helvetica', fontWeight: 'bold' }
should be equivalent to
{ fontFamily: 'Helvetica-Bold' }

Desktop (please complete the following information):

  • MacOS
  • chrome
  • React-pdf version v1.6.0 in the REPL, v1.6.2 locally
@diegomura
Copy link
Owner

Agreed! Will try to take a look soon

@diegomura diegomura changed the title Included fonts does not support fontWeight modifier. Included fonts does not support fontWeight modifier for default fonts Jun 24, 2019
@chaofan232
Copy link

Hi, just wondering is there a solution for this issue now?

@owenduncansnobel
Copy link

I am having this problem now. Has the accepted solution just been reloading the default font with ReactFont to be able to set the fontWeight?

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

Successfully merging a pull request may close this issue.

4 participants