react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Fontweights style not working

Open baesslerpa opened this issue 1 year ago • 4 comments

import { PDFViewer, Document, Page, View, Text } from '@react-pdf/renderer';

function App() {
  return (
    <>
      <PDFViewer>
        <Document>
          <Page size="A4" style={{}}>
            <View style={{ fontWeight: 700 }}>
              <Text>Section #1</Text>
            </View>
            <View style={{ fontWeight: 'normal' }}>
              <Text>Section #2</Text>
            </View>
          </Page>
        </Document>
      </PDFViewer>
    </>
  );
}

export default App;

https://stackblitz.com/edit/vitejs-vite-389pzyqw

in production app im using

Font.register({
  family: 'Proxima',
  fonts: [
    { fontWeight: 'normal', src: '/fonts/ProximaNovaCondensed-Regular.ttf' },
    {
      fontWeight: 'bold',
      src: '/fonts/ProximaNovaCondensed-Bold.ttf',
    },
  ],
});

which either renders all fonts bold or none, depending on which style is first applied

opening a new issue, since all similar are closed. using this minimal example, i still dont get the fontweights applied.

baesslerpa avatar Dec 17 '24 11:12 baesslerpa

I guess font weight is not supporting thats why you are getting this isuse. i am getting same issue so pls let me know if you have found any thing regarding this to fix this issue.

santrajyadav196 avatar Jan 13 '25 05:01 santrajyadav196

@santrajyadav196 according to the docs it should be supported https://react-pdf.org/repl?example=font-register but i could not resolve the issue so far

baesslerpa avatar Jan 20 '25 16:01 baesslerpa

Could resolve the issue. The font was for web usage only, using a font that allows for Print/Desktop fixes the issue. Still not sure why the bug is also in the example I provided.

baesslerpa avatar Feb 04 '25 12:02 baesslerpa

I am using fontStyle: "bold" | "normal", it works

umihui avatar Feb 07 '25 00:02 umihui