diegomura / react-pdf

đź“„ Create PDF files using React
https://react-pdf.org
MIT License
14.46k stars 1.14k forks source link

Copy and pasting Roboto font from Chrome PDF preview results in missing characters. #2762

Open pd2xts opened 1 month ago

pd2xts commented 1 month ago

Describe the bug

Using Google's Roboto TTF fonts, when I copy and past from Chrome PDF preview, certain characters in my pasted text are missing. For example the copied word beneficial, pastes as benefcial, missing an i.

This seems very similar to this now-resolved issue https://github.com/diegomura/react-pdf/issues/1950.

To Reproduce

Version "@react-pdf/renderer": "^3.4.4"

Font registration:

Font.register({
    family: 'Roboto',
    fonts: [
      {
        src: '/fonts/Roboto-Regular.ttf'
      },
      {
        src: '/fonts/Roboto-Light.ttf',
        fontWeight: 200
      },
      {
        src: '/fonts/Roboto-Italic.ttf',
        fontStyle: 'italic'
      },
      {
        src: '/fonts/Roboto-Bold.ttf',
        fontWeight: 600
      },
      {
        src: '/fonts/Roboto-BoldItalic.ttf',
        fontStyle: 'italic',
        fontWeight: 600,
      },
    ],
  })

If I download the document and do the same thing using Mac OS Preview, then the characters copy and paste correctly.

Expected behaviour

Characters copy and paste correctly

Desktop:

AbdelMounhim commented 1 month ago

it seems like fix: copy-paste for registered font

AbdelMounhim commented 1 month ago

I have the same problem, using Roboto web fonts

Font.register({
  family: 'Roboto',
  src: 'https://fonts.gstatic.com/s/roboto/v19/KFOmCnqEu92Fr1Mu4mxPKTU1Kg.ttf',
});

Font.register({
  family: 'Roboto-Bold',
  src: 'http://fonts.gstatic.com/s/roboto/v15/d-6IYplOFocCacKzxwXSOKCWcynf_cDxXwCLxiixG1c.ttf',
});